haikuwebkit/LayoutTests/animations/steps-transform-rendering-u...

52 lines
1.3 KiB
HTML
Raw Permalink Normal View History

steps() timing function on a transform animation triggers a render every frame https://bugs.webkit.org/show_bug.cgi?id=214712 <rdar://problem/62737868> Reviewed by Tim Horton. Source/WebCore: An animation of transform, with a steps() timing function, would schedule a rendering update on every frame. This happened because KeyframeEffect::updateAcceleratedActions() would keep trying, and failing to start the accelerated animation every frame, since GraphicsLayerCA refuses to run accelerated animations with steps timing functions. Fix by making m_isRunningAccelerated an Optional<>, which gets a value once we've tried to run the animation the first time. Also ensure that we re-try if the timing function changes, via animationDidChangeTimingProperties(). Test: animations/steps-transform-rendering-updates.html * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::isRunningAcceleratedAnimationForProperty const): (WebCore::KeyframeEffect::updateAcceleratedActions): (WebCore::KeyframeEffect::animationDidChangeTimingProperties): (WebCore::KeyframeEffect::animationWasCanceled): (WebCore::KeyframeEffect::willChangeRenderer): (WebCore::KeyframeEffect::animationSuspensionStateDidChange): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): * animation/KeyframeEffect.h: (WebCore::KeyframeEffect::isRunningAccelerated const): * page/Page.cpp: (WebCore::Page::startTrackingRenderingUpdates): (WebCore::Page::renderingUpdateCount const): (WebCore::Page::updateRendering): * page/Page.h: * testing/Internals.cpp: (WebCore::Internals::startTrackingRenderingUpdates): (WebCore::Internals::renderingUpdateCount): * testing/Internals.h: * testing/Internals.idl: LayoutTests: * animations/steps-transform-rendering-updates-expected.txt: Added. * animations/steps-transform-rendering-updates.html: Added. Canonical link: https://commits.webkit.org/227580@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-24 21:03:23 +00:00
<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<style>
#box {
width: 100px;
height: 100px;
background-color: silver;
}
#box.animating {
animation: spinner 0.25s steps(2) 1;
}
@keyframes spinner {
from { transform:rotate(0deg); }
to { transform:rotate(360deg); }
}
</style>
<script>
window.jsTestIsAsync = true;
let count = 0;
window.addEventListener('load', () => {
if (!window.internals) {
finishJSTest();
return;
}
let box = document.getElementById('box');
box.addEventListener('animationstart', () => {
internals.startTrackingRenderingUpdates();
shouldBe('count', '0');
}, false);
box.addEventListener('animationend', () => {
Avoid triggering redundant compositing updates when trying ot run a steps() animation on transform https://bugs.webkit.org/show_bug.cgi?id=215241 <rdar://problem/62737868> Reviewed by Zalan Bujtas. Source/WebCore: With a steps() timing function and keyframes animating the transform property, KeyframeEffect::applyPendingAcceleratedActions() tries to restart the animation every time because the GraphicsLayer reports that it didn't start an accelerated animation. r264856 patched some of this, but we still call animationFinished() every time, and this triggers a compositing update via the m_owningLayer.setNeeds* calls in RenderLayerBacking::animationFinished(). So don't try to remove the animation if wasn't running. This makes those compositing updates a no-op, which is important because these animations still invalidate style on every frame (webkit.org/b/215229). Test: animations/steps-transform-compositing-updates.html * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::applyPendingAcceleratedActions): LayoutTests: animations/steps-transform-rendering-updates.html was landed with a bug; it aliased the global 'count' variable, and was thus testing the wrong thing. So land a failing result for the test for now (webkit.org/b/215229 addresses the fix). * animations/steps-transform-compositing-updates-expected.txt: Copied from LayoutTests/animations/steps-transform-rendering-updates-expected.txt. * animations/steps-transform-compositing-updates.html: Copied from LayoutTests/animations/steps-transform-rendering-updates.html. * animations/steps-transform-rendering-updates-expected.txt: * animations/steps-transform-rendering-updates.html: Canonical link: https://commits.webkit.org/228036@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-07 00:57:45 +00:00
count = internals.renderingUpdateCount();
steps() timing function on a transform animation triggers a render every frame https://bugs.webkit.org/show_bug.cgi?id=214712 <rdar://problem/62737868> Reviewed by Tim Horton. Source/WebCore: An animation of transform, with a steps() timing function, would schedule a rendering update on every frame. This happened because KeyframeEffect::updateAcceleratedActions() would keep trying, and failing to start the accelerated animation every frame, since GraphicsLayerCA refuses to run accelerated animations with steps timing functions. Fix by making m_isRunningAccelerated an Optional<>, which gets a value once we've tried to run the animation the first time. Also ensure that we re-try if the timing function changes, via animationDidChangeTimingProperties(). Test: animations/steps-transform-rendering-updates.html * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::isRunningAcceleratedAnimationForProperty const): (WebCore::KeyframeEffect::updateAcceleratedActions): (WebCore::KeyframeEffect::animationDidChangeTimingProperties): (WebCore::KeyframeEffect::animationWasCanceled): (WebCore::KeyframeEffect::willChangeRenderer): (WebCore::KeyframeEffect::animationSuspensionStateDidChange): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): * animation/KeyframeEffect.h: (WebCore::KeyframeEffect::isRunningAccelerated const): * page/Page.cpp: (WebCore::Page::startTrackingRenderingUpdates): (WebCore::Page::renderingUpdateCount const): (WebCore::Page::updateRendering): * page/Page.h: * testing/Internals.cpp: (WebCore::Internals::startTrackingRenderingUpdates): (WebCore::Internals::renderingUpdateCount): * testing/Internals.h: * testing/Internals.idl: LayoutTests: * animations/steps-transform-rendering-updates-expected.txt: Added. * animations/steps-transform-rendering-updates.html: Added. Canonical link: https://commits.webkit.org/227580@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-24 21:03:23 +00:00
shouldBeTrue('count < 6');
finishJSTest();
}, false);
box.classList.add('animating');
}, false);
</script>
</head>
<body>
<div id="box"></div>
<div id="console"></div>
<script src="../resources/js-test-post.js"></script>
</body>
</html>