Skip to content

[WASM] Exceptions thrown from OnLaunched are swallowed, leaving a blank canvas and an empty console #24308

Closed

Description

@MartinZikmund

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.UnhandledException
  • TaskScheduler.UnobservedTaskException (with SetObserved())
  • try/catch wrapped directly around await 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 present

Application.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

  1. added
    7.0
    on Oct 14, 2026
  2. removed
    7.0
    on Oct 29, 2026
  3. self-assigned this
    on Oct 31, 2026
  4. added a commit that references this issue on Nov 2, 2026
    137ad67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions