Title: [253728] trunk
Revision
253728
Author
[email protected]
Date
2019-12-18 16:30:46 -0800 (Wed, 18 Dec 2019)

Log Message

Animations stop if new tab opened (and closed)
https://bugs.webkit.org/show_bug.cgi?id=202360
<rdar://problem/55923261>

Patch by Antoine Quint <[email protected]> on 2019-12-18
Reviewed by Dean Jackson.

Source/WebCore:

In the case where we would have a fill-forwards software animation when an animation that could be
accelerated started, we would fail to start an accelerated animation because we had no composited
renderer. However, we would still advertise a state of "running accelerated" and the DocumentTimeline
would not schedule ticks to run the animation in software.

We now only schedule accelerated animations once their delay phase is over and the animation is in its
"active" phase, which helps to only schedule accelerated animations once they actually have an effect
that is worth accelerating, and reset pending accelerated actions in case we try to start an accelerated
animation but fail to because we don't have a composited renderer.

Test: webanimations/animation-of-accelerated-property-after-non-accelerated-property.html

* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::apply):
(WebCore::KeyframeEffect::updateAcceleratedAnimationState):
(WebCore::KeyframeEffect::applyPendingAcceleratedActions):
* animation/KeyframeEffect.h:

LayoutTests:

Add a ref test that checks that an element with a software animation followed by an animation of a property
that can be accelerated yields animations in both cases.

Also, somehow, the WPT test dom/events/Event-dispatch-on-disabled-elements.html seems to now pass an extra
test that would fail on iOS and now behaves like macOS, so we remove that platform-specific expectation.

* platform/ios/imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements-expected.txt
* webanimations/animation-of-accelerated-property-after-non-accelerated-property-expected.html: Added.
* webanimations/animation-of-accelerated-property-after-non-accelerated-property.html: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253727 => 253728)


--- trunk/LayoutTests/ChangeLog	2019-12-18 23:57:14 UTC (rev 253727)
+++ trunk/LayoutTests/ChangeLog	2019-12-19 00:30:46 UTC (rev 253728)
@@ -1,3 +1,21 @@
+2019-12-18  Antoine Quint  <[email protected]>
+
+        Animations stop if new tab opened (and closed)
+        https://bugs.webkit.org/show_bug.cgi?id=202360
+        <rdar://problem/55923261>
+
+        Reviewed by Dean Jackson.
+
+        Add a ref test that checks that an element with a software animation followed by an animation of a property
+        that can be accelerated yields animations in both cases. 
+
+        Also, somehow, the WPT test dom/events/Event-dispatch-on-disabled-elements.html seems to now pass an extra
+        test that would fail on iOS and now behaves like macOS, so we remove that platform-specific expectation.
+
+        * platform/ios/imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements-expected.txt
+        * webanimations/animation-of-accelerated-property-after-non-accelerated-property-expected.html: Added.
+        * webanimations/animation-of-accelerated-property-after-non-accelerated-property.html: Added.
+
 2019-12-18  Yury Semikhatsky  <[email protected]>
 
         Web Inspector: Runtime.enable reports duplicates (non existent) contexts

Deleted: trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements-expected.txt (253727 => 253728)


--- trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements-expected.txt	2019-12-18 23:57:14 UTC (rev 253727)
+++ trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements-expected.txt	2019-12-19 00:30:46 UTC (rev 253728)
@@ -1,12 +0,0 @@
- 
-
-PASS Can dispatch untrusted 'click' Events at disabled HTML elements. 
-PASS Can dispatch untrusted Events at disabled HTML elements. 
-PASS Can dispatch CustomEvents at disabled HTML elements. 
-PASS Calling click() on disabled elements must not dispatch events. 
-PASS CSS Transitions transitionrun, transitionstart, transitionend events fire on disabled form elements 
-PASS CSS Transitions transitioncancel event fires on disabled form elements 
-PASS CSS Animation animationstart, animationiteration, animationend fire on disabled form elements 
-PASS CSS Animation's animationcancel event fires on disabled form elements 
-FAIL Real clicks on disabled elements must not dispatch events. assert_true: HTMLSelectElement is enabled, so onclick must fire. expected true got false
-

Added: trunk/LayoutTests/webanimations/animation-of-accelerated-property-after-non-accelerated-property-expected.html (0 => 253728)


--- trunk/LayoutTests/webanimations/animation-of-accelerated-property-after-non-accelerated-property-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/animation-of-accelerated-property-after-non-accelerated-property-expected.html	2019-12-19 00:30:46 UTC (rev 253728)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body style="background-color: white">
+</body>
+</html>

Added: trunk/LayoutTests/webanimations/animation-of-accelerated-property-after-non-accelerated-property.html (0 => 253728)


--- trunk/LayoutTests/webanimations/animation-of-accelerated-property-after-non-accelerated-property.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/animation-of-accelerated-property-after-non-accelerated-property.html	2019-12-19 00:30:46 UTC (rev 253728)
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+
+#target {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100px;
+    height: 100px;
+    background-color: black;
+    animation: anim1 50ms forwards, anim2 5s 50ms;
+}
+
+@keyframes anim1 {
+    0%, 100% { background-color: red; }
+    50% { background-color: orange; }
+}
+
+@keyframes anim2 {
+    0% { transform: translateX(0) }
+    5%, 100% { transform: translateX(500px) }
+}
+
+body {
+    background-color: white;
+}
+
+#cache > div {
+    position: absolute;
+    background-color: white;
+}
+
+#cache > div:nth-of-type(1) {
+    top: 0;
+    left: 100px;
+    right: 0;
+    height: 100%;
+}
+
+#cache > div:nth-of-type(2) {
+    top: 100px;
+    left: 0;
+    bottom: 0;
+    width: 100%;
+}
+
+</style>
+</head>
+<body>
+<div id="target"></div>
+<div id="cache">
+    <div></div>
+    <div></div>
+</div>
+<script>
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    document.getElementById("target").addEventListener("animationstart", event => {
+        if (event.animationName == "anim2")
+            setTimeout(() => testRunner.notifyDone(), 100);
+    });
+}
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (253727 => 253728)


--- trunk/Source/WebCore/ChangeLog	2019-12-18 23:57:14 UTC (rev 253727)
+++ trunk/Source/WebCore/ChangeLog	2019-12-19 00:30:46 UTC (rev 253728)
@@ -1,3 +1,29 @@
+2019-12-18  Antoine Quint  <[email protected]>
+
+        Animations stop if new tab opened (and closed)
+        https://bugs.webkit.org/show_bug.cgi?id=202360
+        <rdar://problem/55923261>
+
+        Reviewed by Dean Jackson.
+
+        In the case where we would have a fill-forwards software animation when an animation that could be
+        accelerated started, we would fail to start an accelerated animation because we had no composited
+        renderer. However, we would still advertise a state of "running accelerated" and the DocumentTimeline
+        would not schedule ticks to run the animation in software.
+
+        We now only schedule accelerated animations once their delay phase is over and the animation is in its
+        "active" phase, which helps to only schedule accelerated animations once they actually have an effect
+        that is worth accelerating, and reset pending accelerated actions in case we try to start an accelerated
+        animation but fail to because we don't have a composited renderer.
+
+        Test: webanimations/animation-of-accelerated-property-after-non-accelerated-property.html
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::apply):
+        (WebCore::KeyframeEffect::updateAcceleratedAnimationState):
+        (WebCore::KeyframeEffect::applyPendingAcceleratedActions):
+        * animation/KeyframeEffect.h:
+
 2019-12-18  Eric Carlson  <[email protected]>
 
         Remove more unused MediaPlayer methods

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (253727 => 253728)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2019-12-18 23:57:14 UTC (rev 253727)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2019-12-19 00:30:46 UTC (rev 253728)
@@ -1080,10 +1080,10 @@
 
     updateBlendingKeyframes(targetStyle);
 
-    updateAcceleratedAnimationState();
-
     auto computedTiming = getComputedTiming();
 
+    updateAcceleratedAnimationState(computedTiming);
+
     InspectorInstrumentation::willApplyKeyframeEffect(*m_target, *this, computedTiming);
 
     if (!computedTiming.progress)
@@ -1307,7 +1307,7 @@
     return nullptr;
 }
 
-void KeyframeEffect::updateAcceleratedAnimationState()
+void KeyframeEffect::updateAcceleratedAnimationState(ComputedEffectTiming computedTiming)
 {
     if (!m_shouldRunAccelerated)
         return;
@@ -1343,7 +1343,7 @@
         return;
     }
 
-    if (playState == WebAnimation::PlayState::Running && localTime >= 0_s) {
+    if (playState == WebAnimation::PlayState::Running && computedTiming.phase == AnimationEffectPhase::Active) {
         if (m_lastRecordedAcceleratedAction != AcceleratedAction::Play)
             addPendingAcceleratedAction(AcceleratedAction::Play);
         return;
@@ -1393,18 +1393,21 @@
     if (m_pendingAcceleratedActions.isEmpty())
         return;
 
+    // In the case where we have a composited renderer, we'll be applying all pending accelerated actions.
+    // In case we don't have a composited renderer, then we won't be able to apply the pending accelerated
+    // actions. In both cases, we can clear the pending accelerated actions.
+    auto pendingAcceleratedActions = m_pendingAcceleratedActions;
+    m_pendingAcceleratedActions.clear();
+
     auto* renderer = this->renderer();
     if (!renderer || !renderer->isComposited()) {
-        // The renderer may no longer be composited because the accelerated animation ended before we had a chance to update it,
-        // in which case if we asked for the animation to stop, we can discard the current set of accelerated actions.
-        if (m_lastRecordedAcceleratedAction == AcceleratedAction::Stop)
-            m_pendingAcceleratedActions.clear();
+        // If we don't have a composited renderer when we were supposed to be applying an accelerated action other
+        // than to stop a running animation, then we won't manage to apply accelerations in the future either, so
+        // we should reset the flag to run accelerated.
+        m_lastRecordedAcceleratedAction = AcceleratedAction::Stop;
         return;
     }
 
-    auto pendingAcceleratedActions = m_pendingAcceleratedActions;
-    m_pendingAcceleratedActions.clear();
-
     auto* compositedRenderer = downcast<RenderBoxModelObject>(renderer);
 
     // To simplify the code we use a default of 0s for an unresolved current time since for a Stop action that is acceptable.

Modified: trunk/Source/WebCore/animation/KeyframeEffect.h (253727 => 253728)


--- trunk/Source/WebCore/animation/KeyframeEffect.h	2019-12-18 23:57:14 UTC (rev 253727)
+++ trunk/Source/WebCore/animation/KeyframeEffect.h	2019-12-19 00:30:46 UTC (rev 253728)
@@ -152,7 +152,7 @@
     void copyPropertiesFromSource(Ref<KeyframeEffect>&&);
     ExceptionOr<void> processKeyframes(JSC::JSGlobalObject&, JSC::Strong<JSC::JSObject>&&);
     void addPendingAcceleratedAction(AcceleratedAction);
-    void updateAcceleratedAnimationState();
+    void updateAcceleratedAnimationState(ComputedEffectTiming);
     void setAnimatedPropertiesInStyle(RenderStyle&, double);
     TimingFunction* timingFunctionForKeyframeAtIndex(size_t);
     Ref<const Animation> backingAnimationForCompositedRenderer() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to