Repository navigation
Description
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) 🔬
- Create an app from the Uno template with the Skia renderer and the
net10.0-desktophead. - Replace
OnLaunchedinApp.xaml.cswith:
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");
}- Build in Release and run the Windows build of the app (
dotnet build -c Release, then startApp.exe). - Wait about 10 seconds.
- The process is still running with no window.
repro.logonly containsOnLaunched 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:
Win32Host.RunLoopschedulesApplication.Start(...)(which synchronously callsOnLaunched) onto the Win32 event loop as a regular dispatcher action (Win32Host.cs#L165).Application.InvokeOnLaunchedhas no try/catch aroundOnLaunched(Application.cs#L878).Win32EventLoop.WndProcwraps every dispatched action in acatch (Exception e)that only callsLogError(Win32EventLoop.cs#L72-L93). Logging is off by default, so nothing is visible, andApplication.UnhandledExceptionis not raised.- The run loop only exits once
_allWindowsClosedis set (Win32Host.cs#L184), which never happens when no window was ever created, so the loop idles inGetMessageforever.
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
MartinZikmund commentedon Oct 5, 2026
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 logsApplication.UnhandledException,AppDomain.UnhandledExceptionandFirstChanceExceptionto a file.OnLaunchedAppconstructorGlobalStaticResources->TypeInitializationExceptionwrapping aFileNotFoundException)Appctor never runsSo the swallow is not specific to
OnLaunched.Win32Host.RunLoopalso 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 theWndProccatch 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.
fix(win32): Surface exceptions thrown while starting the app
fix(win32): Surface exceptions thrown while starting the app
fix(win32): Surface exceptions thrown while starting the app
fix(win32): Surface exceptions thrown while starting the app
MartinZikmund commentedon Nov 6, 2026
A failed graphics backend start takes this same path, because negotiation runs inside
new Window()inOnLaunched. That gives a repro with no throw in app code and no GPU dependency:On
Uno.Sdk7.0.0-dev.175(Uno.WinUI7.1.0-dev.21), a Skia app with an ordinaryOnLaunchedthat creates aWindowis still running with no window after 12 seconds.Application.UnhandledExceptionisn't raised. With a logger configured, the only trace isException in WndProcwithNo registered backend could initialize on this host.A WebGPU-only app behaved the same way when
webgpu.dllwas 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.fix(win32): Surface exceptions thrown while starting the app