Skip to content

fix(composition): Repaint RedirectVisual and stop Lottie clearing the frame - #24194

Merged
MartinZikmund merged 5 commits into
feature/breakingchangesfrom
dev/mazi/redirectvisual
Sep 1, 2026
Merged

MartinZikmund merged 5 commits into
feature/breakingchangesfrom
dev/mazi/redirectvisual

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #24193

PR Type:

🐞 Bugfix

What changed? 🚀

The Microsoft.UI.Composition / RedirectVisual sample regressed on this branch: the redirected column stayed blank (and, once a window resize forced it to appear, froze on a single frame), and the Lottie animation next to it painted on an opaque rectangle instead of the app background. Two independent defects, both on the Skia compositor.

1. A RedirectVisual never damaged the region it paints

RedirectVisual.CanPaint() delegated to its Source. An element's visual is normally a plain ContainerVisual that leaves the painting to its children, so the redirect answered "I paint nothing". Visual.TryGetLocalContentBounds then sized its content to an empty rect, TryGetPaintDamageRegion bailed out, and the region the redirect actually draws into was never reported as damaged — it only ever showed up on a full repaint, and never followed its source afterwards.

This is latent on master as well. There, the Lottie render surface was an unclipped child element whose own damage covered the whole frame, which incidentally repainted the redirect every frame. The ported AnimatedVisualPlayer now clips its animated visual (m_rootVisual.Clip = compositor.CreateInsetClip()), so the frame is no longer over-damaged and the defect surfaced.

  • RedirectVisual.CanPaint() now reports painting whenever there is a Source.
  • RedirectVisual.TryGetLocalContentBounds reports the source subtree's bounds measured in the source parent's coordinate space — exactly what Visual.RenderRootVisual maps into the redirect's local space — so the damage stays tight instead of falling back to the whole clip.
  • New Visual.TryGetSubtreeContentBoundsInRoot helper, factored from the existing own-plus-descendants bounds logic used by the drop-shadow silhouette walk.

2. The Skia Lottie visual cleared the frame behind the player

LottieVisualSource's Skia path called canvas.Clear(SKColors.Transparent) inside SKCanvasElement.RenderOverride. That canvas is the frame being recorded, not a private surface, so the clear blended with Src over everything already painted underneath and punched the animation's box through the app background — black on Win32, and the white page behind the canvas in a browser. The renderer already clears the frame before the visual tree is drawn, and master's Skia Lottie path never cleared here either.

Validation

  • Runtime tests (Skia Desktop / Win32): both new tests fail before the change and pass after; Given_Visual_Damage, Given_RedirectVisual and Given_AnimatedVisualPlayer are green (32/32).
  • Manual (Skia Desktop / Win32): the sample now renders and animates both columns with a transparent animation background, matching a master build of the same sample side by side.
  • Regression sweep (Skia Desktop / Win32): 2984 tests across Windows_UI_Composition, Microsoft_UI_Xaml_Controls, Windows_UI_Xaml_Controls, Windows_UI_Xaml_Media and Windows_UI_Xaml_Shapes — 2754 passed, 67 failed, 73 skipped. The same test classes on a baseline build of 55f41a366e (this branch's tip before the change) fail 68. The two failure sets differ only in clipboard- and context-menu-dependent Given_TextBox cases, whose membership shuffles on every local run; the remaining failures are identical on both sides and are DPI-scaling layout assertions specific to this machine (Expected:<193>. Actual:<192.8>). No Composition, rendering or Lottie failures on either side.
  • WebAssembly was not re-verified locally (wasm-tools workload is not installed on this machine); both root causes are in shared Skia code and the browser symptoms are the same defects with a white page behind the canvas instead of a black window.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01SMoHqSCNVaS4na2bEk1DCJ

Copilot AI lite review requested due to automatic review settings August 25, 2026 10:45
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 20s —— View job


Review complete

Verdict: ship — 1 minor finding (non-blocking).

  • Gather context and understand the PR
  • Read changed files
  • Diff against base branch
  • Post inline review comments
  • Update summary comment

Summary

Both fixes are correct root-cause resolutions. The coordinate-space math in RedirectVisual.TryGetLocalContentBounds is sound, and the removal of canvas.Clear in the Lottie path is the right call — the canvas is the shared frame recording surface, so clearing it always punched through the compositor background regardless of what was behind the player.

RedirectVisual.skia.cs — CanPaint() correctly widened to Source is not null (the old delegation to Source?.CanPaint() returned false for any container source, which is the typical element visual). The new TryGetLocalContentBounds correctly converts root-space subtree bounds back to the redirect's local coordinate system via inverse(source.Parent.TotalMatrix), matching how RenderRootVisual paints (it undoes the parent transform before rendering the source). The shadow-state branch feeds those already-local bounds into TryGetShadowSilhouetteBounds, which is correct.

Visual.Damage.skia.cs — TryGetSubtreeContentBoundsInRoot is a clean extraction: it adds this visual's own contribution, then delegates to the already-existing TryAccumulateDescendantContentBoundsInRoot for descendants. No new allocations; the method is internal to the assembly.

LottieVisualSource.skia.cs — One-line removal plus an explanatory comment. Correct.

Tests — Both new tests follow the existing patterns in their respective files; the damage-bounds assertions are tight enough to catch fallback-to-whole-surface regressions. One minor gap (see inline): [GitHubWorkItem] is missing on both new methods per runtime-tests.md.

Edge-case note (not blocking): In TryGetLocalContentBounds, if source.Parent is null and the subtree returns non-empty bounds, those root-space bounds are used as local bounds verbatim — the redirect's own transform would then be double-applied by the damage system. This is a degenerate configuration (a detached floating source) that shouldn't arise in practice, but worth knowing.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes two Skia compositor regressions affecting the SamplesApp Microsoft.UI.Composition / RedirectVisual sample: (1) RedirectVisual not reporting paint/damage correctly (leading to blank/frozen redirected content), and (2) Skia Lottie rendering clearing the recorded frame (punching a “hole” through background content).

Changes:

  • Adjust RedirectVisual Skia damage/bounds reporting by treating a non-null Source as paintable and computing subtree content bounds in the correct coordinate space.
  • Introduce Visual.TryGetSubtreeContentBoundsInRoot to compute painted subtree bounds in root coordinates for tighter damage regions.
  • Remove SKCanvas.Clear from Skia Lottie rendering path and add runtime tests covering both regressions.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Composition/Given_Visual_Damage.cs Adds a runtime test ensuring RedirectVisual reports damage every frame in its own region.
src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_AnimatedVisualPlayer.cs Adds a runtime test ensuring production Lottie rendering doesn’t introduce transparent “holes” through an opaque background.
src/Uno.UI.Composition/Composition/Visual.Damage.skia.cs Adds TryGetSubtreeContentBoundsInRoot to compute subtree-painted bounds in root coordinates.
src/Uno.UI.Composition/Composition/RedirectVisual.skia.cs Fixes RedirectVisual paintability and local content bounds calculation based on the redirected subtree.
src/AddIns/Uno.UI.Lottie/LottieVisualSource.skia.cs Removes frame-clearing during Lottie rendering to preserve already-painted pixels behind the player.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 230066 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 196

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Attributed_text_FontSize_Changing.png
    • DropDownButtonPage.png-dark
    • Examples.png
    • ButtonClippingTestsControl.png
    • Buttons.png
    • ContentControl_Inheritance.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • DynamicFont.png
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Image_Margin_Large.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ContextRequested.png-dark
    • Image_AnimatedWebP.png-dark
  • skia-windows-screenshots: 196 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Dopes.png-dark
    • Buttons.png-dark
    • ContentPresenter_Template.png-dark
    • ContentPresenter_Template.png
    • Examples.png
    • ColorPickerSample.png-dark
    • ColorPickerSample.png
    • ChatBox.png
    • DoubleImageBrushInList.png-dark
    • FocusManagerTest.png-dark
    • FocusManagerTest.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • GetFocus.png-dark
    • GetFocus.png
    • Attributed_text_FontSize_Changing.png

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/redirectvisual branch from ae893ae to 7868deb Compare August 29, 2026 15:09
@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 231043 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 223

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Examples.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DynamicFont.png
    • DropDownButtonPage.png-dark
    • ImageBrush_Stretch.png
    • Attributed_text_FontSize_Changing.png
    • Focus_FocusVisual_Properties.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ContentControl_Inheritance.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Gamepad_CurrentReading.png-dark
  • skia-windows-screenshots: 223 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ContentPresenter_Padding.png-dark
    • ContentPresenter_Padding.png
    • FocusManagerTest.png-dark
    • FocusManagerTest.png
    • HyperlinkButton_IsEnabled_Automated.png-dark
    • HyperlinkButton_IsEnabled_Automated.png
    • Hyperlink_Button.png-dark
    • Hyperlink_Button.png
    • Hyperlink_CanExecute_False.png-dark
    • Hyperlink_CanExecute_False.png
    • ContextRequested.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • ElementLevelTheme.png-dark
    • Hyperlink_Disabled.png-dark
    • ElementLevelTheme.png
    • Hyperlink_Disabled.png
    • ImageAlignment2541.png-dark
    • ImageAlignment2541.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

MartinZikmund and others added 5 commits August 31, 2026 13:37
RedirectVisual.CanPaint() delegated to its Source, but an element's visual is
usually a plain ContainerVisual that leaves the painting to its children, so the
redirect reported that it painted nothing. TryGetLocalContentBounds then sized
its content to an empty rect and no damage was ever reported for the region it
mirrors into: the redirected content appeared only on a full repaint (a window
resize) and never followed the source afterwards.

This was latent until the ported AnimatedVisualPlayer started clipping its
animated visual, which had been over-damaging the whole frame and hiding it.

Report the redirect as painting whenever it has a Source, and bound its damage
to the source subtree measured in the source parent's space, which is what
RenderRootVisual maps into the redirect's local coordinates.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01SMoHqSCNVaS4na2bEk1DCJ
The Skia Lottie visual renders through an SKCanvasElement, so its canvas is the
frame being recorded rather than a private surface. Clearing it to transparent
therefore blended with Src over everything already painted underneath, punching
the animation's box through the app background: black on Win32, and the white
page behind the canvas in a browser.

The renderer already clears the frame before the visual tree is drawn, and
master's Skia path never cleared here either.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01SMoHqSCNVaS4na2bEk1DCJ
Left >= 90 bounded the damage instead of proving it reached x=100..150,
so it belongs with the over-damage check, not the coverage one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fix9QXTPgXQKcsfzxBvfsf
An #if around [Ignore] is the one form our own runtime-test conventions
tell us not to use; RuntimeTestPlatforms.Skia says the same thing without
a compile-time branch. The bodies keep their #if, as the damage helpers
only exist on Skia.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fix9QXTPgXQKcsfzxBvfsf
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/redirectvisual branch from 7791dfb to 8a85f4f Compare August 31, 2026 11:39
@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 231142 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 220

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ContentControl_Inheritance.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ButtonClippingTestsControl.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • Image_Margin_Large.png
    • Attributed_text_FontSize_Changing.png
    • ButtonClippingTestsControl.png
    • ContextRequested.png-dark
    • ElementLevelTheme.png-dark
    • DropDownButtonPage.png-dark
    • ElementLevelTheme.png
    • DynamicFont.png
    • Examples.png
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark
  • skia-windows-screenshots: 220 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ChatBox.png-dark
    • ChatBox.png
    • Clipping652.png-dark
    • Clipping652.png
    • ExpanderColorValidationPage.png-dark
    • Focus_FocusState.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusState.png
    • Hyperlink_Button.png-dark
    • Hyperlink_Button.png
    • Hyperlink_CanExecute_False.png-dark
    • Hyperlink_CanExecute_False.png
    • ImagesInlineInFlipView.png-dark
    • ImagesInlineInFlipView.png
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • BorderVisualClipping.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 231142 has failed on Uno.UI - CI.

MartinZikmund added a commit that referenced this pull request Sep 1, 2026
The ms-appdata load intermittently never completes on the Android Skia
runtime-test host: the test starts, then 30 seconds of total silence
follow with no ImageOpened, no ImageFailed and no exception, until the
inner WaitAsync trips. That is the same signature already tracked for
the Linux hosts in #23967, which the existing exclusion covers.

#24215 already excluded SkiaAndroid for this test, but gated behind
RUNTIME_NATIVE_AOT while investigating #24271. The hang is not specific
to NativeAOT -- it reproduces on the plain Android Skia leg -- so the
exclusion is un-gated here rather than duplicated, and #24271 is kept
in the comment.

The test only began running on Android at all once #24003 aligned shard
0's UITEST_RUNTIME_TEST_GROUP_COUNT (4 -> 5, 005db43): selection is
a stable hash modulo that count, so before the fix When_MsAppData was
one of the 14.7% of methods no shard selected. It is not a new failure,
just a newly executed one.

Since that merge it has failed on three unrelated PR builds within
hours of each other -- 231145 (#24186), 231142 (#24194) and 231152
(#19083) -- where the isolated retry only sometimes recovers, so it
reddens whichever PR happens to be unlucky. master still carries the
old count of 4 and therefore never runs it.

Scoped to this test alone: When_MsAppData_StreamDisposed_FileNotLocked
and When_Exif_Rotated_MsAppData use the same ms-appdata path and run
green on Android in every post-fix build checked, so they keep running.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015Lk1RUZfAj6A7xGWzYaoBw
@MartinZikmund

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 231377 found UI Test snapshots differences: skia-linux-screenshots: 82, skia-windows-screenshots: 111

Details
  • skia-linux-screenshots: 82 changed over 2356

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • CalendarView_Theming.png-dark
    • ImagesInlineInFlipView.png-dark
    • ImagesInlineInFlipView.png
    • Examples.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • DynamicFont.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • Image_UseTargetSize.png
    • Basics Pivot Test.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ColorPickerSample.png
    • DataTransferManager.png
    • DoubleImageBrushInList.png-dark
    • DropDownButtonPage.png-dark
  • skia-windows-screenshots: 111 changed over 2356

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Attributed_text_FontSize_Changing.png
    • ExpanderColorValidationPage.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Accessibility_ScreenReader.png-dark
    • Basics Pivot Test.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • ContentPresenter_NativeEmbedding_Android_FillType.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Grid_RowSpan_Right.png-dark
    • ImageIconPage.png-dark
    • ImagesInlineInFlipView.png-dark
    • ImagesInlineInFlipView.png
    • Image_UseTargetSize.png-dark
    • Image_UseTargetSize.png
    • Image_UseTargetSizeLate.png-dark
    • Image_UseTargetSizeLate.png
    • ContextRequested.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 231377 has failed on Uno.UI - CI.

@MartinZikmund
MartinZikmund merged commit a9a7170 into feature/breakingchanges Sep 1, 2026
46 of 47 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/redirectvisual branch September 1, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants