Bug 139543 - Regression(r176212): Carousel on mbusa.com is choppy
Summary: Regression(r176212): Carousel on mbusa.com is choppy
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P1 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-12-11 10:08 PST by Chris Dumez
Modified: 2015-01-06 09:57 PST (History)
11 users (show)

See Also:


Attachments
Patch (15.95 KB, patch)
2014-12-11 12:17 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (11.21 KB, patch)
2014-12-11 13:25 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (14.57 KB, patch)
2014-12-12 10:14 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (18.10 KB, patch)
2014-12-13 20:11 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-12-11 10:08:12 PST
Carousel on mbusa.com is choppy due to a DOM Timer being throttled when it shouldn't.

radar: <rdar://problem/19209406>.
Comment 1 Chris Dumez 2014-12-11 12:17:19 PST
Created attachment 243137 [details]
Patch
Comment 2 Chris Dumez 2014-12-11 13:25:56 PST
Created attachment 243143 [details]
Patch
Comment 3 Chris Dumez 2014-12-11 13:51:10 PST
Comment on attachment 243143 [details]
Patch

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

> Source/WebCore/rendering/RenderElement.cpp:1338
> +        accountForSelfPaintingDescendantsOverflow(child, repaintRect);

We can probably optimize further by not traversing the descendants if hasOverflowClip() return true?
Comment 4 Chris Dumez 2014-12-12 10:14:17 PST
Created attachment 243203 [details]
Patch
Comment 5 Chris Dumez 2014-12-12 10:15:59 PST
Comment on attachment 243203 [details]
Patch

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

> Source/WebCore/rendering/RenderElement.cpp:1341
> +    if (renderer.hasOverflowClip())

We now stop traversing descendants if the renderer clips its overflow to avoid unnecessary work. I also added a layout test to make sure we still throttle if the overflow is hidden.
Comment 6 Chris Dumez 2014-12-12 10:55:53 PST
Simon, what do you think?
Comment 7 Simon Fraser (smfr) 2014-12-12 11:01:39 PST
Comment on attachment 243203 [details]
Patch

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

> Source/WebCore/rendering/RenderElement.cpp:1348
> +    for (auto& child : childrenOfType<RenderLayerModelObject>(renderer)) {
> +        if (child.hasSelfPaintingLayer())
> +            repaintRect.unite(child.absoluteClippedOverflowRect());
> +        accountForSelfPaintingDescendantsOverflow(child, repaintRect);
> +    }

This seems very costly for deep trees with no overflow. You're also doing a tree walk where you do a mapping back to the root (under child.absoluteClippedOverflowRect()) for each node, so this is potentially O(N^2).
Comment 8 Chris Dumez 2014-12-12 12:12:09 PST
(In reply to comment #7)
> Comment on attachment 243203 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=243203&action=review
> 
> > Source/WebCore/rendering/RenderElement.cpp:1348
> > +    for (auto& child : childrenOfType<RenderLayerModelObject>(renderer)) {
> > +        if (child.hasSelfPaintingLayer())
> > +            repaintRect.unite(child.absoluteClippedOverflowRect());
> > +        accountForSelfPaintingDescendantsOverflow(child, repaintRect);
> > +    }
> 
> This seems very costly for deep trees with no overflow. You're also doing a
> tree walk where you do a mapping back to the root (under
> child.absoluteClippedOverflowRect()) for each node, so this is potentially
> O(N^2).

As per our offline discussion. I will re-upload a patch that is very conservative and does not attempt to compute the overflow rect if:
- The element does not have its own layer
- Any descendant has its own layer

Both checks are very cheap and it will still cover the cases I am interested in.

I will also prepare another patch to only throttle timers that change a few CSS properties we know won't cause other elements to relayout (and will cause the element to have its own layer), namely left/opacity.
Comment 9 Chris Dumez 2014-12-13 20:11:13 PST
Created attachment 243262 [details]
Patch
Comment 10 Chris Dumez 2014-12-16 14:32:15 PST
Simon, is the latest iteration acceptable?
Comment 11 Chris Dumez 2015-01-06 08:12:38 PST
ping review?
Comment 12 WebKit Commit Bot 2015-01-06 09:57:53 PST
Comment on attachment 243262 [details]
Patch

Clearing flags on attachment: 243262

Committed r177964: <http://trac.webkit.org/changeset/177964>
Comment 13 WebKit Commit Bot 2015-01-06 09:57:58 PST
All reviewed patches have been landed.  Closing bug.