Bug 206280

Summary: Do not detect the stopped animations in Nicosia::Animation to avoid flashback
Product: WebKit Reporter: Tomoki Imai <tomoki.imai>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply, cgarcia, cmarcelo, commit-queue, ews-watchlist, Hironori.Fujii, kondapallykalyan, luiz, magomez, noam, yoshiaki.jitsukawa, zan
Priority: P2    
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
The video shows what we see on morphing-cubes.html
none
patch
none
patch none

Tomoki Imai
Reported 2020-01-15 01:08:26 PST
Created attachment 387759 [details] The video shows what we see on morphing-cubes.html How to reproduce the flashback: - Build webkitgtk with MiniBrowser - Run minibrowser and open https://webkit.org/blog-files/3d-transforms/morphing-cubes.html - Push "Toggle Shape" button several times. We see flashback when the toggling shape animation stops. Confirmed revision: r254528 The flashback was caused by using the old layer transform matrix saved when the animation has been started. The root cause is an inconsistency of animation state in Nicosia::Animation and CoordinatedGraphicsLayer. For Nicosia::Animation, ThreadedCompositor increases MonitonicTime for animation every frame, and calls Nicosia::Animation::apply. For CoordinatedGraphicsLayer, CSSAnimationController updates animations list and if the animation has been finished it updates CSS value. There is a chance to use old layer state while the Nicosia::Animation stopped, but CoordinatedGraphicsLayer still obtains old CSS value and animations.
Attachments
The video shows what we see on morphing-cubes.html (2.41 MB, video/mp4)
2020-01-15 01:08 PST, Tomoki Imai
no flags
patch (7.18 KB, patch)
2020-01-15 01:09 PST, Tomoki Imai
no flags
patch (7.20 KB, patch)
2020-01-15 01:13 PST, Tomoki Imai
no flags
Tomoki Imai
Comment 1 2020-01-15 01:09:25 PST
Created attachment 387761 [details] patch Patch to fix the issue
Tomoki Imai
Comment 2 2020-01-15 01:13:23 PST
Created attachment 387762 [details] patch Added bug URL
Miguel Gomez
Comment 3 2020-01-16 06:45:58 PST
I see what happens here. On a proper execution, CSSAnimationController sets an animation to the CoordinatedGraphicsLayer, which is flushed to the appropriate TextureMapperLayer, and several compositions happen in the compositor until the animation is over. At that point the CSSAnimationController removes the animation from the CoordinatedGraphicsLayer, that's flushed to the TextureMapperLayer and the animation is gone. The problem is that a new composition may happen after the animation is finished on the compositor side, but the CSSAnimationController didn't have time to propagate the removal of the animation to the TextureMapperLayer. In the morphing cubes example this extra composition is probably caused by the other animations running (as the finished one won't request more compositions). This extra composition happens when the animation is over on the compositor side, so the animation transform is not applied and the TextureMapperLayer is painted where it was before the animation, and there's the flashback. The idea of the patch looks good: basically always apply the animation until it's removed by the CSSAnimationController. This causes that even if the animation is over, the TextureMapperLayer will be painted in the last position of the animation until it gets removed, which makes sense. Also, this is not causing extra composition requests, because in order to decide whether there are animations ongoing to request more compositions we check whether there are animations in the playing state and not whether they are active. Keeping the last animation transform until it's removed by CSSAnimationController doesn't seem to cause any visual regression (I tried several tests to check) and it doesn't cause regressions on the layout tests, so it looks good to me.
WebKit Commit Bot
Comment 4 2020-01-16 07:43:28 PST
Comment on attachment 387762 [details] patch Clearing flags on attachment: 387762 Committed r254680: <https://trac.webkit.org/changeset/254680>
WebKit Commit Bot
Comment 5 2020-01-16 07:43:30 PST
All reviewed patches have been landed. Closing bug.
Tomoki Imai
Comment 6 2020-01-16 19:11:20 PST
Thanks for your kind review!
Note You need to log in before you can comment on or make changes to this bug.