Title: [255810] trunk
Revision
255810
Author
grao...@webkit.org
Date
2020-02-05 03:51:40 -0800 (Wed, 05 Feb 2020)

Log Message

[Web Animations] Canceling an accelerated animation before it was committed does not prevent it from playing
https://bugs.webkit.org/show_bug.cgi?id=207253
<rdar://problem/59143624>

Reviewed by Antti Koivisto.

Source/WebCore:

Test: webanimations/accelerated-animation-canceled-before-commit.html

Merely checking whether an accelerated animation is running prior to enqueuing an action to cancel it is not sufficient
since there could be an uncommitted change to start it upon the next animation frame. The same logic would need to apply
in other situations where the playback state changes for a potentially in-flight animation.

* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::animationDidSeek):
(WebCore::KeyframeEffect::animationWasCanceled):
(WebCore::KeyframeEffect::willChangeRenderer):
(WebCore::KeyframeEffect::animationSuspensionStateDidChange):

LayoutTests:

Add a new test that checks that an accelerated animation that has been enqueued to start but has
not yet been committed is correctly canceled when the cancel() method is called. This test fails
prior to this source change.

* webanimations/accelerated-animation-canceled-before-commit-expected.html: Added.
* webanimations/accelerated-animation-canceled-before-commit.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (255809 => 255810)


--- trunk/LayoutTests/ChangeLog	2020-02-05 10:55:48 UTC (rev 255809)
+++ trunk/LayoutTests/ChangeLog	2020-02-05 11:51:40 UTC (rev 255810)
@@ -1,3 +1,18 @@
+2020-02-05  Antoine Quint  <grao...@apple.com>
+
+        [Web Animations] Canceling an accelerated animation before it was committed does not prevent it from playing
+        https://bugs.webkit.org/show_bug.cgi?id=207253
+        <rdar://problem/59143624>
+
+        Reviewed by Antti Koivisto.
+
+        Add a new test that checks that an accelerated animation that has been enqueued to start but has
+        not yet been committed is correctly canceled when the cancel() method is called. This test fails
+        prior to this source change.
+
+        * webanimations/accelerated-animation-canceled-before-commit-expected.html: Added.
+        * webanimations/accelerated-animation-canceled-before-commit.html: Added.
+
 2020-02-04  Lauro Moura  <lmo...@igalia.com>
 
         [GTK] Garden some wpt tests failing with harness timeout

Added: trunk/LayoutTests/webanimations/accelerated-animation-canceled-before-commit-expected.html (0 => 255810)


--- trunk/LayoutTests/webanimations/accelerated-animation-canceled-before-commit-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/accelerated-animation-canceled-before-commit-expected.html	2020-02-05 11:51:40 UTC (rev 255810)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+
+#target {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100px;
+    height: 100px;
+    background-color: black;
+}
+
+</style>
+</head>
+<body>
+<div id="target"></div>
+</body>
+</html>

Added: trunk/LayoutTests/webanimations/accelerated-animation-canceled-before-commit.html (0 => 255810)


--- trunk/LayoutTests/webanimations/accelerated-animation-canceled-before-commit.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/accelerated-animation-canceled-before-commit.html	2020-02-05 11:51:40 UTC (rev 255810)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+
+#target {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100px;
+    height: 100px;
+    background-color: black;
+    will-change: transform;
+}
+
+</style>
+</head>
+<body>
+<div id="target"></div>
+<script>
+
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+const animation = document.getElementById("target").animate({ transform: ["translateX(50px)", "translateX(100px)"] }, 1000);
+
+// Wait until the animation is ready which means the action to play an accelerated animation has been enqueued by now, but not commmitted.
+animation.ready.then(() => {
+    // Cancel the animation, this should cancel the uncommitted accelerated animation.
+    animation.cancel();
+    if (window.testRunner)
+        testRunner.notifyDone();
+});
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (255809 => 255810)


--- trunk/Source/WebCore/ChangeLog	2020-02-05 10:55:48 UTC (rev 255809)
+++ trunk/Source/WebCore/ChangeLog	2020-02-05 11:51:40 UTC (rev 255810)
@@ -1,3 +1,23 @@
+2020-02-05  Antoine Quint  <grao...@apple.com>
+
+        [Web Animations] Canceling an accelerated animation before it was committed does not prevent it from playing
+        https://bugs.webkit.org/show_bug.cgi?id=207253
+        <rdar://problem/59143624>
+
+        Reviewed by Antti Koivisto.
+
+        Test: webanimations/accelerated-animation-canceled-before-commit.html
+
+        Merely checking whether an accelerated animation is running prior to enqueuing an action to cancel it is not sufficient
+        since there could be an uncommitted change to start it upon the next animation frame. The same logic would need to apply
+        in other situations where the playback state changes for a potentially in-flight animation. 
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::animationDidSeek):
+        (WebCore::KeyframeEffect::animationWasCanceled):
+        (WebCore::KeyframeEffect::willChangeRenderer):
+        (WebCore::KeyframeEffect::animationSuspensionStateDidChange):
+
 2020-02-05  Philippe Normand  <ph...@igalia.com>
 
         [GStreamer] Client-side video rendering doesn't fallback to internal compositing

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (255809 => 255810)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2020-02-05 10:55:48 UTC (rev 255809)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2020-02-05 11:51:40 UTC (rev 255810)
@@ -1385,25 +1385,25 @@
 {
     // There is no need to seek if we're not playing an animation already. If seeking
     // means we're moving into an active lexicalGlobalObject, we'll pick this up in apply().
-    if (m_isRunningAccelerated)
+    if (m_isRunningAccelerated || isAboutToRunAccelerated())
         addPendingAcceleratedAction(AcceleratedAction::Seek);
 }
 
 void KeyframeEffect::animationWasCanceled()
 {
-    if (m_isRunningAccelerated)
+    if (m_isRunningAccelerated || isAboutToRunAccelerated())
         addPendingAcceleratedAction(AcceleratedAction::Stop);
 }
 
 void KeyframeEffect::willChangeRenderer()
 {
-    if (m_isRunningAccelerated)
+    if (m_isRunningAccelerated || isAboutToRunAccelerated())
         addPendingAcceleratedAction(AcceleratedAction::Stop);
 }
 
 void KeyframeEffect::animationSuspensionStateDidChange(bool animationIsSuspended)
 {
-    if (m_isRunningAccelerated)
+    if (m_isRunningAccelerated || isAboutToRunAccelerated())
         addPendingAcceleratedAction(animationIsSuspended ? AcceleratedAction::Pause : AcceleratedAction::Play);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to