Title: [293003] branches/safari-613-branch
Revision
293003
Author
[email protected]
Date
2022-04-18 17:50:29 -0700 (Mon, 18 Apr 2022)

Log Message

Cherry-pick r292858. rdar://problem/90699078

    [web-animations] REGRESSION(r291527): assertion hit during teardown of document with CSS Animations
    https://bugs.webkit.org/show_bug.cgi?id=239291
    rdar://90699078

    Reviewed by Dean Jackson.

    Source/WebCore:

    When a CSS Animation is not considered to be relevant anymore, it is removed from both AnimationTimeline::m_animations
    and Styleable::animations(). However, if that animation becomes relevant again, it will be added back to the associated
    effect stack as well as AnimationTimeline::m_animations but not to Styleable::animations().

    This causes a problem because when eventually that CSS Animation's target is removed from the tree, such as during
    document teardown, Styleable::cancelDeclarativeAnimations() will be called an iterate over Styleable::animations()
    to find declarative animations to cancel. Since the CSS animation was not added to Styleable::animations(), it will
    not be canceled and the associated effect will not be removed from the effect stack.

    Later in Styleable::cancelDeclarativeAnimations(), the list of associated CSS Animation names is cleared.

    If during that teardown an animation resolution is performed, such as within a "beforeunload" event listener as
    shown in the new test, we will get into a state where there are effects left in the effect stack of the element
    being torn down but no associated CSS Animation names and we will hit the RELEASE_ASSERT_NOT_REACHED() at the
    end of compareCSSAnimations().

    To fix this, we simply ensure that we add animations back to Styleable::animations() within
    AnimationTimeline::animationTimingDidChange() the same way we add the animations back to
    AnimationTimeline::m_animations.

    Test: webanimations/css-animation-resolution-during-teardown.html

    * animation/AnimationTimeline.cpp:
    (WebCore::AnimationTimeline::animationTimingDidChange):

    LayoutTests:

    Add a new test that would have asserted prior to the source change.

    * webanimations/css-animation-resolution-during-teardown-expected.txt: Added.
    * webanimations/css-animation-resolution-during-teardown.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/ChangeLog (293002 => 293003)


--- branches/safari-613-branch/LayoutTests/ChangeLog	2022-04-19 00:50:25 UTC (rev 293002)
+++ branches/safari-613-branch/LayoutTests/ChangeLog	2022-04-19 00:50:29 UTC (rev 293003)
@@ -1,5 +1,64 @@
 2022-04-18  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r292858. rdar://problem/90699078
+
+    [web-animations] REGRESSION(r291527): assertion hit during teardown of document with CSS Animations
+    https://bugs.webkit.org/show_bug.cgi?id=239291
+    rdar://90699078
+    
+    Reviewed by Dean Jackson.
+    
+    Source/WebCore:
+    
+    When a CSS Animation is not considered to be relevant anymore, it is removed from both AnimationTimeline::m_animations
+    and Styleable::animations(). However, if that animation becomes relevant again, it will be added back to the associated
+    effect stack as well as AnimationTimeline::m_animations but not to Styleable::animations().
+    
+    This causes a problem because when eventually that CSS Animation's target is removed from the tree, such as during
+    document teardown, Styleable::cancelDeclarativeAnimations() will be called an iterate over Styleable::animations()
+    to find declarative animations to cancel. Since the CSS animation was not added to Styleable::animations(), it will
+    not be canceled and the associated effect will not be removed from the effect stack.
+    
+    Later in Styleable::cancelDeclarativeAnimations(), the list of associated CSS Animation names is cleared.
+    
+    If during that teardown an animation resolution is performed, such as within a "beforeunload" event listener as
+    shown in the new test, we will get into a state where there are effects left in the effect stack of the element
+    being torn down but no associated CSS Animation names and we will hit the RELEASE_ASSERT_NOT_REACHED() at the
+    end of compareCSSAnimations().
+    
+    To fix this, we simply ensure that we add animations back to Styleable::animations() within
+    AnimationTimeline::animationTimingDidChange() the same way we add the animations back to
+    AnimationTimeline::m_animations.
+    
+    Test: webanimations/css-animation-resolution-during-teardown.html
+    
+    * animation/AnimationTimeline.cpp:
+    (WebCore::AnimationTimeline::animationTimingDidChange):
+    
+    LayoutTests:
+    
+    Add a new test that would have asserted prior to the source change.
+    
+    * webanimations/css-animation-resolution-during-teardown-expected.txt: Added.
+    * webanimations/css-animation-resolution-during-teardown.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-04-13  Antoine Quint  <[email protected]>
+
+            [web-animations] REGRESSION(r291527): assertion hit during teardown of document with CSS Animations
+            https://bugs.webkit.org/show_bug.cgi?id=239291
+            rdar://90699078
+
+            Reviewed by Dean Jackson.
+
+            Add a new test that would have asserted prior to the source change.
+
+            * webanimations/css-animation-resolution-during-teardown-expected.txt: Added.
+            * webanimations/css-animation-resolution-during-teardown.html: Added.
+
+2022-04-18  Kocsen Chung  <[email protected]>
+
         Cherry-pick r292522. rdar://problem/91130503
 
     NBSP characters drawn in fonts that don't support the space character turn into boxes

Added: branches/safari-613-branch/LayoutTests/webanimations/css-animation-resolution-during-teardown-expected.txt (0 => 293003)


--- branches/safari-613-branch/LayoutTests/webanimations/css-animation-resolution-during-teardown-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/webanimations/css-animation-resolution-during-teardown-expected.txt	2022-04-19 00:50:29 UTC (rev 293003)
@@ -0,0 +1 @@
+PASS

Added: branches/safari-613-branch/LayoutTests/webanimations/css-animation-resolution-during-teardown.html (0 => 293003)


--- branches/safari-613-branch/LayoutTests/webanimations/css-animation-resolution-during-teardown.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/webanimations/css-animation-resolution-during-teardown.html	2022-04-19 00:50:29 UTC (rev 293003)
@@ -0,0 +1,41 @@
+<style>
+  @keyframes a0 {
+  }
+  div, span {
+    animation-name: a0;
+  }
+  slot {
+    animation-name: a0, a0;
+  }
+</style>
+<script>
+  window.testRunner?.dumpAsText();
+  window.testRunner?.waitUntilDone();
+
+  _onload_ = () => {
+    document.body.append(document.createElement('input'));
+    document.body.append(document.createElement('slot'));
+    let br0 = document.createElement('br');
+    document.body.append(br0);
+    let div0 = document.createElement('div');
+    br0.append(div0);
+    document.body.offsetTop;
+    document.body.append(document.createElement('input'));
+    div0.append(document.createElement('span'));
+    document.execCommand('SelectAll');
+    _onbeforeunload_ = () => {
+      document.styleSheets[0].insertRule(`slot { animation-delay: 25ms; }`);
+      document.designMode = 'on';
+      document.execCommand('Bold');
+    };
+
+    requestAnimationFrame(() => {
+        if (!window.location.search)
+            window.location.href = "" + "?foo=1";
+        else {
+            document.body.textContent = "PASS";
+            window.testRunner?.notifyDone();
+        }
+    });
+  };
+</script>

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (293002 => 293003)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-04-19 00:50:25 UTC (rev 293002)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-04-19 00:50:29 UTC (rev 293003)
@@ -1,5 +1,84 @@
 2022-04-18  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r292858. rdar://problem/90699078
+
+    [web-animations] REGRESSION(r291527): assertion hit during teardown of document with CSS Animations
+    https://bugs.webkit.org/show_bug.cgi?id=239291
+    rdar://90699078
+    
+    Reviewed by Dean Jackson.
+    
+    Source/WebCore:
+    
+    When a CSS Animation is not considered to be relevant anymore, it is removed from both AnimationTimeline::m_animations
+    and Styleable::animations(). However, if that animation becomes relevant again, it will be added back to the associated
+    effect stack as well as AnimationTimeline::m_animations but not to Styleable::animations().
+    
+    This causes a problem because when eventually that CSS Animation's target is removed from the tree, such as during
+    document teardown, Styleable::cancelDeclarativeAnimations() will be called an iterate over Styleable::animations()
+    to find declarative animations to cancel. Since the CSS animation was not added to Styleable::animations(), it will
+    not be canceled and the associated effect will not be removed from the effect stack.
+    
+    Later in Styleable::cancelDeclarativeAnimations(), the list of associated CSS Animation names is cleared.
+    
+    If during that teardown an animation resolution is performed, such as within a "beforeunload" event listener as
+    shown in the new test, we will get into a state where there are effects left in the effect stack of the element
+    being torn down but no associated CSS Animation names and we will hit the RELEASE_ASSERT_NOT_REACHED() at the
+    end of compareCSSAnimations().
+    
+    To fix this, we simply ensure that we add animations back to Styleable::animations() within
+    AnimationTimeline::animationTimingDidChange() the same way we add the animations back to
+    AnimationTimeline::m_animations.
+    
+    Test: webanimations/css-animation-resolution-during-teardown.html
+    
+    * animation/AnimationTimeline.cpp:
+    (WebCore::AnimationTimeline::animationTimingDidChange):
+    
+    LayoutTests:
+    
+    Add a new test that would have asserted prior to the source change.
+    
+    * webanimations/css-animation-resolution-during-teardown-expected.txt: Added.
+    * webanimations/css-animation-resolution-during-teardown.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-04-13  Antoine Quint  <[email protected]>
+
+            [web-animations] REGRESSION(r291527): assertion hit during teardown of document with CSS Animations
+            https://bugs.webkit.org/show_bug.cgi?id=239291
+            rdar://90699078
+
+            Reviewed by Dean Jackson.
+
+            When a CSS Animation is not considered to be relevant anymore, it is removed from both AnimationTimeline::m_animations
+            and Styleable::animations(). However, if that animation becomes relevant again, it will be added back to the associated
+            effect stack as well as AnimationTimeline::m_animations but not to Styleable::animations().
+
+            This causes a problem because when eventually that CSS Animation's target is removed from the tree, such as during
+            document teardown, Styleable::cancelDeclarativeAnimations() will be called an iterate over Styleable::animations()
+            to find declarative animations to cancel. Since the CSS animation was not added to Styleable::animations(), it will
+            not be canceled and the associated effect will not be removed from the effect stack.
+
+            Later in Styleable::cancelDeclarativeAnimations(), the list of associated CSS Animation names is cleared.
+
+            If during that teardown an animation resolution is performed, such as within a "beforeunload" event listener as
+            shown in the new test, we will get into a state where there are effects left in the effect stack of the element
+            being torn down but no associated CSS Animation names and we will hit the RELEASE_ASSERT_NOT_REACHED() at the
+            end of compareCSSAnimations().
+
+            To fix this, we simply ensure that we add animations back to Styleable::animations() within
+            AnimationTimeline::animationTimingDidChange() the same way we add the animations back to
+            AnimationTimeline::m_animations.
+
+            Test: webanimations/css-animation-resolution-during-teardown.html
+
+            * animation/AnimationTimeline.cpp:
+            (WebCore::AnimationTimeline::animationTimingDidChange):
+
+2022-04-18  Kocsen Chung  <[email protected]>
+
         Cherry-pick r292779. rdar://problem/89750945
 
     RejectedPromiseTracker can be recreated if we are in a worker / worklet whose execution is terminating

Modified: branches/safari-613-branch/Source/WebCore/animation/AnimationTimeline.cpp (293002 => 293003)


--- branches/safari-613-branch/Source/WebCore/animation/AnimationTimeline.cpp	2022-04-19 00:50:25 UTC (rev 293002)
+++ branches/safari-613-branch/Source/WebCore/animation/AnimationTimeline.cpp	2022-04-19 00:50:29 UTC (rev 293003)
@@ -52,6 +52,10 @@
         auto* timeline = animation.timeline();
         if (timeline && timeline != this)
             timeline->removeAnimation(animation);
+        else if (timeline == this && is<KeyframeEffect>(animation.effect())) {
+            if (auto styleable = downcast<KeyframeEffect>(animation.effect())->targetStyleable())
+                styleable->animationWasAdded(animation);
+        }
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to