Bug 89828 - Optimize RenderGeometryMap mappings gathering
Summary: Optimize RenderGeometryMap mappings gathering
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: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2012-06-24 07:04 PDT by Antti Koivisto
Modified: 2012-07-10 16:54 PDT (History)
3 users (show)

See Also:


Attachments
patch (9.68 KB, patch)
2012-06-24 10:00 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
updated patch (10.49 KB, patch)
2012-06-24 16:57 PDT, Antti Koivisto
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2012-06-24 07:04:39 PDT
RenderGeometryMap currently gathers mappings by climbing the rendering tree. This is slow and can produce large number of mapping steps. In the common case we already have the child layer coordinates available in the layer tree and we can just use that.
Comment 1 Antti Koivisto 2012-06-24 07:18:56 PDT
<rdar://problem/10559009>
Comment 2 Antti Koivisto 2012-06-24 10:00:51 PDT
Created attachment 149194 [details]
patch
Comment 3 WebKit Review Bot 2012-06-24 10:04:16 PDT
Attachment 149194 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
Source/WebCore/rendering/RenderLayer.h:483:  Line contains only semicolon. If this should be an empty statement, use { } instead.  [whitespace/semicolon] [5]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Simon Fraser (smfr) 2012-06-24 14:53:17 PDT
Comment on attachment 149194 [details]
patch

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

> Source/WebCore/rendering/RenderGeometryMap.cpp:182
> +    if (ancestorLayer && layer->canUseConvertToLayerCoords() && renderer->style()->position() != FixedPosition) {

Doesn't this need to check canUseConvertToLayerCoords() on all layers between layer and ancestorLayer? There's no guarantee that ancestorLayer is an immediate ancestor.

> Source/WebCore/rendering/RenderGeometryMap.h:52
> +    // Called by code walking the layer tree.
> +    void pushMappingsToAncestor(const RenderLayer*, const RenderLayer* ancestorLayer);
> +    void popMappingsToAncestor(const RenderLayer*);

I'd like to keep versions that are renderer-based, so we can call them from absoluteRects()/absoluteQuads() at some point (we already know of cases where these are a bottleneck).
Comment 5 Simon Fraser (smfr) 2012-06-24 14:54:32 PDT
Also, I think we should try to wean ourselves off of convertToLayerCoords in the long term, since it would be better to have one way to do coordinate math that always "just works", rather than checking whether it's OK to call it.
Comment 6 Antti Koivisto 2012-06-24 16:13:28 PDT
(In reply to comment #4)
> Doesn't this need to check canUseConvertToLayerCoords() on all layers between layer and ancestorLayer? There's no guarantee that ancestorLayer is an immediate ancestor.

Sounds likely. Can you think of a way to test that case? The patch is logic pretty well tested due to 

    ASSERT(enclosingIntRect(rendererMappedResult) == enclosingIntRect(FloatQuad(result).boundingBox()));

in RenderGeometryMap::absoluteRect() and we don't hit the case in layout tests. 

> I'd like to keep versions that are renderer-based, so we can call them from absoluteRects()/absoluteQuads() at some point (we already know of cases where these are a bottleneck).

We don't usually leave around dead code. It is trivial to add back later. Are you planning to use it soon?
Comment 7 Antti Koivisto 2012-06-24 16:15:18 PDT
(In reply to comment #5)
> Also, I think we should try to wean ourselves off of convertToLayerCoords in the long term, since it would be better to have one way to do coordinate math that always "just works", rather than checking whether it's OK to call it.

Sounds very sensible, this is not nice at all. The new scheme will need some sort of caching though, just walking up the rendering tree is pretty slow.
Comment 8 Antti Koivisto 2012-06-24 16:57:14 PDT
Created attachment 149206 [details]
updated patch

- check that all layers between the current and the ancestor have canUseConvertToLayerCoords().
- put the renderer version of pushMappingsToAncestor back for future use
Comment 9 WebKit Review Bot 2012-06-24 16:59:35 PDT
Attachment 149206 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
Source/WebCore/rendering/RenderLayer.h:483:  Line contains only semicolon. If this should be an empty statement, use { } instead.  [whitespace/semicolon] [5]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Simon Fraser (smfr) 2012-06-24 17:05:21 PDT
Comment on attachment 149206 [details]
updated patch

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

> Source/WebCore/rendering/RenderGeometryMap.cpp:190
> +        canConvertInLayerTree = current->canUseConvertToLayerCoords();

Shouldn't this be &= ?
Comment 11 Antti Koivisto 2012-06-24 17:13:51 PDT
(In reply to comment #10)
> Shouldn't this be &= ?

No need, we bail out from the loop if the variable turns false.
Comment 12 Antti Koivisto 2012-06-24 17:14:50 PDT
http://trac.webkit.org/changeset/121124
Comment 13 Antti Koivisto 2012-06-24 19:17:32 PDT
http://trac.webkit.org/changeset/121130 fixes an assert with fast/block/inline-children-root-linebox-crash.html
Comment 14 Simon Fraser (smfr) 2012-06-30 11:07:19 PDT
This change caused RenderGeometryMap::pushView() to no longer get called. This might have broken compositing overlap testing inside of position:fixed, I'm not sure.
Comment 15 Simon Fraser (smfr) 2012-06-30 11:10:07 PDT
        push(renderer, toLayoutSize(layerOffset), /*accumulatingTransform*/ true, /*isNonUniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false);

accumulatingTransform should also be false; that refers to preserve-3d.
Comment 16 Simon Fraser (smfr) 2012-06-30 11:11:19 PDT
...and I think we need to check for position:fixed on intermediate layers.
Comment 17 Antti Koivisto 2012-06-30 15:11:13 PDT
The assert in absoluteRect should verify that the results are identical to the old code across all our tests. I wonder if those cases don't occur for some reason? Or is the test coverage just weak?
Comment 18 Simon Fraser (smfr) 2012-06-30 15:19:58 PDT
We'd hae to have a test that has compositing layers inside position:fixed, with a scrolled page. We might not. Or maybe the breakage is benign so far (but I'm making some changes that hit it).
Comment 19 Antti Koivisto 2012-06-30 15:58:36 PDT
The top level view will use pushView() due to the ancestorLayer test. I think the problems would be with scrolled subframes. Not sure if canUseConvertToLayerCoords test catches them.
Comment 20 Simon Fraser (smfr) 2012-06-30 15:59:16 PDT
pushView was never hit when using the convertToLayerCoords path.
Comment 21 Antti Koivisto 2012-06-30 16:04:25 PDT
(In reply to comment #20)
> pushView was never hit when using the convertToLayerCoords path.

Correct. The idea is to not take convertToLayerCoords path for the RenderViews.
Comment 22 Simon Fraser (smfr) 2012-06-30 16:16:34 PDT
Yeah. Push the RenderView alone, then push layer offsets from it.
Comment 23 Simon Fraser (smfr) 2012-06-30 16:45:51 PDT
The patch in bug 90342 has some relevant RenderGeometryMap changes (assertions and fixes), but not a fix for the pushView issue.
Comment 24 Simon Fraser (smfr) 2012-07-10 16:54:52 PDT
This caused bug 90919.