Title: [269963] trunk
Revision
269963
Author
[email protected]
Date
2020-11-18 09:51:39 -0800 (Wed, 18 Nov 2020)

Log Message

[Web Animations] Ensure we don't schedule animation udpates when there are no styles to update
https://bugs.webkit.org/show_bug.cgi?id=219071

Reviewed by Simon Fraser.

Source/WebCore:

Test: webanimations/scheduling-of-animation-without-keyframes.html

For keyframe effects that don't interpolate any CSS property, run the same logic that we already run
to determine when to schedule the next animation update in the case where we are running accelerated
animations.

* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::timeToNextTick const):

LayoutTests:

Add a test that creates animations with various empty keyframes parameters to check that we don't
schedule animation update for them.

* webanimations/scheduling-of-animation-without-keyframes-expected.txt: Added.
* webanimations/scheduling-of-animation-without-keyframes.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (269962 => 269963)


--- trunk/LayoutTests/ChangeLog	2020-11-18 17:45:21 UTC (rev 269962)
+++ trunk/LayoutTests/ChangeLog	2020-11-18 17:51:39 UTC (rev 269963)
@@ -1,5 +1,18 @@
 2020-11-18  Antoine Quint  <[email protected]>
 
+        [Web Animations] Ensure we don't schedule animation udpates when there are no styles to update
+        https://bugs.webkit.org/show_bug.cgi?id=219071
+
+        Reviewed by Simon Fraser.
+
+        Add a test that creates animations with various empty keyframes parameters to check that we don't
+        schedule animation update for them.
+
+        * webanimations/scheduling-of-animation-without-keyframes-expected.txt: Added.
+        * webanimations/scheduling-of-animation-without-keyframes.html: Added.
+
+2020-11-18  Antoine Quint  <[email protected]>
+
         Support <source> as a child of <model> to specify the current source
         https://bugs.webkit.org/show_bug.cgi?id=219080
 

Added: trunk/LayoutTests/webanimations/scheduling-of-animation-without-keyframes-expected.txt (0 => 269963)


--- trunk/LayoutTests/webanimations/scheduling-of-animation-without-keyframes-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webanimations/scheduling-of-animation-without-keyframes-expected.txt	2020-11-18 17:51:39 UTC (rev 269963)
@@ -0,0 +1,6 @@
+
+PASS Computing the time until the next tick for an effect with null keyframes parameter.
+PASS Computing the time until the next tick for an effect with {} keyframes parameter.
+PASS Computing the time until the next tick for an effect with [] keyframes parameter.
+PASS Computing the time until the next tick for an effect with invalid CSS property keyframes parameter.
+

Added: trunk/LayoutTests/webanimations/scheduling-of-animation-without-keyframes.html (0 => 269963)


--- trunk/LayoutTests/webanimations/scheduling-of-animation-without-keyframes.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/scheduling-of-animation-without-keyframes.html	2020-11-18 17:51:39 UTC (rev 269963)
@@ -0,0 +1,20 @@
+<script src=""
+<script src=""
+<div></div>
+<script>
+
+const noKeyframesTest = (keyframes, label) => {
+    promise_test(async () => {
+        const animation = document.querySelector("div").animate(keyframes, 1000);
+        await animation.ready;
+        animation.currentTime = 100;
+        assert_equals(internals.timeToNextAnimationTick(animation), 900);
+    }, `Computing the time until the next tick for an effect with ${label} keyframes parameter.`);
+}
+
+noKeyframesTest(null, "null");
+noKeyframesTest({}, "{}");
+noKeyframesTest([], "[]");
+noKeyframesTest({ foo: "bar" }, "invalid CSS property");
+
+</script>

Modified: trunk/Source/WebCore/ChangeLog (269962 => 269963)


--- trunk/Source/WebCore/ChangeLog	2020-11-18 17:45:21 UTC (rev 269962)
+++ trunk/Source/WebCore/ChangeLog	2020-11-18 17:51:39 UTC (rev 269963)
@@ -1,5 +1,21 @@
 2020-11-18  Antoine Quint  <[email protected]>
 
+        [Web Animations] Ensure we don't schedule animation udpates when there are no styles to update
+        https://bugs.webkit.org/show_bug.cgi?id=219071
+
+        Reviewed by Simon Fraser.
+
+        Test: webanimations/scheduling-of-animation-without-keyframes.html
+
+        For keyframe effects that don't interpolate any CSS property, run the same logic that we already run
+        to determine when to schedule the next animation update in the case where we are running accelerated
+        animations.
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::timeToNextTick const):
+
+2020-11-18  Antoine Quint  <[email protected]>
+
         Support <source> as a child of <model> to specify the current source
         https://bugs.webkit.org/show_bug.cgi?id=219080
 

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (269962 => 269963)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2020-11-18 17:45:21 UTC (rev 269962)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2020-11-18 17:51:39 UTC (rev 269963)
@@ -1979,14 +1979,18 @@
     case AnimationEffectPhase::Before:
         // The effect is in its "before" phase, in this case we can wait until it enters its "active" phase.
         return delay() - *timing.localTime;
-    case AnimationEffectPhase::Active:
-        if (isCompletelyAccelerated() && isRunningAccelerated()) {
-            // Fully-accelerated running CSS Animations need to trigger "animationiteration" events, in this case we must wait until the next iteration.
+    case AnimationEffectPhase::Active: {
+        auto doesNotAffectStyles = m_blendingKeyframes.isEmpty() || m_blendingKeyframes.properties().isEmpty();
+        auto completelyAcceleratedAndRunning = isCompletelyAccelerated() && isRunningAccelerated();
+        if (doesNotAffectStyles || completelyAcceleratedAndRunning) {
+            // In the case of fully accelerated running effects and effects that don't actually target any CSS property,
+            // we do not have a need to invalidate styles.
             if (is<CSSAnimation>(animation())) {
+                // However, CSS Animations need to trigger "animationiteration" events, in this case we must wait until the next iteration.
                 if (auto iterationProgress = getComputedTiming().simpleIterationProgress)
                     return iterationDuration() * (1 - *iterationProgress);
             }
-            // Fully-accelerated running effects in the "active" phase can wait until they ended.
+            // Other running effects in the "active" phase can wait until they end.
             return endTime() - *timing.localTime;
         }
         if (auto iterationProgress = getComputedTiming().simpleIterationProgress) {
@@ -1996,6 +2000,7 @@
         }
         // Other effects in the "active" phase will need to update their animated value at the immediate next opportunity.
         return 0_s;
+    }
     case AnimationEffectPhase::After:
         // The effect is in its after phase, which means it will no longer update its value, so it doens't need a tick.
         return Seconds::infinity();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to