Bug 104950 - Add a setting to enable composited scrolling for frames
Summary: Add a setting to enable composited scrolling for frames
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: Xianzhu Wang
URL:
Keywords:
Depends on: 105546
Blocks: 106262
  Show dependency treegraph
 
Reported: 2012-12-13 14:05 PST by Xianzhu Wang
Modified: 2013-01-07 17:52 PST (History)
14 users (show)

See Also:


Attachments
Patch (7.59 KB, patch)
2012-12-20 14:26 PST, Xianzhu Wang
no flags Details | Formatted Diff | Diff
Manual test case (1.82 KB, text/html)
2013-01-04 15:01 PST, Xianzhu Wang
no flags Details
Patch (8.68 KB, patch)
2013-01-07 15:12 PST, Xianzhu Wang
no flags Details | Formatted Diff | Diff
Patch (8.71 KB, patch)
2013-01-07 16:46 PST, Xianzhu Wang
no flags Details | Formatted Diff | Diff
Patch (8.44 KB, patch)
2013-01-07 17:13 PST, Xianzhu Wang
no flags Details | Formatted Diff | Diff
Patch (8.36 KB, patch)
2013-01-07 17:17 PST, Xianzhu Wang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xianzhu Wang 2012-12-13 14:05:21 PST
When enableAcceleratedCompositingForScrollableFrames, we also need to setScrollable(true) to enable composited scrolling for iframes. Otherwise Chromium compositor will still use the scroll layer of the main page and fall back to slow scrolling path because of the nonFastScrollableRegion (which eventually should not include iframes and overflow:scroll areas) of the main scroll layer. The patch to this bug will only address setScrollable, not nonFastScrollableRegion.
Comment 1 James Robinson 2012-12-13 14:11:20 PST
I don't think our current code supports composited scrolling for iframes or anything other than the root, so the current behavior seems correct.
Comment 2 Xianzhu Wang 2012-12-13 15:38:59 PST
(In reply to comment #1)
> I don't think our current code supports composited scrolling for iframes or anything other than the root, so the current behavior seems correct.

The purpose of this bug is to enable composited scrolling for iframes for better performance. To achieve that we need to fix any blocking issues. Is the solution proposed in Description the right way to go?

Just saw that the patch of bug 97357 just let RenderLayer::usesCompositedScrolling() return true to enable composited scrolling for -webkit-overflow-scrolling:touch. I'm wondering how it works.
Comment 3 Xianzhu Wang 2012-12-13 17:50:23 PST
(In reply to comment #2)
> Just saw that the patch of bug 97357 just let RenderLayer::usesCompositedScrolling() return true to enable composited scrolling for -webkit-overflow-scrolling:touch. I'm wondering how it works.

Never mind. Found updateScrollingLayers in RenderLayerBacking::updateGraphicsLayerConfigurations().
Comment 4 Xianzhu Wang 2012-12-20 14:26:10 PST
Created attachment 180410 [details]
Patch
Comment 5 WebKit Review Bot 2012-12-20 15:31:27 PST
Comment on attachment 180410 [details]
Patch

Attachment 180410 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/15451191

New failing tests:
platform/chromium/virtual/softwarecompositing/iframes/iframe-composited-scrolling.html
compositing/iframes/iframe-composited-scrolling.html
Comment 6 Antonio Gomes 2012-12-20 15:41:53 PST
I plan to enable compositing for inner frames ports that do not use non-force-compositing as well. I do not think it overlaps with this work though.
Comment 7 Build Bot 2012-12-20 22:47:08 PST
Comment on attachment 180410 [details]
Patch

Attachment 180410 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/15458253

New failing tests:
compositing/iframes/iframe-composited-scrolling.html
Comment 8 James Robinson 2013-01-02 14:48:14 PST
I think there's a bit more work to do before we can turn usesCompositedScrolling on for subframes.  For instance from ScrollingCoordinator.cpp:

bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView) const
{
    ASSERT(isMainThread());
    ASSERT(m_page);

    // We currently only handle the main frame.
    if (frameView->frame() != m_page->mainFrame())
        return false;



One consequence is that scrollbar layers don't update properly for subframes.  There are probably other cases as well.
Comment 9 Xianzhu Wang 2013-01-04 14:56:44 PST
(In reply to comment #8)
> I think there's a bit more work to do before we can turn usesCompositedScrolling on for subframes.  For instance from ScrollingCoordinator.cpp:
> 
> bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView) const
> {
>     ASSERT(isMainThread());
>     ASSERT(m_page);
> 
>     // We currently only handle the main frame.
>     if (frameView->frame() != m_page->mainFrame())
>         return false;
> 
> 
> 
> One consequence is that scrollbar layers don't update properly for subframes.  There are probably other cases as well.

I noticed this, while I thought most parts of ScrollingCoordinator were for main frame only and sub-frame scrolling could be handled by the compositor directly given that ScrollingCoordinatorChromium sets the scrollable flag and scrollableArea for the layer. Ran a test (will attach) on chromium-android and it worked well (including the scrollbars and fixed position element in the sub-frame) with the patch. I think this is just like how composited scrolling for overflow:scroll works because the layer tree for a sub-frame is similar to that of an overflow-scroll element. Am I missing anything?

Did a smoke test of enabling ScrollingCoordinator::coordinatesScrollingForFrameView() for sub-frames and it didn't work: no scrolling, no scroll bar and sometimes crashed IN
Comment 10 Xianzhu Wang 2013-01-04 15:01:58 PST
Created attachment 181383 [details]
Manual test case
Comment 11 James Robinson 2013-01-04 15:05:45 PST
(In reply to comment #9)
> (In reply to comment #8)
> > I think there's a bit more work to do before we can turn usesCompositedScrolling on for subframes.  For instance from ScrollingCoordinator.cpp:
> > 
> > bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView) const
> > {
> >     ASSERT(isMainThread());
> >     ASSERT(m_page);
> > 
> >     // We currently only handle the main frame.
> >     if (frameView->frame() != m_page->mainFrame())
> >         return false;
> > 
> > 
> > 
> > One consequence is that scrollbar layers don't update properly for subframes.  There are probably other cases as well.
> 
> I noticed this, while I thought most parts of ScrollingCoordinator were for main frame only and sub-frame scrolling could be handled by the compositor directly given that ScrollingCoordinatorChromium sets the scrollable flag and scrollableArea for the layer. Ran a test (will attach) on chromium-android and it worked well (including the scrollbars and fixed position element in the sub-frame) with the patch. I think this is just like how composited scrolling for overflow:scroll works because the layer tree for a sub-frame is similar to that of an overflow-scroll element. Am I missing anything?
>

As far as I understand, composited scrolling (in the usesCompositedScrolling() sense) for overflow:scroll doesn't work right now either.

With this patch, running on desktop linux with "--enable-threaded-compositing --force-compositing-mode --enable-accelerated-scrollable-frames" on this page http://webstuff.nfshost.com/scrolling/iframe_scrolls.html the iframe's contents scroll on the thread but the scrollbars do not, which looks pretty bad.
 
> Did a smoke test of enabling ScrollingCoordinator::coordinatesScrollingForFrameView() for sub-frames and it didn't work: no scrolling, no scroll bar and sometimes crashed IN

Right.  I imagine there's some amount of work needed to get this working for either the iframe or overflow:scroll case.
Comment 12 James Robinson 2013-01-04 15:06:12 PST
Comment on attachment 180410 [details]
Patch

Doesn't work yet.
Comment 13 Xianzhu Wang 2013-01-04 15:53:09 PST
Is overflow:scroll in the same status (composited scrolling, main-thread scrollbar update)? Actually we have enabled composited scrolling for overflow:scroll in chromium-android dev.
Comment 14 James Robinson 2013-01-04 16:32:34 PST
(In reply to comment #13)
> Is overflow:scroll in the same status (composited scrolling, main-thread scrollbar update)? Actually we have enabled composited scrolling for overflow:scroll in chromium-android dev.

I don't know what the status of scrollbars for overflow:scroll elements on android is, but if they had scrollbars I do not think they would work as expected.  There just isn't any code that would implement that logic.
Comment 15 Sami Kyöstilä 2013-01-07 05:14:40 PST
(In reply to comment #14)
> I don't know what the status of scrollbars for overflow:scroll elements on android is, but if they had scrollbars I do not think they would work as expected.  There just isn't any code that would implement that logic.

Composited overflow:scroll on Android and elsewhere currently uses main-thread scrollbars which have a number of problems (not scrolling on the compositor thread, not fading out, changing size depending on the page scale). I've opened bug 106215.
Comment 16 Xianzhu Wang 2013-01-07 09:24:45 PST
@jamesr, are there issues other than the main-thread scrollbar of enabling composited scrolling for frames? If no, would you agree to enable it just like what we did for overflo:scroll? It is controlled by the switch and might be only enabled on android at first.

In addition, some of the main-thread scrollbar issues seem to also exist without enabling composited scrolling for frames and overflow:scroll, so enabling it seems not to make things worse, while it will make scrolling faster :)
Comment 17 James Robinson 2013-01-07 09:49:25 PST
The cross-platform support isn't in place, so the cross-platform changes in this patch (like FrameView) are definitely wrong and cannot land.  If you want to consider enabling this feature just for chromium-android despite its current bugs, the way to do that would be to add a setting that can be toggled by different ports and platforms.
Comment 18 Xianzhu Wang 2013-01-07 09:59:43 PST
(In reply to comment #17)
> The cross-platform support isn't in place, so the cross-platform changes in this patch (like FrameView) are definitely wrong and cannot land.  If you want to consider enabling this feature just for chromium-android despite its current bugs, the way to do that would be to add a setting that can be toggled by different ports and platforms.

I was thinking acceleratedCompositingForScrollableFrames is the setting. For now it seems to be disabled for all platforms. ForceCompositingMode of a sub-frame will be set to true if and only if the setting is enabled and the frame is scrollable. Do we need another setting?
Comment 19 James Robinson 2013-01-07 10:07:26 PST
(In reply to comment #18)
> (In reply to comment #17)
> > The cross-platform support isn't in place, so the cross-platform changes in this patch (like FrameView) are definitely wrong and cannot land.  If you want to consider enabling this feature just for chromium-android despite its current bugs, the way to do that would be to add a setting that can be toggled by different ports and platforms.
> 
> I was thinking acceleratedCompositingForScrollableFrames is the setting. For now it seems to be disabled for all platforms. ForceCompositingMode of a sub-frame will be set to true if and only if the setting is enabled and the frame is scrollable. Do we need another setting?

That flag controls compositing, not scrolling.
Comment 20 Xianzhu Wang 2013-01-07 10:39:02 PST
(In reply to comment #19)
> (In reply to comment #18)
> > I was thinking acceleratedCompositingForScrollableFrames is the setting. For now it seems to be disabled for all platforms. ForceCompositingMode of a sub-frame will be set to true if and only if the setting is enabled and the frame is scrollable. Do we need another setting?
> 
> That flag controls compositing, not scrolling.

I thought the reason to composite a scrollable frame was for scrolling only, just like that acceleratedCompositingForOverflowScrollEnabled is for composited scrolling of overflow:scroll.

I'd add another setting but am still wondering what the other reasons to composite scrollable (but not non-scrollable) frames are.
Comment 21 James Robinson 2013-01-07 11:26:48 PST
Performance - so you don't have to repaint the full frame every time it scrolls.

If composited scrolling was feature complete then it might make sense to combine the two into one setting, but so long as composited scrolling for frames doesn't fully work it cannot be combined with a feature that does work correctly (compositing iframes that can scroll).
Comment 22 Xianzhu Wang 2013-01-07 15:12:11 PST
Created attachment 181575 [details]
Patch
Comment 23 James Robinson 2013-01-07 16:22:58 PST
Comment on attachment 181575 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        [Chromium] Enable composited scrolling for frames

This touches cross-platform code, so it shouldn't have the [Chromium] tag, and it doesn't enable anything by itself - it adds a setting.

> LayoutTests/platform/chromium/compositing/force-compositing-mode/iframe-composited-scrolling.html:1
> +<html>

add <!DOCTYPE html> before this line so the test doesn't run in quirks mode
Comment 24 Xianzhu Wang 2013-01-07 16:46:25 PST
Created attachment 181598 [details]
Patch
Comment 25 James Robinson 2013-01-07 16:47:56 PST
Comment on attachment 181598 [details]
Patch

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

Move the test to a cross-platform location (if it is indeed cross platform) then r=me.  If it isn't, what's the issue?

> LayoutTests/ChangeLog:11
> +        * platform/chromium/compositing/force-compositing-mode/iframe-composited-scrolling-expected.txt: Added.
> +        * platform/chromium/compositing/force-compositing-mode/iframe-composited-scrolling.html: Added.

this test isn't chromium-specific in any way, is it?
Comment 26 Xianzhu Wang 2013-01-07 16:48:09 PST
Comment on attachment 181575 [details]
Patch

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

>> Source/WebCore/ChangeLog:3
>> +        [Chromium] Enable composited scrolling for frames
> 
> This touches cross-platform code, so it shouldn't have the [Chromium] tag, and it doesn't enable anything by itself - it adds a setting.

Done.

I still put the layout test under platform/chromium because all other force-compositing-mode tests are at here. If necessary, I think we can move them all together out of platform/chromium in a separate bug.

>> LayoutTests/platform/chromium/compositing/force-compositing-mode/iframe-composited-scrolling.html:1
>> +<html>
> 
> add <!DOCTYPE html> before this line so the test doesn't run in quirks mode

Done.
Comment 27 James Robinson 2013-01-07 17:05:37 PST
(In reply to comment #26)
> (From update of attachment 181575 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=181575&action=review
> 
> >> Source/WebCore/ChangeLog:3
> >> +        [Chromium] Enable composited scrolling for frames
> > 
> > This touches cross-platform code, so it shouldn't have the [Chromium] tag, and it doesn't enable anything by itself - it adds a setting.
> 
> Done.
> 
> I still put the layout test under platform/chromium because all other force-compositing-mode tests are at here. If necessary, I think we can move them all together out of platform/chromium in a separate bug.

Those seem wrong as well, then.  No reason to continue the badness.
Comment 28 Xianzhu Wang 2013-01-07 17:13:07 PST
Created attachment 181609 [details]
Patch
Comment 29 James Robinson 2013-01-07 17:14:10 PST
Comment on attachment 181609 [details]
Patch

Still looks good. Want a CQ?
Comment 30 Xianzhu Wang 2013-01-07 17:17:02 PST
(In reply to comment #29)
> (From update of attachment 181609 [details])
> Still looks good. Want a CQ?

There are some tiny issues in ChangeLog (extra chromium/ in the path). Updating. Will CQ by myself when it's uploaded.
Comment 31 Xianzhu Wang 2013-01-07 17:17:37 PST
Created attachment 181610 [details]
Patch
Comment 32 WebKit Review Bot 2013-01-07 17:52:35 PST
Comment on attachment 181610 [details]
Patch

Clearing flags on attachment: 181610

Committed r139024: <http://trac.webkit.org/changeset/139024>
Comment 33 WebKit Review Bot 2013-01-07 17:52:43 PST
All reviewed patches have been landed.  Closing bug.