Bug 109179 - [CoordGfx] Regression from r135212: big layers with transform animations sometime fail to render tiles.
Summary: [CoordGfx] Regression from r135212: big layers with transform animations some...
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: Allan Sandfeld Jensen
URL:
Keywords:
Depends on: 110099
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-07 05:35 PST by Noam Rosenthal
Modified: 2013-02-18 02:29 PST (History)
12 users (show)

See Also:


Attachments
Test case - looks green in chrome, red in CoordGfx-based MiniBrowser (678 bytes, text/html)
2013-02-07 05:35 PST, Noam Rosenthal
no flags Details
Test case (717 bytes, text/html)
2013-02-07 05:40 PST, Noam Rosenthal
no flags Details
Patch (5.45 KB, patch)
2013-02-08 08:34 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (9.49 KB, patch)
2013-02-08 09:11 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (10.10 KB, patch)
2013-02-11 10:04 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (10.15 KB, patch)
2013-02-12 00:51 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (10.81 KB, patch)
2013-02-13 02:40 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (13.77 KB, patch)
2013-02-13 08:33 PST, Allan Sandfeld Jensen
jturcotte: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Noam Rosenthal 2013-02-07 05:35:39 PST
Created attachment 187072 [details]
Test case - looks green in chrome, red in CoordGfx-based MiniBrowser

In https://bugs.webkit.org/show_bug.cgi?id=102313, we added an optimization that allows releasing tiles of transform-animated layers when they are outside the viewport.
This optimization works in some cases; But in slower animations when the layer has more than one tile and nothing else happens during the animation, the new tiles would not be recreated until something triggers a layout/render. This is because the animation works completely in the UI process, and nobody triggers CoordinatedLayerTreeHost to flush layer changes or check for new tiles.

A possible solution would be to periodically compute the visible rect when a transform animation is ongoing.
Comment 1 Kenneth Rohde Christiansen 2013-02-07 05:38:10 PST
I get red in chrome...
Comment 2 Noam Rosenthal 2013-02-07 05:40:54 PST
Created attachment 187075 [details]
Test case

Oops, uploaded wrong attachment.
Comment 3 Allan Sandfeld Jensen 2013-02-08 03:23:00 PST
It turns out we do regularly check for new tiles to create and flush layer changes. Unfortunately this only leads to tiles being dropped and in the end the last tile being created and dropped in an infinite loop. 

Besides the infinite loop thing, the problem seems to be that the visible rect is not updated on the WebProcess side. Or rather it is constantly updated using outdated values.
Comment 4 Allan Sandfeld Jensen 2013-02-08 08:34:30 PST
Created attachment 187326 [details]
Patch
Comment 5 Noam Rosenthal 2013-02-08 08:42:39 PST
Comment on attachment 187326 [details]
Patch

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

Great! But needs an autotest. (pixel-test?)

> Source/WebCore/ChangeLog:11
> +        Force updates of the visible rect while it is animating, and until we have done one last update after
> +        it stops animating.
> +
> +        * platform/graphics/TiledBackingStore.cpp:

Needs an autotest.
Comment 6 Allan Sandfeld Jensen 2013-02-08 09:11:01 PST
Created attachment 187332 [details]
Patch
Comment 7 Build Bot 2013-02-08 10:29:24 PST
Comment on attachment 187332 [details]
Patch

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

New failing tests:
compositing/transitions/transform-on-large-layer.html
Comment 8 WebKit Review Bot 2013-02-09 09:57:00 PST
Comment on attachment 187332 [details]
Patch

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

New failing tests:
compositing/transitions/transform-on-large-layer.html
platform/chromium/virtual/softwarecompositing/transitions/transform-on-large-layer.html
Comment 9 Allan Sandfeld Jensen 2013-02-11 03:46:38 PST
(In reply to comment #7)
> (From update of attachment 187332 [details])
> Attachment 187332 [details] did not pass mac-ews (mac):
> Output: http://queues.webkit.org/results/16435702
> 
> New failing tests:
> compositing/transitions/transform-on-large-layer.html

I guessed it would fail on Chromium since it has a similar issue, but I am surprised it fails on Safari as well. Could just be a hard case to solve, or maybe the baseline I commited is not as generic as I thought.
Comment 10 Allan Sandfeld Jensen 2013-02-11 10:04:41 PST
Created attachment 187605 [details]
Patch
Comment 11 WebKit Review Bot 2013-02-11 11:52:16 PST
Comment on attachment 187605 [details]
Patch

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

New failing tests:
compositing/transitions/transform-on-large-layer.html
platform/chromium/virtual/softwarecompositing/transitions/transform-on-large-layer.html
Comment 12 Dongseong Hwang 2013-02-11 17:27:39 PST
Comment on attachment 187605 [details]
Patch

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

> Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:968
> +    if (!m_shouldUpdateVisibleRect && !m_movingVisibleRect)

Thank you for fixing this bug that I created.

Could you explain why we need new member: m_movingVisibleRect?
currently, flushCompositingStateForThisLayerOnly() calls computeTransformedVisibleRect() every frame. and computeTransformedVisibleRect() is called only from flushCompositingStateForThisLayerOnly().
I don't fully understand how this patch changes behavior. I mean the behavior looks like the same to before to me..
Comment 13 Build Bot 2013-02-11 22:58:42 PST
Comment on attachment 187605 [details]
Patch

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

New failing tests:
compositing/transitions/transform-on-large-layer.html
Comment 14 Allan Sandfeld Jensen 2013-02-12 00:51:22 PST
Created attachment 187801 [details]
Patch

Also resize expectations
Comment 15 Allan Sandfeld Jensen 2013-02-12 00:52:49 PST
(In reply to comment #12)
> (From update of attachment 187605 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=187605&action=review
> 
> > Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:968
> > +    if (!m_shouldUpdateVisibleRect && !m_movingVisibleRect)
> 
> Thank you for fixing this bug that I created.
> 
> Could you explain why we need new member: m_movingVisibleRect?
> currently, flushCompositingStateForThisLayerOnly() calls computeTransformedVisibleRect() every frame. and computeTransformedVisibleRect() is called only from flushCompositingStateForThisLayerOnly().
> I don't fully understand how this patch changes behavior. I mean the behavior looks like the same to before to me..

The difference is that computeTransformedVisibleRect() is also called one last time after the animation stops. Otherwise something that jumps to the end in a single frame would fail to update the visible rect.
Comment 16 Build Bot 2013-02-12 15:13:37 PST
Comment on attachment 187801 [details]
Patch

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

New failing tests:
compositing/transitions/transform-on-large-layer.html
Comment 17 Build Bot 2013-02-12 23:50:11 PST
Comment on attachment 187801 [details]
Patch

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

New failing tests:
compositing/transitions/transform-on-large-layer.html
Comment 18 Allan Sandfeld Jensen 2013-02-13 02:40:35 PST
Created attachment 188042 [details]
Patch
Comment 19 Noam Rosenthal 2013-02-13 05:07:59 PST
Comment on attachment 188042 [details]
Patch

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

> Source/WebCore/platform/graphics/TiledBackingStore.cpp:427
> +            keepRect.unite(coverRect);

Is this the same bug?
Comment 20 Allan Sandfeld Jensen 2013-02-13 05:22:15 PST
(In reply to comment #19)
> (From update of attachment 188042 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=188042&action=review
> 
> > Source/WebCore/platform/graphics/TiledBackingStore.cpp:427
> > +            keepRect.unite(coverRect);
> 
> Is this the same bug?

It is too different changes but they are both needed for animating large layers without dropping tiles.
Comment 21 Dongseong Hwang 2013-02-13 06:15:44 PST
Comment on attachment 188042 [details]
Patch

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

> Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:671
> +    if (!hasActiveTransformAnimation)

(In reply to comment #15)
> The difference is that computeTransformedVisibleRect() is also called one last time after the animation stops. Otherwise something that jumps to the end in a single frame would fail to update the visible rect.

Thank you for explanation. I find '!' in if statement now.

Your approach is quite good, but how about get together all code into computeTransformedVisibleRect()? please see computeTransformedVisibleRect.
If so, other developers don't need to see both flushCompositingStateForThisLayerOnly() and computeTransformedVisibleRect() to understand how this patch fixed the bug.

> Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:967
>  {

how about fix this bug as changing only this method as follows,

void CoordinatedGraphicsLayer::computeTransformedVisibleRect()
{
    bool hasActiveTransformAnimation = selfOrAncestorHasActiveTransformAnimation();
    bool shouldUpdateDueToAnimation = hasActiveTransformAnimation | m_hasActiveTransformAnimationAtPreviousFrame;
    if (!m_shouldUpdateVisibleRect && !shouldUpdateDueToAnimation) {
        m_hasActiveTransformAnimationAtPreviousFrame = hasActiveTransformAnimation;
        return;
    }
    ...
    m_hasActiveTransformAnimationAtPreviousFrame = hasActiveTransformAnimation;
}
Comment 22 Allan Sandfeld Jensen 2013-02-13 08:33:00 PST
Created attachment 188087 [details]
Patch

Fix the adjustForContentRect logic for large AC layers
Comment 23 Noam Rosenthal 2013-02-13 12:42:11 PST
Comment on attachment 188087 [details]
Patch

I'm ok with the AC parts; Can Kenneth or Jocelyn review the TBS parts?
Comment 24 Dongseong Hwang 2013-02-13 17:00:35 PST
Comment on attachment 188087 [details]
Patch

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

> Source/WebCore/platform/graphics/TiledBackingStore.cpp:377
>          rect.inflateX(((pixelsCovered / rect.height()) - rect.width()) / 2);

In TBS part, LGTM.

But I have one question.
Although this inflate code has been in long time, the inflate code is still needed?
If we remove the code, adjustForContentsRect() would be more succinct.
Comment 25 Allan Sandfeld Jensen 2013-02-14 02:18:49 PST
(In reply to comment #24)
> (From update of attachment 188087 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=188087&action=review
> 
> > Source/WebCore/platform/graphics/TiledBackingStore.cpp:377
> >          rect.inflateX(((pixelsCovered / rect.height()) - rect.width()) / 2);
> 
> In TBS part, LGTM.
> 
> But I have one question.
> Although this inflate code has been in long time, the inflate code is still needed?
> If we remove the code, adjustForContentsRect() would be more succinct.

We could do that. I only kept it because it was possible, and I don't want to change unrelated behavior. Keeping it though means that we can better do memory pressure response in the future.
Comment 26 Jocelyn Turcotte 2013-02-15 03:02:27 PST
Comment on attachment 188087 [details]
Patch

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

> Source/WebCore/platform/graphics/TiledBackingStore.cpp:417
> +    // Adjust the content rect.

This should probably say "Adjust the cover rect." or be removed altogether. The code pretty much says the same.
Comment 27 Allan Sandfeld Jensen 2013-02-15 04:12:10 PST
Committed r142979: <http://trac.webkit.org/changeset/142979>
Comment 28 Ryosuke Niwa 2013-02-16 13:32:11 PST
The test added by this patch is failing on all non-GTK+ ports:
http://test-results.appspot.com/dashboards/flakiness_dashboard.html#group=%40ToT%20-%20webkit.org&tests=compositing%2Ftransitions%2Ftransform-on-large-layer.html

Should this test be moved into platform/gtk?
Comment 29 Allan Sandfeld Jensen 2013-02-16 13:36:26 PST
(In reply to comment #28)
> The test added by this patch is failing on all non-GTK+ ports:
> http://test-results.appspot.com/dashboards/flakiness_dashboard.html#group=%40ToT%20-%20webkit.org&tests=compositing%2Ftransitions%2Ftransform-on-large-layer.html
> 
> Should this test be moved into platform/gtk?

No, what would it do there??

It may need a larger timeout or a faster animation though.
Comment 30 Allan Sandfeld Jensen 2013-02-16 13:42:01 PST
(In reply to comment #28)
> The test added by this patch is failing on all non-GTK+ ports:
> http://test-results.appspot.com/dashboards/flakiness_dashboard.html#group=%40ToT%20-%20webkit.org&tests=compositing%2Ftransitions%2Ftransform-on-large-layer.html
> 

Only looks flaky on Mountain Lion WK2, so you may need to mark it flaky for that one, or skip the test completely on Mac.

I also noticed you don't have a Qt WK2 bot in there, which is what I developed the test-case against.