Repository navigation
fix(wasm): Surface exceptions thrown from OnLaunched - #25859
Merged
ramezgerges merged 1 commit intoNov 2, 2026
Merged
ramezgerges merged 1 commit into
ramezgerges merged 1 commit into
Conversation
The browser runs OnLaunched from a dispatcher callback after Application.Start returns, so an exception from it was only logged by the dispatcher (a no-op without a configured logger) while RunAsync waited forever: a blank page and an empty console. The deferred launch now completes a task the host awaits, so the failure is printed and faults RunAsync, as on the other heads (fixes unoplatform#24308). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Contributor
|
The build 242603 found UI Test snapshots differences: Details
|
MartinZikmund
approved these changes
Nov 2, 2026
Contributor
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
2 of 5 tasks
2 of 5 tasks
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.
GitHub Issue: closes #24308
PR Type:
🐞 Bugfix
What changed? 🚀
On WebAssembly, an exception thrown from
Application.OnLaunchedleft a blank page, a still-visible loader and, without a configured logger, a completely empty console.AppDomain.UnhandledException,TaskScheduler.UnobservedTaskExceptionand atry/catcharoundawait host.RunAsync()all stayed silent.Cause. Only on the browser,
Application.StartPartialdefers launch withDispatcherQueue.Main.TryEnqueue(currentApp.PrepareOnLaunched)(so the .NET exports are initialized first).Application.Startreturns,WebAssemblyBrowserHost.RunLoopparks onawait Task.Delay(-1), and whenOnLaunchedthen throws,NativeDispatcher.RunActioncatches it and only callsLog().Error(...), which writes nothing unless the app registered a logger. On the other headsOnLaunchedruns synchronously insideApplication.Start, so the exception escapesRunLoopandRunAsyncfaults.Fix.
Application: the deferred launch completes a new internalDeferredLaunchtask, or faults it with whatPrepareOnLaunchedthrew (also logged asOnLaunched failed).WebAssemblyBrowserHost.RunLoopawaitsDeferredLaunchbefore parking. A failure goes through the existing catch, which printsApp failed to initialize: …withConsole.WriteLine(no logger needed) and rethrows, soawait host.RunAsync()faults as on the other heads. Secondary-ALC hosts don't wait, as before.Not covered:
AppDomain.UnhandledExceptionis still not raised (the failure reaches the app'sawait host.RunAsync()instead), and exceptions thrown after the firstawaitof anasync void OnLaunchedstill go through the dispatcher's log-only path.Validation (runtime: WebAssembly SamplesApp, clean publish, headless Edge, with temporary hooks, not committed: a URL flag that throws from
OnLaunched, one that skips logger setup, and the issue'sAppDomain/UnobservedTaskException/try-catchprobes inProgram.cs)RunAsyncnever completes, no probe firesApp failed to initialize: System.InvalidOperationException: boom from OnLaunchedwith the stack, and thecatcharoundawait host.RunAsync()receives itNativeDispatcher unhandled exceptionfail: Microsoft.UI.Xaml.ApplicationOnLaunched failedNo automated test: the runtime-test app is already launched, so
OnLaunchedcan't be made to throw from a test.Compile:
Uno.UI.Runtime.WebAssembly.Browser(which buildsUno.UI) with analyzers on.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code