Bug 71916 - [chromium] scroll deltas are cleared during commit to the main thread
Summary: [chromium] scroll deltas are cleared during commit to the main thread
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Hin-Chung Lam
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 07:43 PST by Hin-Chung Lam
Modified: 2011-11-15 02:52 PST (History)
6 users (show)

See Also:


Attachments
Patch (9.94 KB, patch)
2011-11-09 07:58 PST, Hin-Chung Lam
no flags Details | Formatted Diff | Diff
Patch (17.73 KB, patch)
2011-11-09 13:47 PST, Hin-Chung Lam
no flags Details | Formatted Diff | Diff
Patch for landing (19.22 KB, patch)
2011-11-10 04:12 PST, Hin-Chung Lam
no flags Details | Formatted Diff | Diff
Patch (9.14 KB, patch)
2011-11-14 09:24 PST, Hin-Chung Lam
no flags Details | Formatted Diff | Diff
Patch (8.44 KB, patch)
2011-11-14 10:33 PST, Hin-Chung Lam
no flags Details | Formatted Diff | Diff
Patch (8.33 KB, patch)
2011-11-14 10:36 PST, Hin-Chung Lam
no flags Details | Formatted Diff | Diff
Patch (5.32 KB, patch)
2011-11-14 12:32 PST, Hin-Chung Lam
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hin-Chung Lam 2011-11-09 07:43:20 PST
Scroll deltas of CCLayerImpl are needed to properly position layers that are fixed to the container layer.

Compositor currently clears scroll deltas when committing the scroll deltas to the main thread. This leave a brief time when scroll deltas are not available and fixed layers are not positioned properly.
Comment 1 Hin-Chung Lam 2011-11-09 07:58:33 PST
Created attachment 114280 [details]
Patch
Comment 2 Hin-Chung Lam 2011-11-09 08:04:18 PST
Hi James, please take a look at this patch.

I found that CCLayerTreeHostImpl::subtractScrollDeltas() and CCLayerTreeHost::applyScrollDeltas() have very different behavior and not sensible to share code between them.

CCLayerTreeHost::applyScrollDeltas() looks like it's to notify the client to find the corresponding scrollable element to apply scroll. This code currently goes through WebViewImpl to accomplish this.

CCLayerTreeHost::subtractScrollDeltas() can just subtract scroll deltas from the current scroll.
Comment 3 James Robinson 2011-11-09 12:00:07 PST
Comment on attachment 114280 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=114280&action=review

> Source/WebCore/ChangeLog:15
> +        Reviewed by NOBODY (OOPS!).

this line should go above the long-form patch description, directly below the 1-line desc and bug URL:

[chromium] Foo the blobbizer
https://bugs.webkit.org/show_bug.cgi?id=12345

Reviewed by NOBODY (OOPS!).

> Source/WebCore/ChangeLog:20
> +          are unchanged during commit. And then after commit scroll delts are

delts -> deltas

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:230
> +    if (!m_scrollLayerImpl || !scrollInfo.size())
> +        return;
> +
> +    // FIXME: subtract scroll deltas from layer other than the root.
> +    ASSERT(scrollInfo.size() == 1 && scrollInfo[0].layerId == m_scrollLayerImpl->id());
> +    IntSize scrollDelta = scrollInfo[0].scrollDelta;

this whole part is still copy-pasted, and once we start applying scroll deltas to more than the root layer this will be significantly larger.

> Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp:414
> +    m_layerTreeHostImpl->subtractScrollDeltas(*scrollInfo.get());

just *scrollInfo, the .get() is noise
Comment 4 Hin-Chung Lam 2011-11-09 13:47:22 PST
Created attachment 114357 [details]
Patch
Comment 5 Hin-Chung Lam 2011-11-09 13:51:29 PST
Hi James, I updated the patch moving applyScrollDeltas to CCLayerTreeHostCommon which calls into the root layer, either LayerChromium or CCLayerImpl. Please have another look.
Comment 6 James Robinson 2011-11-09 14:52:22 PST
Comment on attachment 114357 [details]
Patch

Thanks, this is exactly what I had in mind. R=me, I think I want https://bugs.webkit.org/show_bug.cgi?id=71595 to land first since this will very slightly conflict so holding off on cq for now.
Comment 7 Alexandre Elias 2011-11-09 15:58:28 PST
OK, https://bugs.webkit.org/show_bug.cgi?id=71595 has landed, please pull it in and resolve conflicts.  One trivial one is that CCScrollUpdateSet was renamed to CCScrollAndScaleSet and the Vector is now a member ("scrolls").  It looks like semantically speaking, the CLs should be compatible, but please let me know if you run into any bugs after merging it in.
Comment 8 James Robinson 2011-11-09 18:06:17 PST
Comment on attachment 114357 [details]
Patch

cq- since this patch will have merge conflicts
Comment 9 Hin-Chung Lam 2011-11-10 04:12:43 PST
Created attachment 114471 [details]
Patch for landing
Comment 10 WebKit Review Bot 2011-11-10 06:09:12 PST
Comment on attachment 114471 [details]
Patch for landing

Clearing flags on attachment: 114471

Committed r99844: <http://trac.webkit.org/changeset/99844>
Comment 11 WebKit Review Bot 2011-11-10 06:09:16 PST
All reviewed patches have been landed.  Closing bug.
Comment 12 James Robinson 2011-11-11 18:34:30 PST
After more thought I don't like this approach, it's too gross and confusing.  Anything that needs to know the deltas on the impl side should just track that directly.
Comment 13 Hin-Chung Lam 2011-11-14 09:24:58 PST
Created attachment 114963 [details]
Patch
Comment 14 Hin-Chung Lam 2011-11-14 09:28:00 PST
Comment on attachment 114963 [details]
Patch

Updated the patch to add m_sentScrollDelta to keep track of scroll delta in flight.
Comment 15 Adrienne Walker 2011-11-14 10:00:20 PST
Comment on attachment 114963 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=114963&action=review

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:243
> +void CCLayerTreeHostImpl::clearSentScrollDeltas()
> +{
> +    // FIXME: clear scroll deltas other than just the main scroll layer.

I think you could just clear sentScrollDelta in LayerChromium::pushPropertiesTo, and it'd work for all layers.
Comment 16 Hin-Chung Lam 2011-11-14 10:33:55 PST
Created attachment 114980 [details]
Patch
Comment 17 Hin-Chung Lam 2011-11-14 10:36:33 PST
Created attachment 114982 [details]
Patch
Comment 18 Hin-Chung Lam 2011-11-14 10:37:35 PST
Thanks for suggestions! I've updated the patch.
Comment 19 James Robinson 2011-11-14 11:20:48 PST
Comment on attachment 114982 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=114982&action=review

since you are storing both deltas, did you consider not baking the delta into the layer's position in processScrollDeltas()?

> Source/WebCore/platform/graphics/chromium/LayerChromium.h:138
> +    IntSize sentScrollDelta() const { return IntSize(); }

this seems unnecessary, who uses this?  this value doesn't make any sense on LayerChromium

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:343
> +    m_scrollLayerImpl->setSentScrollDelta(m_scrollLayerImpl->sentScrollDelta() + m_scrollLayerImpl->scrollDelta());

adding in the current sent scroll delta doesn't make sense, it should always be 0 here since we only have 0 or 1 BFACs pending at any given point in time. this should be just

m_scrollLayerImpl->setSentScrollDelta(m_scrollLayerImpl->scrollDelta())
Comment 20 Hin-Chung Lam 2011-11-14 12:32:49 PST
Created attachment 115007 [details]
Patch
Comment 21 Hin-Chung Lam 2011-11-14 12:34:22 PST
Comment on attachment 114982 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=114982&action=review

>> Source/WebCore/platform/graphics/chromium/LayerChromium.h:138
>> +    IntSize sentScrollDelta() const { return IntSize(); }
> 
> this seems unnecessary, who uses this?  this value doesn't make any sense on LayerChromium

This is going to be used in CCLayerTreeHostCommon in the template function to calculate layer transforms. I removed this to avoid confusion.

>> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:343
>> +    m_scrollLayerImpl->setSentScrollDelta(m_scrollLayerImpl->sentScrollDelta() + m_scrollLayerImpl->scrollDelta());
> 
> adding in the current sent scroll delta doesn't make sense, it should always be 0 here since we only have 0 or 1 BFACs pending at any given point in time. this should be just
> 
> m_scrollLayerImpl->setSentScrollDelta(m_scrollLayerImpl->scrollDelta())

Fixed this.
Comment 22 James Robinson 2011-11-14 13:14:45 PST
Comment on attachment 115007 [details]
Patch

Looks good.

For the common code, I think it'd make more sense to have these details hidden in the getter on the CCLayerImpl side rather than having the common code need to be aware of every bit of information. For example, we could add a getter for 'the current position including all of your local scroll stuff' that is trivial on the LayerChromium impl and adds in all the appropriate values on the CCLayerImpl side
Comment 23 Hin-Chung Lam 2011-11-14 13:18:45 PST
(In reply to comment #22)
> (From update of attachment 115007 [details])
> Looks good.
> 
> For the common code, I think it'd make more sense to have these details hidden in the getter on the CCLayerImpl side rather than having the common code need to be aware of every bit of information. For example, we could add a getter for 'the current position including all of your local scroll stuff' that is trivial on the LayerChromium impl and adds in all the appropriate values on the CCLayerImpl side

Sorry I missed one of your comments about hiding these scrollDelta and other information from common code. The idea of having a function that covers these information sounds good to me. I'll do that in a separate patch.
Comment 24 Hin-Chung Lam 2011-11-15 02:52:37 PST
Comment on attachment 115007 [details]
Patch

Clearing flags on attachment: 115007

Committed r100258: <http://trac.webkit.org/changeset/100258>
Comment 25 Hin-Chung Lam 2011-11-15 02:52:45 PST
All reviewed patches have been landed.  Closing bug.