Skip to content

RedirectVisual never repaints and Lottie clears the frame behind it (Skia) #24193

Closed

Description

@MartinZikmund

Current behavior 🐛

On feature/breakingchanges, the Microsoft.UI.Composition / RedirectVisual sample in the SamplesApp is broken in two independent ways on Skia (reproduced on Skia Desktop/Win32 and reported in the browser):

  1. A RedirectVisual never repaints. The redirected column is blank when the sample opens. It only appears after something forces a full repaint (resizing/maximizing the window), and once shown it is frozen on that one frame — a RedirectVisual mirroring an animating AnimatedVisualPlayer shows a stale frame forever.

    Root cause: RedirectVisual.CanPaint() delegates to its Source, but an element's visual is normally a plain ContainerVisual that leaves the painting to its children, so the redirect reports that it paints nothing. Visual.TryGetLocalContentBounds then sizes its content to an empty rect, TryGetPaintDamageRegion bails, and no damage is ever reported for the region the redirect draws into. This is latent on master too, where an unclipped Lottie render surface happened to over-damage the whole frame and masked it; the ported AnimatedVisualPlayer now clips its animated visual, so the frame is no longer over-damaged and the defect became visible.

  2. A Lottie animation paints on an opaque box. AnimatedVisualPlayer backed by LottieVisualSource clears its canvas to transparent inside SKCanvasElement.RenderOverride. That canvas is the frame being recorded, not a private surface, so SKCanvas.Clear (Src blend) punches the animation's box straight through everything painted behind the player — it renders black on Win32 and white in a browser (the page behind the canvas), instead of letting the app background show through.

Expected behavior 🎯

  1. A RedirectVisual repaints its own region every frame, so it mirrors its source live without needing a window resize.
  2. A Lottie animation composites over whatever is painted behind the player; transparent parts of the animation show the app background.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Build and run the SamplesApp on Skia from feature/breakingchanges:
    dotnet run --project src/SamplesApp/SamplesApp.Skia.Generic -- "sample=Microsoft.UI.Composition/RedirectVisual"
  2. Observe the "RedirectVisual" column: it is empty.
  3. Resize/maximize the window: the column appears, but the mirrored AnimatedVisualPlayer stays on a single frame while the source keeps animating.
  4. Observe the squirrel animation in the "Source" column: it is drawn on a solid opaque rectangle instead of the app background.

Minimal form of (1) without Lottie:

var compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
var redirect = compositor.CreateRedirectVisual(ElementCompositionPreview.GetElementVisual(source));
redirect.Size = new(100, 100);
ElementCompositionPreview.SetElementChildVisual(host, redirect);
// `host` stays blank until the window is resized.

Workaround 🛠️

For (1), forcing a full repaint (resizing the window) shows the redirected content once. There is no workaround for keeping it live.

For (2), none.

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

WebAssembly, Desktop (Windows), Desktop (macOS), Desktop (X11) — everything using the Skia compositor.

Uno.Sdk version (and other relevant versions) 📦

Source build of the feature/breakingchanges branch (Uno 7.0 development). Not present on master.

Anything else we need to know? 💬

Both defects are covered by new runtime tests:

  • Given_Visual_Damage.When_RedirectVisual_Repaints_Then_Its_Own_Region_Is_Damaged
  • Given_AnimatedVisualPlayer.When_Production_Lottie_Source_Renders_Then_Content_Behind_It_Is_Preserved

Activity

  1. added
    triage/untriaged
    on Aug 25, 2026
  2. added
    7.0
    on Oct 14, 2026
  3. removed
    triage/untriaged
    7.0
    on Oct 29, 2026
  4. self-assigned this
    on Oct 30, 2026
  5. ramezgerges commented on Oct 30, 2026

    @ramezgerges
    Contributor

    Both defects are fixed on master (which now contains feature/breakingchanges):

    1. RedirectVisual never repaints: fae2163, "Damage the region a RedirectVisual paints". RedirectVisual.CanPaint() is now Source is not null instead of delegating to the source visual, which is usually a ContainerVisual that paints nothing itself, so the redirect's region is damaged every frame.
    2. Lottie clears the frame behind it: 8a34f6a, "Stop clearing the frame behind the animation". The animation no longer Clears the recorded frame, so it composites over whatever is behind the player.

    Validation (Skia Desktop, master d980de546a): the two runtime tests from this issue pass:

    • Given_Visual_Damage.When_RedirectVisual_Repaints_Then_Its_Own_Region_Is_Damaged
    • Given_AnimatedVisualPlayer.When_Production_Lottie_Source_Renders_Then_Content_Behind_It_Is_Preserved

    Closing as fixed.

  6. khaskoul commented on Nov 14, 2026

    @khaskoul

    Verified fixed on Uno.Sdk 7.0.22 (Uno.WinUI 7.0.65) and 7.1.0-dev.18 (Uno.WinUI 7.1.0-dev.173), both parts, same result on both.

    Environment: Windows 11 Pro (26200), .NET SDK 10.0.401, Skia desktop (Win32), Release, 150% scale.

    Repro: page Background Orange; an AnimatedVisualPlayer (200x200) with a LottieVisualSource playing a transparent composition with a moving blue circle; next to it an empty Canvas hosting CreateRedirectVisual(GetElementVisual(player)), Size 200x200, set in Loaded.

    • Lottie: the orange background shows around the circle; no opaque box behind the animation.
    • RedirectVisual: the mirrored copy is visible right away (no resize) and follows the animation live (screenshots 700 ms apart show both circles moved by the same distance).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions