feat(skia): Add flag to skip visual tree painting#23667
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a Skia-only feature flag to intentionally skip the visual tree paint walk while keeping the rest of the rendering/composition pipeline alive, primarily to reduce CPU/GPU use in scenarios where pixels are not needed (e.g., automated/runtime tests). The change is wired from FeatureConfiguration into the Skia compositor render loop, with documentation and a runtime test validating frame production + RenderTargetBitmap behavior.
Changes:
- Added
FeatureConfiguration.Rendering.SkipVisualTreePainting(Skia-only, defaultfalse) that forwards to the Skia compositor. - Updated Skia compositor render loop to conditionally skip
rootVisual.RenderRootVisual(...)while still ticking animations/transitions and frame scheduling. - Added a Skia runtime test and documentation entry for the new flag.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Uno.UI/FeatureConfiguration.cs | Introduces the public Skia-only feature flag and forwards it to the compositor. |
| src/Uno.UI.Composition/Composition/Compositor.skia.cs | Implements the conditional “skip paint walk” behavior inside RenderRootVisual. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media/Given_CompositionTarget.cs | Adds a Skia runtime test asserting frames still render and RenderTargetBitmap still captures content. |
| doc/articles/feature-flags.md | Documents the new Skia feature flag and its intended usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Assert.IsFalse(FeatureConfiguration.Rendering.SkipVisualTreePainting); | ||
| FeatureConfiguration.Rendering.SkipVisualTreePainting = true; | ||
| try |
| finally | ||
| { | ||
| FeatureConfiguration.Rendering.SkipVisualTreePainting = false; | ||
| } |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23667/wasm-skia-net9/index.html |
|
The build 220972 found UI Test snapshots differences: Details
|
GitHub Issue: closes https://github.com/unoplatform/uno-private/issues/2204
PR Type:
✨ Feature
What changed? 🚀
Adds
Uno.UI.FeatureConfiguration.Rendering.SkipVisualTreePainting(defaultfalse, Skia targets only). When enabled, each frame skips the visual tree paint walk — the expensive per-frame work of recording the whole tree into anSKPicture— producing frames with no visual output. This saves CPU/GPU in scenarios where the visual output is of no interest, e.g. automated/runtime test runs.The skip is placed inside
Compositor.RenderRootVisual, around only the paint walk, so everything else keeps running as usual:RaiseAnimationFrame) and background transitions still expire, includingCompletedevents and scoped batches.CompositionTarget.Render()/Draw()still execute, soFrameRendered, the publicCompositionTarget.Renderingevent, and render-job execution still fire (an empty picture is recorded and replayed, which is nearly free).RenderTargetBitmapis unaffected — it records its own picture directly from the visual, so screenshot-based tests still capture real content.Transform matrices stay correct because they are pull-based: invalidation marks them dirty at mutation time and the
TotalMatrixgetter recomputes lazily at read time, so hit-testing,TransformToVisual, and automation bounds don't depend on the paint walk having run. Paint caches (_picture, picture-collapsing counters) are consumed only by the walk itself, so toggling the flag off mid-run self-heals: everything is still dirty and the next frame repaints fully.Since
Compositor(inUno.UI.Composition) can't referenceFeatureConfiguration(inUno.UI), the public flag delegates to an internal static under#if __SKIA__, mirroring the existingEnableVisualSubtreeSkippingOptimizationpattern; on non-Skia targets it's a no-op returningfalse.Includes a runtime test (
Given_CompositionTarget.When_SkipVisualTreePainting, passing on Skia Desktop) verifying that with the flag on, a property change still produces a frame and a screenshot still shows actual content, plus documentation infeature-flags.md.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code