Skip to content

Win32: an exception thrown from OnLaunched is swallowed, leaving a windowless process running and no UnhandledException #24930

Done

Description

@MartinZikmund

Current behavior 🐛

On the Skia Win32 head, an exception thrown from Application.OnLaunched is swallowed. The process does not crash and Application.UnhandledException is never raised. The app is left running forever with no window, no console output, and nothing in AppDomain.UnhandledException.

From a user's point of view the app "just doesn't open", and a stuck process stays behind in Task Manager. Any startup bug is invisible unless OnLaunched is wrapped in a try/catch by hand.

Observed on Uno.WinUI 7.0.0-dev.1435 (Release, net10.0-desktop, Win32 host): after 10 seconds the process is alive, MainWindowHandle is 0, and the only line in the log is OnLaunched entered. No unhandled-exception handler fired.

Expected behavior 🎯

Same as WinUI: the exception is surfaced through Application.UnhandledException, and if the handler does not set Handled = true, the process terminates.

I ran the same OnLaunched throw in a throwaway unpackaged WinAppSDK app (net10.0-windows10.0.26100). Application.UnhandledException fired with the InvalidOperationException, and the process exited with code 0xC000027B within the 10 seconds.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Create an app from the Uno template with the Skia renderer and the net10.0-desktop head.
  2. Replace OnLaunched in App.xaml.cs with:
public App()
{
    InitializeComponent();
    UnhandledException += (_, e) => Log("Application.UnhandledException");
    AppDomain.CurrentDomain.UnhandledException += (_, e) => Log("AppDomain.UnhandledException");
    TaskScheduler.UnobservedTaskException += (_, e) => Log("UnobservedTaskException");
}

private static void Log(string m) =>
    File.AppendAllText(Path.Combine(AppContext.BaseDirectory, "repro.log"), m + Environment.NewLine);

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
    Log("OnLaunched entered");
    throw new InvalidOperationException("boom from OnLaunched");
}
  1. Build in Release and run the Windows build of the app (dotnet build -c Release, then start App.exe).
  2. Wait about 10 seconds.
  3. The process is still running with no window. repro.log only contains OnLaunched entered.

Workaround 🛠️

Wrap the body of OnLaunched in a try/catch and log or Environment.FailFast yourself.

Renderer 🎨

  • Skia

Uno.Sdk version (and other relevant versions) 📦

Uno.WinUI 7.0.0-dev.1435 (Uno.Sdk 7.0.0-dev.25). Also seen on Uno.Sdk 6.7.30 and 7.0.0-dev.1429.

Affected platforms 📱💻🖥️

Skia (Desktop, Win32 host). Other Skia hosts, and the other heads, were not checked. WebAssembly is covered separately by #24308.

IDE version 🧑‍💻

Command line, .NET SDK 10.0.401

Anything else we need to know? 💬

Root cause by code inspection on 7a2214115d5c9c798515de156ab32a5c8972ef36. Three things combine:

  1. Win32Host.RunLoop schedules Application.Start(...) (which synchronously calls OnLaunched) onto the Win32 event loop as a regular dispatcher action (Win32Host.cs#L165). Application.InvokeOnLaunched has no try/catch around OnLaunched (Application.cs#L878).
  2. Win32EventLoop.WndProc wraps every dispatched action in a catch (Exception e) that only calls LogError (Win32EventLoop.cs#L72-L93). Logging is off by default, so nothing is visible, and Application.UnhandledException is not raised.
  3. The run loop only exits once _allWindowsClosed is set (Win32Host.cs#L184), which never happens when no window was ever created, so the loop idles in GetMessage forever.

So the same swallowing applies to any exception thrown from a dispatched action, not only OnLaunched. Suggested direction: in the WndProc catch, raise Application.UnhandledException and terminate the process if it is not handled.

Related: #19197 (do not swallow exceptions on pointer input and dispatcher, same family), #24308 (the WebAssembly flavor of the same symptom), #24298 (startup aborts with no diagnostic).

Activity

  1. added
    kind/bug
    triage/untriaged
    project/navigation-lifecycle 🧬
    difficulty/medium 🤔
    platform/win32 🪟
    on Oct 2, 2026
  2. MartinZikmund commented on Oct 5, 2026

    @MartinZikmund
    MemberAuthor

    Additional data points, re-checked on bfc8dffd7fe9062160edbc7562f34955e88f57b2 (master) with a minimal blank app on Uno.Sdk 7.0.0-dev.55, net10.0-desktop, Win32 host. The app logs Application.UnhandledException, AppDomain.UnhandledException and FirstChanceException to a file.

    Where the exception is thrown Process after 10 s Unhandled-exception events
    Nothing thrown (control) alive, window shown n/a
    OnLaunched alive, no window none raised (only the first-chance exception is logged)
    App constructor alive, no window none raised
    A static initializer reached during startup (generated GlobalStaticResources -> TypeInitializationException wrapping a FileNotFoundException) alive, no window, App ctor never runs none raised

    So the swallow is not specific to OnLaunched. Win32Host.RunLoop also builds the app (_appBuilder()) inside the same scheduled action, so any failure while constructing the app or running type initializers on that path ends up in the WndProc catch that only logs. stdout and stderr stayed empty (0 bytes) in the failing runs.

    Confirmed only on the Win32 host. I did not run the other Skia hosts. The WinUI behavior (UnhandledException, then process termination) is as already described above.

  3. added
    7.0
    on Oct 14, 2026
  4. removed
    triage/untriaged
    7.0
    on Oct 29, 2026
  5. self-assigned this
    on Nov 1, 2026
  6. added 4 commits that reference this issue on Nov 3, 2026
    78b2c3b
    a80e099
    07dec00
    d13cbf4
  7. MartinZikmund commented on Nov 6, 2026

    @MartinZikmund
    MemberAuthor

    A failed graphics backend start takes this same path, because negotiation runs inside new Window() in OnLaunched. That gives a repro with no throw in app code and no GPU dependency:

    UnoPlatformHostBuilder.Create()
        .App(() => new App())
        .UseWin32(w => w.DisableRenderingBackends(
            Win32RenderingBackend.Vulkan, Win32RenderingBackend.OpenGL, Win32RenderingBackend.Software))
        .Build()
        .Run();

    On Uno.Sdk 7.0.0-dev.175 (Uno.WinUI 7.1.0-dev.21), a Skia app with an ordinary OnLaunched that creates a Window is still running with no window after 12 seconds. Application.UnhandledException isn't raised. With a logger configured, the only trace is Exception in WndProc with No registered backend could initialize on this host.

    A WebGPU-only app behaved the same way when webgpu.dll was missing, and when wgpu returned no device.

    From reading #25929, this exception reaches its new catch in RunLoop, so that fix should cover this case too. I haven't run it with that PR.

  8. added a commit that references this issue on Nov 9, 2026
    346e1dc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/skia/lifecycle ✏️difficulty/medium 🤔kind/bugplatform/win32 🪟project/navigation-lifecycle 🧬

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions