Fix WASM gallery startup stall/blank by forcing UnoRuntimeIdentifier#314
Open
MartinZikmund wants to merge 1 commit into
Open
Fix WASM gallery startup stall/blank by forcing UnoRuntimeIdentifier#314MartinZikmund wants to merge 1 commit into
MartinZikmund wants to merge 1 commit into
Conversation
…Identifier The WASM head sets TargetFramework late, via App.Head.Wasm.props imported in the project body, after NuGet's generated .nuget.g.props has already been evaluated. That generated file imports Uno.(UI|WinUI).Runtime.WebAssembly.props - which sets UnoRuntimeIdentifier=WebAssembly - inside an ImportGroup gated on "'$(TargetFramework)' == 'net9.0'". Since TargetFramework is still empty when .nuget.g.props is evaluated, the import is skipped and UnoRuntimeIdentifier is never set. With UnoRuntimeIdentifier empty, Uno's ReplaceUnoRuntime target (gated on UnoRuntimeIdentifier != '') does not run, so the platform-agnostic reference Uno.UI.dll (lib/, no embedded JS) is deployed instead of the uno-runtime/.../webassembly implementation that embeds Uno.UI.WasmScripts.Uno.UI.js. The bootstrapper therefore has no Uno runtime JS to load, globalThis.Uno.UI is never registered, Application.Start's callback is never invoked, and the gallery hangs on the splash screen (WinUI 2 / Uno.UI) or shows blank (WinUI 3 / Uno.WinUI). This regressed in the net8 -> net9 migration that flipped the head SDK from Microsoft.NET.Sdk.Web to Microsoft.NET.Sdk.WebAssembly. Set UnoRuntimeIdentifier=WebAssembly and UnoIsWebAssemblyBrowserHead=true explicitly in App.Head.Wasm.props so the runtime-assembly swap runs regardless of NuGet import timing. Verified end-to-end (gallery renders, 2386 XAML elements) for both Uno.UI/WinUI 2 and Uno.WinUI/WinUI 3. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The WebAssembly gallery fails on startup: WinUI 2 / Uno.UI (production at toolkitlabs.dev) hangs on the splash screen at ~100% load, and WinUI 3 / Uno.WinUI shows a blank screen. No console error. Both have the same root cause and regressed with the net8→net9 migration that flipped the head SDK from
Microsoft.NET.Sdk.WebtoMicrosoft.NET.Sdk.WebAssembly.Root cause
TargetFrameworklate — inApp.Head.Wasm.props, imported in the project body..nuget.g.propsimportsUno.(UI|WinUI).Runtime.WebAssembly.props(which setsUnoRuntimeIdentifier=WebAssembly) inside anImportGroupgated on'$(TargetFramework)' == 'net9.0'. That file is evaluated before the project body, whenTargetFrameworkis still empty, so the import is skipped andUnoRuntimeIdentifiernever gets set.ReplaceUnoRuntimetarget is gated onUnoRuntimeIdentifier != '', so it never runs. That target swaps the platform-agnostic referencelib/net9.0/Uno.UI.dll(no embedded JS) for theuno-runtime/.../webassembly/Uno.UI.dllimplementation that embedsUno.UI.WasmScripts.Uno.UI.js.Uno.UI.jsis never delivered →globalThis.Uno.UInever registers →Application.Start's callback is never invoked → the splash never clears.Diagnostic proof:
dotnet build … --getProperty:UnoRuntimeIdentifierreturns empty; adding-p:TargetFramework=net9.0(early) returnsWebAssembly.Fix
Set
UnoRuntimeIdentifier=WebAssemblyandUnoIsWebAssemblyBrowserHead=trueexplicitly inApp.Head.Wasm.props(what the skipped NuGet import would have set). The runtime-assembly swap runs late enough that a bodyPropertyGroupsatisfies its gate.Verification
Built and run in the browser for both flavors. After the fix: 11 MB runtime
Uno.UI.dlldeployed,Uno.UI.jspresent in the package,uno_dependenciesincludesUno.UI, and the gallery renders fully (2386 XAML elements, loader gone) in both Uno.UI/WinUI 2 and Uno.WinUI/WinUI 3.Note for maintainers
This is the minimal, low-risk fix. The deeper issue is that the late-
TargetFrameworkpattern silently skips anynet9.0-conditional NuGet import; longer-term, makingTargetFrameworkknown before.nuget.g.props(global property / real multi-targeting outer build) or migrating heads to Uno.Sdk would address the class of problem.🤖 Generated with Claude Code