Repository navigation
Description
What happened
An exception thrown from Application.OnLaunched on WebAssembly is swallowed completely. The app is left with the loading indicator still showing and a <canvas> that never leaves its 300x150 HTML default, and nothing at all is written to the browser console.
Because there is no diagnostic of any kind, the failure is indistinguishable from "the app is still loading" or "Skia failed to start". Working out that an exception had been thrown at all took a long time, and finding which one required bisecting OnLaunched by hand.
Expected
The exception should surface somewhere — logged through Uno's logging at Error, rethrown so that await host.RunAsync() faults, or reported to AppDomain.CurrentDomain.UnhandledException. Any one of these would be enough.
Actual
None of these observe it:
AppDomain.CurrentDomain.UnhandledExceptionTaskScheduler.UnobservedTaskException(withSetObserved())try/catchwrapped directly aroundawait host.RunAsync()
The console output stops after Uno's own bootstrap lines. The last thing visible is the runtime starting; nothing follows.
Repro
Any exception thrown from OnLaunched reproduces it. In our case a page constructor reached by rootFrame.Navigate(...) threw DllNotFoundException (a [DllImport("kernel32.dll")] that cannot resolve in a browser), surfacing as TargetInvocationException out of Navigate.
Minimal shape:
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
throw new InvalidOperationException("boom");
}// Platforms/WebAssembly/Program.cs - none of the hooks below observe the throw
public static async Task Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
Console.WriteLine($"unhandled: {e.ExceptionObject}");
TaskScheduler.UnobservedTaskException += (_, e) =>
{
Console.WriteLine($"unobserved: {e.Exception}");
e.SetObserved();
};
var host = UnoPlatformHostBuilder.Create()
.App(() => new App())
.UseWebAssembly()
.Build();
try { await host.RunAsync(); }
catch (Exception ex) { Console.WriteLine($"host failed: {ex}"); throw; }
}Observable state once it has failed:
document.getElementById('uno-canvas').width // 300 (never resized)
document.querySelector('.uno-loader:not([hidden])') // still presentApplication.Current and Window.Current are both non-null; Window.Current.Content is never assigned, because OnLaunched died before reaching that line.
Environment
- Uno.WinUI
7.0.0-dev.579, Uno.Sdk.Private net10.0-browserwasm, .NET 10.0.11, Mono interpreter, linker disabled- Skia renderer,
Uno.UI.Runtime.Skia.WebAssembly.Browser.WebAssemblyBrowserHost - Chromium, WebGL2
Observed on WebAssembly. Not verified on the other heads, so the title is scoped to WASM.
Why it matters
This is the first thing an app does. When it fails silently the result is a blank page with an empty console and no thread to pull on — the worst possible first-run experience, and it makes every subsequent startup bug much more expensive to diagnose than it needs to be.
Activity
fix(wasm): Surface exceptions thrown from OnLaunched