[Web Animations] Starting a transform animation with a 1ms delay doesn't run it accel...
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Feb 2022 13:57:38 +0000 (13:57 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Feb 2022 13:57:38 +0000 (13:57 +0000)
commit3cce06c3c2dabe5b977fd846ef8ee589c3817eff
tree8d59a24721e79dd3614bc08d4b1780dfc58ea51a
parent2039437cf681ac646d4eb9505de5b5bd273045c4
[Web Animations] Starting a transform animation with a 1ms delay doesn't run it accelerated
https://bugs.webkit.org/show_bug.cgi?id=236080
<rdar://problem/88432373>

Reviewed by Dean Jackson.

Source/WebCore:

Accelerated animations can only be started if the keyframe effect's renderer is composited.
Keyframe effects enqueue a list of accelerated actions (play, pause, seek, stop, etc.) when
they can be accelerated, and these actions are performed in sync as the document timeline
is finishing up its "update animations and send events" procedure as we update the page
rendering.

When an animation is started _without_ a delay, the machinery to consider making a renderer
composited happens _before_ we update animations and send events, and since at this stage the
new animation's effect is already in its target's effect stack because it is immediately
"relevant" (per the Web Animations terminology) and targets a property that can be accelerated,
its renderer is indeed composited.

Thus by the time we consider starting this animation's effect with acceleration, it is in a
condition to do so since its renderer is already composited.

However, when an animation is started _with_ a delay, it is not immediately "relevant" and thus
won't appear in its target's effect stack. That will happen once we run the "update animations
and send events procedure" the next time we update the page rendering. But before that, the
effect's renderer will be considered to be made composited and _will not_ be because at this
point there is no effect animating a property that can be accelerated.

As we eventually run the "update animations and send events" procedure, we'll enqueue an
accelerated action to play the animation now that it became relevant, and when that procedure
completes and we try to apply that accelerated action, we'll fail to start an accelerated
animation since the renderer is not composited.

To address this, we only enqueue accelerated actions when the renderer is composited, thus
matching the condition to actually be able to apply this action.

This means we no longer need the animationDidPlay() on effects since we wouldn't be able to
honor enqueuing a "play" accelerated action since the renderer won't be composited yet at this
time in the vast majority of cases.

Test: webanimations/transform-animation-with-delay-yields-accelerated-animation.html

* animation/AnimationEffect.h:
(WebCore::AnimationEffect::animationDidTick):
(WebCore::AnimationEffect::animationDidPlay): Deleted.
* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::updateAcceleratedActions):
(WebCore::KeyframeEffect::animationDidPlay): Deleted.
* animation/KeyframeEffect.h:
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::play):

* animation/AnimationEffect.h:
(WebCore::AnimationEffect::animationDidTick):
(WebCore::AnimationEffect::animationDidPlay): Deleted.
* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::updateAcceleratedActions):
(WebCore::KeyframeEffect::animationDidPlay): Deleted.
* animation/KeyframeEffect.h:
(WebCore::KeyframeEffect::isAboutToRunAccelerated const):
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::play):

LayoutTests:

Add a test that runs a "transform" animation with a small delay and checks that it yielded
an accelerated animation. We also rewrite some existing tests to use internals.acceleratedAnimationsForElement()
since relying on a layer tree dump was not reliable, which also resolves some platform-specific
issues.

* platform/glib/TestExpectations:
* platform/gtk/webanimations/partly-accelerated-transition-by-removing-property-expected.txt: Removed.
* platform/mac-wk1/webanimations/partly-accelerated-transition-by-removing-property-expected.txt: Removed.
* platform/win/TestExpectations:
* webanimations/accelerated-css-transition-with-easing-y-axis-above-1.html: Make sure overflow doesn't cause an image failure.
* webanimations/partly-accelerated-transition-by-removing-property-expected.txt:
* webanimations/partly-accelerated-transition-by-removing-property.html: Rewrite test to check on the accelerated
animation count and ensure the element is already composited to make the test work on WK1 and GTK.
* webanimations/resources/request-frames-until-true.js: Added.
(const.requestFramesUntilTrue.async resolveCondition):
* webanimations/transform-animation-with-delay-yields-accelerated-animation-expected.txt: Added.
* webanimations/transform-animation-with-delay-yields-accelerated-animation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289211 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/glib/TestExpectations
LayoutTests/platform/gtk/webanimations/partly-accelerated-transition-by-removing-property-expected.txt [deleted file]
LayoutTests/platform/mac-wk1/webanimations/partly-accelerated-transition-by-removing-property-expected.txt [deleted file]
LayoutTests/platform/win/TestExpectations
LayoutTests/webanimations/accelerated-css-transition-with-easing-y-axis-above-1.html
LayoutTests/webanimations/partly-accelerated-transition-by-removing-property-expected.txt
LayoutTests/webanimations/partly-accelerated-transition-by-removing-property.html
LayoutTests/webanimations/resources/request-frames-until-true.js [new file with mode: 0644]
LayoutTests/webanimations/transform-animation-with-delay-yields-accelerated-animation-expected.txt [new file with mode: 0644]
LayoutTests/webanimations/transform-animation-with-delay-yields-accelerated-animation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/animation/AnimationEffect.h
Source/WebCore/animation/KeyframeEffect.cpp
Source/WebCore/animation/KeyframeEffect.h
Source/WebCore/animation/WebAnimation.cpp