Skip to content

feat(skia): Add flag to skip visual tree painting#23667

Open
ramezgerges wants to merge 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/skip-visual-tree-painting
Open

feat(skia): Add flag to skip visual tree painting#23667
ramezgerges wants to merge 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/skip-visual-tree-painting

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes https://github.com/unoplatform/uno-private/issues/2204

PR Type:

✨ Feature

What changed? 🚀

Adds Uno.UI.FeatureConfiguration.Rendering.SkipVisualTreePainting (default false, Skia targets only). When enabled, each frame skips the visual tree paint walk — the expensive per-frame work of recording the whole tree into an SKPicture — 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:

  • Composition animations still tick (RaiseAnimationFrame) and background transitions still expire, including Completed events and scoped batches.
  • Frame scheduling stays alive: CompositionTarget.Render()/Draw() still execute, so FrameRendered, the public CompositionTarget.Rendering event, and render-job execution still fire (an empty picture is recorded and replayed, which is nearly free).
  • RenderTargetBitmap is unaffected — it records its own picture directly from the visual, so screenshot-based tests still capture real content.
  • Native-element clip path and z-order tracking still run (separate walk, not part of the paint walk).

Transform matrices stay correct because they are pull-based: invalidation marks them dirty at mutation time and the TotalMatrix getter 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 (in Uno.UI.Composition) can't reference FeatureConfiguration (in Uno.UI), the public flag delegates to an internal static under #if __SKIA__, mirroring the existing EnableVisualSubtreeSkippingOptimization pattern; on non-Skia targets it's a no-op returning false.

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 in feature-flags.md.

PR Checklist ✅

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 7, 2026 00:15
@github-actions github-actions Bot added area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation labels Jul 7, 2026

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

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, default false) 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.

Comment on lines +21 to +23
Assert.IsFalse(FeatureConfiguration.Rendering.SkipVisualTreePainting);
FeatureConfiguration.Rendering.SkipVisualTreePainting = true;
try
Comment on lines +47 to +50
finally
{
FeatureConfiguration.Rendering.SkipVisualTreePainting = false;
}
@unodevops

Copy link
Copy Markdown
Contributor

🤖 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

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 220972 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • DisplayInformation.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ImageIconPage.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ContextRequested.png-dark
  • skia-windows-screenshots: 2348 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png-dark
    • ApplicationViewMode.png
    • AppWindowFeatures.png
    • AppWindowPresenters.png
    • ArcSegment.png
    • AuthenticationBroker_Demo.png-dark
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_Name.png-dark
    • AutoSuggestBox_Reason.png-dark
    • AutoSuggestBox_Reason.png
    • BasicThemeResources.png
    • Battery.png-dark
    • BorderCenteredwithmargins.png
    • BorderImageBrush.png-dark
    • Border_Simple_No_Background_With_Content_Border_With_Background.png-dark
    • Border_Simple_No_Background_With_Content_Border_With_Background.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • Button_UseUWPDefaultStyles.png-dark
    • Button_UseUWPDefaultStyles.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties

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 kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants