Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9fe876d63d4a51281d610347cbc2c9a4de04368b
      
https://github.com/WebKit/WebKit/commit/9fe876d63d4a51281d610347cbc2c9a4de04368b
  Author: Antoine Quint <[email protected]>
  Date:   2026-02-22 (Sun, 22 Feb 2026)

  Changed paths:
    M LayoutTests/platform/mac-wk2/TestExpectations
    A 
LayoutTests/webanimations/threaded-animations/accelerated-timeline-preservation-during-update-expected.txt
    A 
LayoutTests/webanimations/threaded-animations/accelerated-timeline-preservation-during-update.html
    M Source/WebCore/animation/AcceleratedEffectStackUpdater.cpp
    M Source/WebCore/platform/animation/AcceleratedEffectStack.h
    M Source/WebCore/platform/graphics/GraphicsLayer.h
    M Source/WebCore/rendering/RenderLayerBacking.cpp
    M Source/WebCore/rendering/RenderLayerBacking.h

  Log Message:
  -----------
  [threaded-animations] remote timeline may not get preserved in update where a 
new animation uses it
https://bugs.webkit.org/show_bug.cgi?id=308429
rdar://170365106

Reviewed by Simon Fraser.

We update threaded animations once per page rendering update. This process 
involves a list of target
Styleable instances that have been marked as dirty during when animations last 
updated. That list is
processed in `AcceleratedEffectStackUpdater::update()` where we create a 
current list of accelerated
effects for this styleable's associated graphics layer, replacing the existing 
list of accelerated
effects by creating a new `AcceleratedEffectStack`.

The `AcceleratedEffectStack` keeps a strong reference to its 
`AcceleratedEffect` instances, which in
turn keep a strong reference to its `AcceleratedTimeline` instance.

This means that during the call to `AcceleratedEffectStackUpdater::update()`, 
as accelerated effect
stacks are replaced, accelerated effects and their associated timelines may get 
destroyed. Then, when
layer tree commit will occur, 
`AcceleratedTimelinesUpdater::takeTimelinesUpdate()` will identify
which `AcceleratedTimeline` instances are no longer in use and mark them for 
deletion when the remote
layer tree processes that update.

Consider the case where an existing animation A is running on target A. In a 
later page rendering update,
that animation A will have been canceled as a new animation B will be started 
on target B. Both animations
may be associated with the same timeline, as is common with monotonic 
animations which will use the
default document timeline. During the call to 
`AcceleratedEffectStackUpdater::update()`, target A may be
processed first, causing its accelerated effect stack to be cleared and its 
accelerated effect – and associated
timeline – to be destroyed. During that same function, as target B gets 
processed, a new accelerated effect
is created and a new `AcceleratedTimeline` will be created, using the same 
identifier as the accelerated
timeline that was just destroyed because they are the accelerated 
representation of the same, persistent
`DocumentTimeline`.

As a result, that timeline identifier will be marked for deletion and we will 
fail the timeline lookup in
`RemoteLayerTreeNode::setAcceleratedEffectsAndBaseValues()`, causing a crash.

We fix this issue by keeping a list of strong references to all effects 
previously associated with the targets
processed during a call to `AcceleratedEffectStackUpdater::update()`. This way, 
the accelerated effects that are
no longer current will be destroyed in a batch as that function ends, making 
sure in the scenario described above
that when we process target B, the accelerated timeline that was used for 
target A remains alive. As a result,
during this update, no timeline is marked for either creation or destruction.

To support this, we need to expose the `AcceleratedEffectStack` through 
`RenderLayerBacking`. Doing so made it
clear that existing accessors on `GraphicsLayer` should have return a const 
pointer, so we make those changes
as well.

This uncovered a reproducible deadlock when running this new test over multiple 
iterations, covered by bug 308430,
which we will address separately.

Test: 
webanimations/threaded-animations/accelerated-timeline-preservation-during-update.html

* LayoutTests/platform/mac-wk2/TestExpectations:
* 
LayoutTests/webanimations/threaded-animations/accelerated-timeline-preservation-during-update-expected.txt:
 Added.
* 
LayoutTests/webanimations/threaded-animations/accelerated-timeline-preservation-during-update.html:
 Added.
* Source/WebCore/animation/AcceleratedEffectStackUpdater.cpp:
(WebCore::AcceleratedEffectStackUpdater::update):
* Source/WebCore/platform/animation/AcceleratedEffectStack.h:
* Source/WebCore/platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::acceleratedEffectStack const):
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::acceleratedEffectStack const):
* Source/WebCore/rendering/RenderLayerBacking.h:

Canonical link: https://commits.webkit.org/308011@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to