Repository navigation
Description
Current behavior 🐛
Composition keyframe animations running on a visual below the root of a removed subtree keep running after the subtree leaves the tree:
ContainerVisual(childrenCollectionChanged, Remove/Reset) callsStopAllAnimations()only on the directly removed child, and theVisual.Parentsetter only stops animations when that visual's own parent becomesnull. Descendants of the removed root keep their parent, so their animations stay registered.Compositor.RegisterAnimationcaptured the window'sICompositionTargetat start time, andCompositor.RenderRootVisualends every frame withif (_runningAnimations.Count > 0 ...) rootVisual.CompositionTarget?.RequestNewFrame();. A detached, infinite animation (e.g. aProgressRing/Lottie inside a removed panel) therefore keeps the window rendering at display rate (60/120 Hz) forever: constant CPU/GPU wake-ups, heat, battery drain.Compositor._runningAnimationsholds the animation strongly, the animation'sAnimationFramehandler holds its target visual, and the visual holds its parent chain: the whole detached subtree leaks.
Related: animations started on a visual that isn't attached yet (target null) were silently never registered, so they never tick once the visual is attached.
Expected behavior 🎯
A detached visual's animations neither tick nor request frames, and nothing in the compositor keeps the detached subtree alive. When the subtree is attached again, its animations resume (keyframe animations are time-based, so they continue as if they had kept running, which matches WinUI where composition animations survive tree changes).
How to reproduce it (as minimally and precisely as possible) 🔬
- Put a
StackPanelin the window with aBorderchild. - Start an infinite
ScalarKeyFrameAnimation(IterationBehavior = Forever) on the child's element visual (ElementCompositionPreview.GetElementVisual(child)), e.g. onOpacity. - Remove the
StackPanelfrom the window. - The compositor keeps reporting
IsAnimating, frames keep being requested every vsync, and the child visual is never collected.
Workaround 🛠️
Stop composition animations explicitly before removing their ancestors (e.g. in Unloaded).
Renderer 🎨
- Skia
Affected platforms 📱💻🖥️
All Skia targets (shared composition code). Present in 6.7 and 7.0.
Uno.Sdk version (and other relevant versions) 📦
6.7.x and 7.0 master.
IDE version 🧑💻
N/A
Anything else we need to know? 💬
Raised in review of #25046 (the CompositionObject finalizer could never have helped here: everything involved stays reachable through the compositor).
Activity
test(skia): Add rendering budget runtime tests