Title: [231794] trunk
Revision
231794
Author
[email protected]
Date
2018-05-15 01:59:53 -0700 (Tue, 15 May 2018)

Log Message

animation-play-state: paused causes very high cpu load because of style invalidation loop
https://bugs.webkit.org/show_bug.cgi?id=182436
<rdar://problem/37182562>

Reviewed by Dean Jackson.

Source/WebCore:

Test: animations/animation-playstate-paused-style-resolution.html

If the style of an element with 'animation-play-state: paused' is recomputed so it stays
paused we would enter zero-duration animation timer loop.

* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::updateStateMachine):

Don't move to AnimationState::PausedWaitResponse unless we get AnimationStateInput::StyleAvailable
(matching the comments). Otherwise just stay in the existing paused state.

Remove AnimationStateInput::StartAnimation from assertion as the case can't happen.

LayoutTests:

* animations/animation-playstate-paused-style-resolution-expected.txt: Added.
* animations/animation-playstate-paused-style-resolution.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231793 => 231794)


--- trunk/LayoutTests/ChangeLog	2018-05-15 08:07:02 UTC (rev 231793)
+++ trunk/LayoutTests/ChangeLog	2018-05-15 08:59:53 UTC (rev 231794)
@@ -1,3 +1,14 @@
+2018-05-15  Antti Koivisto  <[email protected]>
+
+        animation-play-state: paused causes very high cpu load because of style invalidation loop
+        https://bugs.webkit.org/show_bug.cgi?id=182436
+        <rdar://problem/37182562>
+
+        Reviewed by Dean Jackson.
+
+        * animations/animation-playstate-paused-style-resolution-expected.txt: Added.
+        * animations/animation-playstate-paused-style-resolution.html: Added.
+
 2018-05-14  Youenn Fablet  <[email protected]>
 
         readableStreamDefaultControllerError should return early if stream is not readable

Added: trunk/LayoutTests/animations/animation-playstate-paused-style-resolution-expected.txt (0 => 231794)


--- trunk/LayoutTests/animations/animation-playstate-paused-style-resolution-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/animations/animation-playstate-paused-style-resolution-expected.txt	2018-05-15 08:59:53 UTC (rev 231794)
@@ -0,0 +1,2 @@
+Paused animation
+style recalc count: 1

Added: trunk/LayoutTests/animations/animation-playstate-paused-style-resolution.html (0 => 231794)


--- trunk/LayoutTests/animations/animation-playstate-paused-style-resolution.html	                        (rev 0)
+++ trunk/LayoutTests/animations/animation-playstate-paused-style-resolution.html	2018-05-15 08:59:53 UTC (rev 231794)
@@ -0,0 +1,37 @@
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+</script>
+<style>
+.anim {
+    animation-duration: 20s;
+    animation-name: slidein;
+    animation-play-state: paused;
+}
+@keyframes slidein {
+    from { margin-left: 50%; width: 300%; }
+    to { margin-left: 0%; width: 100%; }
+}
+</style>
+<div class=anim>
+Paused animation
+</div>
+<div id=log></div>
+<script>
+document.body.offsetLeft;
+if (window.testRunner) {
+    internals.startTrackingStyleRecalcs();
+    setTimeout(() => {
+        document.body.offsetLeft;
+        log.innerHTML = "style recalc count: " + internals.styleRecalcCount();
+        testRunner.notifyDone();
+    }, 50);
+}
+</script>
+<style>
+.anim {
+    color: green;
+}
+</style>

Modified: trunk/Source/WebCore/ChangeLog (231793 => 231794)


--- trunk/Source/WebCore/ChangeLog	2018-05-15 08:07:02 UTC (rev 231793)
+++ trunk/Source/WebCore/ChangeLog	2018-05-15 08:59:53 UTC (rev 231794)
@@ -1,3 +1,24 @@
+2018-05-15  Antti Koivisto  <[email protected]>
+
+        animation-play-state: paused causes very high cpu load because of style invalidation loop
+        https://bugs.webkit.org/show_bug.cgi?id=182436
+        <rdar://problem/37182562>
+
+        Reviewed by Dean Jackson.
+
+        Test: animations/animation-playstate-paused-style-resolution.html
+
+        If the style of an element with 'animation-play-state: paused' is recomputed so it stays
+        paused we would enter zero-duration animation timer loop.
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::updateStateMachine):
+
+        Don't move to AnimationState::PausedWaitResponse unless we get AnimationStateInput::StyleAvailable
+        (matching the comments). Otherwise just stay in the existing paused state.
+
+        Remove AnimationStateInput::StartAnimation from assertion as the case can't happen.
+
 2018-05-14  Youenn Fablet  <[email protected]>
 
         readableStreamDefaultControllerError should return early if stream is not readable

Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (231793 => 231794)


--- trunk/Source/WebCore/page/animation/AnimationBase.cpp	2018-05-15 08:07:02 UTC (rev 231793)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp	2018-05-15 08:59:53 UTC (rev 231794)
@@ -395,7 +395,7 @@
             // AnimationState::PausedWaitResponse, we don't yet have a valid startTime, so we send 0 to startAnimation.
             // When the AnimationStateInput::StartTimeSet comes in and we were in AnimationState::PausedRun, we will notice
             // that we have already set the startTime and will ignore it.
-            ASSERT(input == AnimationStateInput::PlayStatePaused || input == AnimationStateInput::PlayStateRunning || input == AnimationStateInput::StartTimeSet || input == AnimationStateInput::StyleAvailable || input == AnimationStateInput::StartAnimation);
+            ASSERT(input == AnimationStateInput::PlayStatePaused || input == AnimationStateInput::PlayStateRunning || input == AnimationStateInput::StartTimeSet || input == AnimationStateInput::StyleAvailable);
             ASSERT(paused());
 
             if (input == AnimationStateInput::PlayStateRunning) {
@@ -456,6 +456,12 @@
             }
 
             ASSERT(m_animationState == AnimationState::PausedNew || m_animationState == AnimationState::PausedWaitStyleAvailable);
+
+            if (input == AnimationStateInput::PlayStatePaused)
+                break;
+
+            ASSERT(input == AnimationStateInput::StyleAvailable);
+
             // We are paused but we got the callback that notifies us that style has been updated.
             // We move to the AnimationState::PausedWaitResponse state
             LOG(Animations, "%p AnimationState %s -> PausedWaitResponse", this, nameForState(m_animationState));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to