Skip to content

perf(wasm): Enable XAML resource trimming in Release - #26071

Closed
MartinZikmund wants to merge 3 commits into
masterfrom
dev/mazi/wasm-xaml-trimming-default
Closed

MartinZikmund wants to merge 3 commits into
masterfrom
dev/mazi/wasm-xaml-trimming-default

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #26070

PR Type:

✨ Feature

What changed? 🚀

Uno.Sdk WebAssembly heads now default UnoXamlResourcesTrimming to true in Release (Optimize=true), where ILLink already runs. An explicit value in the project wins, so false opts out. Debug builds, other targets, and AOT profile generation (Uno.GenerateAot.targets still forces false) are unchanged.

While validating this, a control gallery app showed one Uno-internal casualty: an ItemsView without an ItemTemplate rendered empty. Its default template was built with XamlReader.Load, so the trimmer never saw ItemContainer being created. This was observed together with #26054, which stops keeping a control's bindable metadata just because the type survives an is check. That change is the likely trigger, though master + trimming was not built separately to confirm, so this fix should land before or with #26054. It is now built in code, like ItemsRepeater's default. The remaining XamlReader.Load string calls in Uno.UI build a TabViewItem geometry and a Run, not controls (TabView renders correctly trimmed).

Known limit, unchanged from opting in today (documented in resources-trimming.md): app code that creates controls only through XamlReader.Load strings needs those controls rooted, or must opt out.

Validation:

  • Runtime (WASM, trimmed): gallery app (images, Thai text, 20 common controls, ItemsView, TabView, flyouts) is pixel-identical between trimmed and untrimmed builds once the ItemsView fix is in. Before the fix, the ItemsView items were missing.
  • Runtime (WASM, default): the same app published with no property set comes out at the trimmed size (39.4 MB on disk vs 44.6 MB), confirming the default applies.
  • Runtime test: Given_ItemsView.When_No_ItemTemplate_Then_Items_Shown_In_ItemContainers passes on Skia desktop.

Measurements

Blank app Trimming off (today's default) Trimming on (this PR) Δ
Download (brotli) 8.28 MB 6.42 MB −1.86 MB (−22%)
4G visually ready (5 runs) 8695 ms (8656–9074) 6984 ms (6953–7015) −1711 ms (−20%)
Mobile visually ready (3 runs) 11426 ms (11235–11792) 9685 ms (9665–9763) −1741 ms (−15%)
Local visually ready (7 runs) 969 ms (951–1393) 918 ms (874–1585) within noise

How this was measured

Blank dotnet new unoapp (Skia, net10.0-browserwasm, Release publish), with the other startup PRs (#26054–#26059) applied, built with and without UnoXamlResourcesTrimming. Both builds were served by the same static server (brotli q11, immutable caching for fingerprinted files) and loaded cold in headless Chrome, runs interleaved. "Visually ready" is the first CDP screencast frame identical to the settled final frame. 4G = 9 Mbps down, 85 ms RTT (CDP emulation). Mobile = 4G plus 4× CPU throttling. Values are medians with (min–max). A difference is only claimed where the ranges don't overlap. Rig: Playwright + Node, available on request.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable)
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features)
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

Not ticked "no breaking changes": apps that build controls only from XamlReader.Load strings must root them or set UnoXamlResourcesTrimming=false.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TXMNu2RupRy4QPFGK2cmij

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 243775 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png
    • AnimatedBackVisualSourceSamplePage.png
    • AndroidWindowInsets.png
    • Accessibility_ScreenReader.png-dark
    • AnimatedIconPage.png
    • AppBarButtonTest.png
    • AnimatedVisualsTestbedPage.png
    • AppBarButtonWithIconTest.png-dark
    • AnimatedVisualsTestbedPage.png-dark
    • AppBarButtonTest.png-dark
    • ApplicationViewMode.png
    • ApplicationViewSpanningRectsPage.png
    • AppBar_KeyBoard.png-dark
    • ApplicationViewSizing.png
    • AppBar_KeyBoard.png
    • AppWindowPositionAndSize.png
    • AppWindowPositionAndSize.png-dark
    • Application_DispatcherShutdownMode.png-dark
    • AppWindowFeatures.png-dark
    • Application_DispatcherShutdownMode.png
  • skia-windows-screenshots: 2458 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • AndroidWindowInsets.png-dark
    • AndroidWindowInsets.png
    • AnimatedIconPage.png-dark
    • ApplicationViewMode.png-dark
    • AppBarButtonTest.png-dark
    • AnimatedBackVisualSourceSamplePage.png
    • AnimatedVisualsTestbedPage.png-dark
    • AppWindowClosing.png-dark
    • AppBarButtonWithIconTest.png-dark
    • AppBarButtonWithIconTest.png
    • AppBarButtonTest.png
    • AppWindowPresenters.png
    • AppBarToggleButtonTest.png
    • ApplicationViewMode.png
    • AppBar_KeyBoard.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • ApplicationViewSizing.png-dark
    • Application_DispatcherShutdownMode.png
    • ApplicationViewSpanningRectsPage.png

@unodevops

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable XAML resource trimming by default for WebAssembly Release builds

3 participants