Bug 78186

Summary: Avoid compositing out-of-view fixed positioned elements
Product: WebKit Reporter: Xianzhu Wang <wangxianzhu>
Component: Layout and RenderingAssignee: Xianzhu Wang <wangxianzhu>
Status: RESOLVED FIXED    
Severity: Normal CC: jamesr, klobag, simon.fraser, vangelis, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch for preview (missing test)
none
patch with layout test none

Description Xianzhu Wang 2012-02-08 17:26:20 PST
Like in http://techcrunch.com, a out-of-viewport fixed positioned element with negative z-index makes the whole page composited, even the element is never visible, causing unnecessary layer compositings.

Should check if the fixed element is visible when determining if it should be composited. This avoids the problem of excessive repaints which still needs to be investigated and resolved.

Experiments on chromium-linux showed that with the checking, the number of layers of http://techcrunch.com reduced from about 100 to 0. Experiments on chromium-android showed the number of layers reduced from 31 (including 3 fullscreen layers) to only 5~6. (http://techcrunch.com returns different pages for chromium-linux and chromium-android)
Comment 1 Xianzhu Wang 2012-02-08 17:34:12 PST
Created attachment 126202 [details]
patch for preview (missing test)
Comment 2 James Robinson 2012-02-08 20:05:07 PST
Comment on attachment 126202 [details]
patch for preview (missing test)

This is a nice find.  For testing, I'd recommend use the layerTreeAsText() hook to make sure that we aren't making GraphicsLayers that we don't need to.
Comment 3 Xianzhu Wang 2012-02-09 18:09:01 PST
Created attachment 126418 [details]
patch with layout test
Comment 4 James Robinson 2012-02-09 18:12:02 PST
Comment on attachment 126418 [details]
patch with layout test

Great! R=me
Comment 5 WebKit Review Bot 2012-02-09 22:35:10 PST
Comment on attachment 126418 [details]
patch with layout test

Clearing flags on attachment: 126418

Committed r107364: <http://trac.webkit.org/changeset/107364>
Comment 6 WebKit Review Bot 2012-02-09 22:35:14 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Xianzhu Wang 2012-02-17 15:35:11 PST
Changed title to be more accurate.
Comment 8 Simon Fraser (smfr) 2012-12-16 15:04:31 PST
There's a problem with this strategy, when combined with zooming;when zoomed in, we may consider a fixed element to be outside the viewport, and not composite it. However, zooming may bring that element back into the viewport, but if it doesn't have a layer yet, it won't be visible while zooming.
Comment 9 Xianzhu Wang 2012-12-17 12:10:33 PST
(In reply to comment #8)
> There's a problem with this strategy, when combined with zooming;when zoomed in, we may consider a fixed element to be outside the viewport, and not composite it. However, zooming may bring that element back into the viewport, but if it doesn't have a layer yet, it won't be visible while zooming.

Thanks for the finding. Filed bug 105202.