Skip to content

Composition animations below a removed subtree keep rendering at display rate and leak the subtree #25054

Open

Description

@MartinZikmund

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 (children CollectionChanged, Remove/Reset) calls StopAllAnimations() only on the directly removed child, and the Visual.Parent setter only stops animations when that visual's own parent becomes null. Descendants of the removed root keep their parent, so their animations stay registered.
  • Compositor.RegisterAnimation captured the window's ICompositionTarget at start time, and Compositor.RenderRootVisual ends every frame with if (_runningAnimations.Count > 0 ...) rootVisual.CompositionTarget?.RequestNewFrame();. A detached, infinite animation (e.g. a ProgressRing/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._runningAnimations holds the animation strongly, the animation's AnimationFrame handler 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) 🔬

  1. Put a StackPanel in the window with a Border child.
  2. Start an infinite ScalarKeyFrameAnimation (IterationBehavior = Forever) on the child's element visual (ElementCompositionPreview.GetElementVisual(child)), e.g. on Opacity.
  3. Remove the StackPanel from the window.
  4. 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

  1. self-assigned this
    on Oct 6, 2026
  2. added
    kind/bug
    triage/untriaged
    on Oct 6, 2026
  3. added
    7.0
    on Oct 14, 2026
  4. removed
    triage/untriaged
    7.0
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/performancekind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions