Title: [256365] branches/safari-609.1.17.1-branch
Revision
256365
Author
alanc...@apple.com
Date
2020-02-11 14:03:12 -0800 (Tue, 11 Feb 2020)

Log Message

Cherry-pick r255663. rdar://problem/59349185

    Accelerated animations freeze on render tree rebuild
    https://bugs.webkit.org/show_bug.cgi?id=201048
    <rdar://problem/54612621>

    Reviewed by Antoine Quint.

    Source/WebCore:

    If there is an accelerated animation in progress for a renderer and the render tree is rebuild the animation
    does not continue with the new renderer.

    To fix, make sure that the animation leaves the accelerated state when the renderer is removed. The new renderer
    will then become accelerated automatically.

    Original test case by Tim Guan-tin Chien.

    Test: webanimations/accelerated-animation-renderer-change.html

    * animation/AnimationTimeline.cpp:
    (WebCore::AnimationTimeline::willChangeRendererForElement):
    * animation/AnimationTimeline.h:
    * animation/KeyframeEffect.cpp:
    (WebCore::KeyframeEffect::willChangeRenderer):
    * animation/KeyframeEffect.h:
    * animation/WebAnimation.cpp:
    (WebCore::WebAnimation::willChangeRenderer):
    * animation/WebAnimation.h:
    * rendering/updating/RenderTreeUpdater.cpp:
    (WebCore::RenderTreeUpdater::tearDownRenderers):

    LayoutTests:

    * webanimations/accelerated-animation-renderer-change-expected.html: Added.
    * webanimations/accelerated-animation-renderer-change.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255663 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-609.1.17.1-branch/LayoutTests/ChangeLog (256364 => 256365)


--- branches/safari-609.1.17.1-branch/LayoutTests/ChangeLog	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/LayoutTests/ChangeLog	2020-02-11 22:03:12 UTC (rev 256365)
@@ -1,5 +1,58 @@
 2020-02-11  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r255663. rdar://problem/59349185
+
+    Accelerated animations freeze on render tree rebuild
+    https://bugs.webkit.org/show_bug.cgi?id=201048
+    <rdar://problem/54612621>
+    
+    Reviewed by Antoine Quint.
+    
+    Source/WebCore:
+    
+    If there is an accelerated animation in progress for a renderer and the render tree is rebuild the animation
+    does not continue with the new renderer.
+    
+    To fix, make sure that the animation leaves the accelerated state when the renderer is removed. The new renderer
+    will then become accelerated automatically.
+    
+    Original test case by Tim Guan-tin Chien.
+    
+    Test: webanimations/accelerated-animation-renderer-change.html
+    
+    * animation/AnimationTimeline.cpp:
+    (WebCore::AnimationTimeline::willChangeRendererForElement):
+    * animation/AnimationTimeline.h:
+    * animation/KeyframeEffect.cpp:
+    (WebCore::KeyframeEffect::willChangeRenderer):
+    * animation/KeyframeEffect.h:
+    * animation/WebAnimation.cpp:
+    (WebCore::WebAnimation::willChangeRenderer):
+    * animation/WebAnimation.h:
+    * rendering/updating/RenderTreeUpdater.cpp:
+    (WebCore::RenderTreeUpdater::tearDownRenderers):
+    
+    LayoutTests:
+    
+    * webanimations/accelerated-animation-renderer-change-expected.html: Added.
+    * webanimations/accelerated-animation-renderer-change.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-02-03  Antti Koivisto  <an...@apple.com>
+
+            Accelerated animations freeze on render tree rebuild
+            https://bugs.webkit.org/show_bug.cgi?id=201048
+            <rdar://problem/54612621>
+
+            Reviewed by Antoine Quint.
+
+            * webanimations/accelerated-animation-renderer-change-expected.html: Added.
+            * webanimations/accelerated-animation-renderer-change.html: Added.
+
+2020-02-11  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r255593. rdar://problem/59349198
 
     [Web Animations] Accelerated animations don't run until their natural completion

Added: branches/safari-609.1.17.1-branch/LayoutTests/webanimations/accelerated-animation-renderer-change-expected.html (0 => 256365)


--- branches/safari-609.1.17.1-branch/LayoutTests/webanimations/accelerated-animation-renderer-change-expected.html	                        (rev 0)
+++ branches/safari-609.1.17.1-branch/LayoutTests/webanimations/accelerated-animation-renderer-change-expected.html	2020-02-11 22:03:12 UTC (rev 256365)
@@ -0,0 +1,15 @@
+<style>
+div {
+    background-color: rebeccapurple;
+    width: 100px;
+    height: 100px;
+}
+
+#test{
+    position: absolute;
+    top: 200px;
+    left: 200px;
+}
+
+</style>
+<div id=test></div>

Added: branches/safari-609.1.17.1-branch/LayoutTests/webanimations/accelerated-animation-renderer-change.html (0 => 256365)


--- branches/safari-609.1.17.1-branch/LayoutTests/webanimations/accelerated-animation-renderer-change.html	                        (rev 0)
+++ branches/safari-609.1.17.1-branch/LayoutTests/webanimations/accelerated-animation-renderer-change.html	2020-02-11 22:03:12 UTC (rev 256365)
@@ -0,0 +1,67 @@
+<style>
+
+div {
+    background-color: rebeccapurple;
+    width: 100px;
+    height: 100px;
+}
+
+#test{
+    position: absolute;
+    top: 200px;
+    left: 200px;
+}
+
+.animate-class {
+    animation: 1s linear 0s 1 normal scale;
+}
+
+.first-letter::first-letter {
+    color:red;
+}
+
+@keyframes scale {
+    0% {
+        transform: scale(0);
+    }
+
+    10% {
+        transform: scale(1);
+    }
+
+    100% {
+        transform: scale(1);
+    }
+}
+
+</style>
+<script>
+
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+window._onload_ = async function() {
+    const element = document.body.appendChild(document.createElement("div"));
+    element.className = "animate-class";
+    element.id = "test";
+
+    const animation = element.getAnimations()[0];
+
+    await animation.ready;
+
+    await new Promise(resolve => requestAnimationFrame(resolve));
+    await new Promise(resolve => requestAnimationFrame(resolve));
+
+    // Force render tree rebuild in the middle of the animation.
+    document.body.classList.add("first-letter");
+
+    // See that the accelerated animation still progresses.
+    while (animation.currentTime < 100)
+        await new Promise(resolve => requestAnimationFrame(resolve));
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+</script>
+

Modified: branches/safari-609.1.17.1-branch/Source/WebCore/ChangeLog (256364 => 256365)


--- branches/safari-609.1.17.1-branch/Source/WebCore/ChangeLog	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/Source/WebCore/ChangeLog	2020-02-11 22:03:12 UTC (rev 256365)
@@ -1,5 +1,77 @@
 2020-02-11  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r255663. rdar://problem/59349185
+
+    Accelerated animations freeze on render tree rebuild
+    https://bugs.webkit.org/show_bug.cgi?id=201048
+    <rdar://problem/54612621>
+    
+    Reviewed by Antoine Quint.
+    
+    Source/WebCore:
+    
+    If there is an accelerated animation in progress for a renderer and the render tree is rebuild the animation
+    does not continue with the new renderer.
+    
+    To fix, make sure that the animation leaves the accelerated state when the renderer is removed. The new renderer
+    will then become accelerated automatically.
+    
+    Original test case by Tim Guan-tin Chien.
+    
+    Test: webanimations/accelerated-animation-renderer-change.html
+    
+    * animation/AnimationTimeline.cpp:
+    (WebCore::AnimationTimeline::willChangeRendererForElement):
+    * animation/AnimationTimeline.h:
+    * animation/KeyframeEffect.cpp:
+    (WebCore::KeyframeEffect::willChangeRenderer):
+    * animation/KeyframeEffect.h:
+    * animation/WebAnimation.cpp:
+    (WebCore::WebAnimation::willChangeRenderer):
+    * animation/WebAnimation.h:
+    * rendering/updating/RenderTreeUpdater.cpp:
+    (WebCore::RenderTreeUpdater::tearDownRenderers):
+    
+    LayoutTests:
+    
+    * webanimations/accelerated-animation-renderer-change-expected.html: Added.
+    * webanimations/accelerated-animation-renderer-change.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-02-03  Antti Koivisto  <an...@apple.com>
+
+            Accelerated animations freeze on render tree rebuild
+            https://bugs.webkit.org/show_bug.cgi?id=201048
+            <rdar://problem/54612621>
+
+            Reviewed by Antoine Quint.
+
+            If there is an accelerated animation in progress for a renderer and the render tree is rebuild the animation
+            does not continue with the new renderer.
+
+            To fix, make sure that the animation leaves the accelerated state when the renderer is removed. The new renderer
+            will then become accelerated automatically.
+
+            Original test case by Tim Guan-tin Chien.
+
+            Test: webanimations/accelerated-animation-renderer-change.html
+
+            * animation/AnimationTimeline.cpp:
+            (WebCore::AnimationTimeline::willChangeRendererForElement):
+            * animation/AnimationTimeline.h:
+            * animation/KeyframeEffect.cpp:
+            (WebCore::KeyframeEffect::willChangeRenderer):
+            * animation/KeyframeEffect.h:
+            * animation/WebAnimation.cpp:
+            (WebCore::WebAnimation::willChangeRenderer):
+            * animation/WebAnimation.h:
+            * rendering/updating/RenderTreeUpdater.cpp:
+            (WebCore::RenderTreeUpdater::tearDownRenderers):
+
+2020-02-11  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r255593. rdar://problem/59349198
 
     [Web Animations] Accelerated animations don't run until their natural completion

Modified: branches/safari-609.1.17.1-branch/Source/WebCore/animation/AnimationTimeline.cpp (256364 => 256365)


--- branches/safari-609.1.17.1-branch/Source/WebCore/animation/AnimationTimeline.cpp	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/Source/WebCore/animation/AnimationTimeline.cpp	2020-02-11 22:03:12 UTC (rev 256365)
@@ -241,6 +241,12 @@
         animation->remove();
 }
 
+void AnimationTimeline::willChangeRendererForElement(Element& element)
+{
+    for (auto& animation : animationsForElement(element))
+        animation->willChangeRenderer();
+}
+
 void AnimationTimeline::cancelDeclarativeAnimationsForElement(Element& element)
 {
     for (auto& cssTransition : m_elementToCSSTransitionsMap.get(&element))

Modified: branches/safari-609.1.17.1-branch/Source/WebCore/animation/AnimationTimeline.h (256364 => 256365)


--- branches/safari-609.1.17.1-branch/Source/WebCore/animation/AnimationTimeline.h	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/Source/WebCore/animation/AnimationTimeline.h	2020-02-11 22:03:12 UTC (rev 256365)
@@ -61,6 +61,7 @@
     Vector<RefPtr<WebAnimation>> animationsForElement(Element&, Ordering ordering = Ordering::Unsorted) const;
     void elementWasRemoved(Element&);
     void removeAnimationsForElement(Element&);
+    void willChangeRendererForElement(Element&);
     void cancelDeclarativeAnimationsForElement(Element&);
     virtual void animationWasAddedToElement(WebAnimation&, Element&);
     virtual void animationWasRemovedFromElement(WebAnimation&, Element&);

Modified: branches/safari-609.1.17.1-branch/Source/WebCore/animation/KeyframeEffect.cpp (256364 => 256365)


--- branches/safari-609.1.17.1-branch/Source/WebCore/animation/KeyframeEffect.cpp	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/Source/WebCore/animation/KeyframeEffect.cpp	2020-02-11 22:03:12 UTC (rev 256365)
@@ -1392,6 +1392,12 @@
         addPendingAcceleratedAction(AcceleratedAction::Stop);
 }
 
+void KeyframeEffect::willChangeRenderer()
+{
+    if (m_isRunningAccelerated)
+        addPendingAcceleratedAction(AcceleratedAction::Stop);
+}
+
 void KeyframeEffect::animationSuspensionStateDidChange(bool animationIsSuspended)
 {
     if (m_isRunningAccelerated)

Modified: branches/safari-609.1.17.1-branch/Source/WebCore/animation/KeyframeEffect.h (256364 => 256365)


--- branches/safari-609.1.17.1-branch/Source/WebCore/animation/KeyframeEffect.h	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/Source/WebCore/animation/KeyframeEffect.h	2020-02-11 22:03:12 UTC (rev 256365)
@@ -122,6 +122,8 @@
     void animationTimingDidChange();
     void applyPendingAcceleratedActions();
 
+    void willChangeRenderer();
+
     void setAnimation(WebAnimation*) final;
 
     RenderElement* renderer() const override;

Modified: branches/safari-609.1.17.1-branch/Source/WebCore/animation/WebAnimation.cpp (256364 => 256365)


--- branches/safari-609.1.17.1-branch/Source/WebCore/animation/WebAnimation.cpp	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/Source/WebCore/animation/WebAnimation.cpp	2020-02-11 22:03:12 UTC (rev 256365)
@@ -667,6 +667,12 @@
         m_effect->animationWasCanceled();
 }
 
+void WebAnimation::willChangeRenderer()
+{
+    if (is<KeyframeEffect>(m_effect))
+        downcast<KeyframeEffect>(*m_effect).willChangeRenderer();
+}
+
 void WebAnimation::enqueueAnimationPlaybackEvent(const AtomString& type, Optional<Seconds> currentTime, Optional<Seconds> timelineTime)
 {
     auto event = AnimationPlaybackEvent::create(type, currentTime, timelineTime);

Modified: branches/safari-609.1.17.1-branch/Source/WebCore/animation/WebAnimation.h (256364 => 256365)


--- branches/safari-609.1.17.1-branch/Source/WebCore/animation/WebAnimation.h	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/Source/WebCore/animation/WebAnimation.h	2020-02-11 22:03:12 UTC (rev 256365)
@@ -123,6 +123,7 @@
     void effectTargetDidChange(Element* previousTarget, Element* newTarget);
     void acceleratedStateDidChange();
     void applyPendingAcceleratedActions();
+    void willChangeRenderer();
 
     bool isRunningAccelerated() const;
     bool isCompletelyAccelerated() const;

Modified: branches/safari-609.1.17.1-branch/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp (256364 => 256365)


--- branches/safari-609.1.17.1-branch/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp	2020-02-11 22:03:08 UTC (rev 256364)
+++ branches/safari-609.1.17.1-branch/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp	2020-02-11 22:03:12 UTC (rev 256365)
@@ -560,7 +560,9 @@
         while (teardownStack.size() > depth) {
             auto& element = *teardownStack.takeLast();
 
-            if (teardownType == TeardownType::Full || teardownType == TeardownType::RendererUpdateCancelingAnimations) {
+            switch (teardownType) {
+            case TeardownType::Full:
+            case TeardownType::RendererUpdateCancelingAnimations:
                 if (timeline) {
                     if (document.renderTreeBeingDestroyed())
                         timeline->elementWasRemoved(element);
@@ -568,6 +570,11 @@
                         timeline->cancelDeclarativeAnimationsForElement(element);
                 }
                 animationController.cancelAnimations(element);
+                break;
+            case TeardownType::RendererUpdate:
+                if (timeline)
+                    timeline->willChangeRendererForElement(element);
+                break;
             }
 
             if (teardownType == TeardownType::Full)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to