Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d88f62b700cb0df20a27ebbec498ba3b30ad4aee
https://github.com/WebKit/WebKit/commit/d88f62b700cb0df20a27ebbec498ba3b30ad4aee
Author: Antoine Quint <[email protected]>
Date: 2025-11-05 (Wed, 05 Nov 2025)
Changed paths:
M
LayoutTests/webanimations/threaded-animations/scroll-driven-animations-expected.txt
M
LayoutTests/webanimations/threaded-animations/scroll-driven-animations.html
M Source/WebCore/animation/DocumentTimeline.cpp
M Source/WebCore/animation/DocumentTimeline.h
M Source/WebCore/animation/KeyframeEffect.cpp
M Source/WebCore/animation/WebAnimation.cpp
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
M Source/WebCore/page/Page.cpp
Log Message:
-----------
[threaded-animations] add support for JS-originated animations associated
with progress-based timelines
https://bugs.webkit.org/show_bug.cgi?id=302000
rdar://164077999
Reviewed by Simon Fraser.
In 302580@main we added support for CSS Animations associated with
progress-based timelines
to be uploaded to the remote layer tree. However, JS-originated animations were
not yet
supported because they are initially marked pending and thus
`KeyframeEffect::canBeAccelerated()`
would return false.
We add support for JS-originated animations associated with progress-based
timelines by making sure
that when such animations are marked as ready [0] in
`KeyframeEffect::animationDidTick()` we
call into `updateAcceleratedAnimationIfNecessary()` which will make these
animations be reconsidered
for upload to the remote layer tree.
This required a bit of a hack as it stands because this system relies on the
timeline being a monotonic
timeline and the relevant code being on `DocumentTimeline`. We will address
that later in a refactor
to move this logic to `AnimationTimelinesController`.
We also change the system we use to process animations pending consideration to
be uploaded to the
remote layer tree from what has been historically used with animations
accelerated on Cocoa platforms
by Core Animation. We now modify the existing
`Document::updateStaleScrollTimelines()` method called
after layout in `Page::updateRendering()` to more generically run post-layout
tasks for animations,
and thus renamed to `Document::runPostRenderingUpdateAnimationTasks()`.
In this method, we now also trigger the mechanism to process such pending
animations so that animations
marked as ready are immediately uploaded to the remote layer tree instead of
waiting for the next frame.
As a result, in the modified
`webanimations/threaded-animations/scroll-driven-animations.html` layout
test, we introduce a new test function to wait until an animation should have
been uploaded to the remote
layer tree as follows:
```
const animationAcceleration = async animation => {
// An animation must be ready to be considered for acceleration.
await animation.ready;
// We only need to wait for the next JS run loop here
// because composition will happen during the animation frame,
// but after the requestAnimationFrame callbacks have been serviced.
await new Promise(setTimeout);
};
```
We also add a new test to check that a JS-originated animation has indeed been
marked as accelerated.
A future patch will add testing facilities on the remote end via
`UIScriptController` to allow the
retrieval of a JSON description of animations associated with a remote layer
tree node such that we
can validate the uploaded animation, timeline and effect data.
[0] https://drafts.csswg.org/web-animations-1/#ready
*
LayoutTests/webanimations/threaded-animations/scroll-driven-animations-expected.txt:
* LayoutTests/webanimations/threaded-animations/scroll-driven-animations.html:
* Source/WebCore/animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::runPostRenderingUpdateTasks):
(WebCore::DocumentTimeline::applyPendingAcceleratedAnimations):
* Source/WebCore/animation/DocumentTimeline.h:
* Source/WebCore/animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::animationDidTick):
* Source/WebCore/animation/WebAnimation.cpp:
(WebCore::WebAnimation::acceleratedStateDidChange):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::runPostRenderingUpdateAnimationTasks):
(WebCore::Document::updateStaleScrollTimelines): Deleted.
* Source/WebCore/dom/Document.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::updateRendering):
Canonical link: https://commits.webkit.org/302634@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications