Repository navigation
fix(win32): Surface exceptions thrown while starting the app - #25929
ramezgerges merged 3 commits into
Conversation
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 242901 found UI Test snapshots differences: Details
|
2709f74 to
78b2c3b
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 243335 found UI Test snapshots differences: Details
|
|
@Mergifyio backport release/stable/7.0 |
✅ Backports have been createdDetails
|
78b2c3b to
a80e099
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 243695 found UI Test snapshots differences: Details
|
Xiaoy312
left a comment
There was a problem hiding this comment.
Approving: the synchronous fix is correct. Capturing the startup failure and rethrowing it on the loop thread after RunOnce() is the right way around the [UnmanagedCallersOnly] WndProc, and I checked that no other host now raises Application.UnhandledException twice (iOS starts outside any try, Android and WASM log and rethrow).
A few non-blocking points; the inline comments have the code-level ones.
async void OnLaunchedis still not covered (inline onApplication.cs). The recommended template uses that shape, so most new apps keep the windowless hang. Please either handle it or name it in the description's "Not covered" section.- Behaviour change for existing Win32 apps: an exception thrown from
OnLaunchedafter the window is activated used to be logged while the app kept running; now it terminates the process. That matches WinUI and is the point of the fix, but it's observable, so it's worth a release-note line (the "NO breaking changes" box is debatable). Handledparity: the issue only checked the unhandled case on WinAppSDK, and the validation tables are Uno-only. Either check theHandled = truecase on WinUI or soften the "as in WinUI" claim in the commit message.
CI: none of the 8 red jobs come from this change. The Android Skia 0/4, Linux Skia/WebGPU (When_Stream_Load_Superseded_After_Decode...) and iOS 0 (When_ShowAsMonochrome_Toggled_False_To_True...) failures also occur on master, and the NativeAOT build fails on an NU1903 advisory for Microsoft.DotNet.ILCompiler. The Framebuffer job hung in When_Animation_With_Brush_Transition and was cancelled; it passed in the last 29 PR builds, so a re-run should clear it.
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 244041 found UI Test snapshots differences: Details
|
273a223 to
3f1ffb5
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 244085 found UI Test snapshots differences: Details
|
3f1ffb5 to
3c8c69c
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 244375 found UI Test snapshots differences: Details
|
3c8c69c to
22d9dde
Compare
As in WinUI, the exception propagates unless a handler sets Handled. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The event loop only logged them, and with no window it never exited (fixes unoplatform#24930). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 244916 found UI Test snapshots differences: Details
|
|
This pull request is merged. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 245219 found UI Test snapshots differences: Details
|
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 246900 found UI Test snapshots differences: Details
|
GitHub Issue: closes #24930
PR Type:
🐞 Bugfix
What changed? 🚀
On the Win32 host, an exception thrown while the app starts (from
OnLaunched, theAppconstructor or a static initializer reached from it) was swallowed. The process stayed alive with no window, and neitherApplication.UnhandledExceptionnorAppDomain.UnhandledExceptionwas raised.Cause.
Win32Host.RunLooprunsApplication.Startas an action on the Win32 message loop.Win32EventLoop.WndProccatches whatever an action throws and only logs it, which writes nothing without a configured logger. The loop exits only once every window has closed, so with no window it waits inGetMessageforever. The X11 and macOS hosts let the same exception propagate.This is the Win32 counterpart of #24308, fixed for WebAssembly in #25859. Both now follow the same pattern: the host captures the startup failure and rethrows it from
RunLoop, sohost.Run()/RunAsync()fails.Fix
Application.InvokeOnLaunched(all hosts): whenOnLaunchedthrows,Application.UnhandledExceptionis raised. As in WinUI, the exception propagates unless a handler setsHandled. No host raised this event forOnLaunchedbefore. It is a plain catch-and-rethrow, so the handler runs afterOnLaunchedhas unwound, and the original stack is kept.Win32Host.RunLoop: the startup action catches whatApplication.Startthrows, and the loop rethrows it (ExceptionDispatchInfo) after the pass that ran it.host.Run()then throws inMain, and the process terminates withAppDomain.UnhandledException. A secondary-ALC app started on an already-running loop keeps the previous log-only behavior, so one guest app failing to start can't take down the host app.Effect on WebAssembly:
InvokeOnLaunchedruns inside #25859's deferred launch, so WebAssembly now raisesApplication.UnhandledExceptionbefore faultingRunAsync. If a handler setsHandled, it no longer faults, matching WinUI and Win32.Not covered: exceptions from dispatched work after startup are still only logged (
NativeDispatcher.RunAction) on every platform. That is #19197.Validation
Unit tests: new
Given_Application_OnLaunched. It builds an app whoseOnLaunchedthrows in a secondary ALC, and callsInvokeOnLaunched.Both fail without the change and pass with it. They also pass alongside
Given_UnitTestUIThreadandGiven_AlcCacheSweep.Win32, runtime: a blank
net10.0-desktopapp onUno.Sdk 7.0.0-dev.127(Uno7.0.0-dev.2526), with this branch'sUno.UI.dllandUno.UI.Runtime.Win32.dllswapped in. Each case checked 10 s after launch:OnLaunchedApplication.UnhandledException, thenAppDomain.UnhandledException, exit0xE0434352OnLaunched, handler setsHandledApplication.UnhandledException, keeps runningAppconstructorAppDomain.UnhandledException, exit0xE0434352WebAssembly, runtime: SamplesApp published from a clean build and run in headless Edge, with temporary hooks (not committed) that throw from
OnLaunchedand log the event:Application.UnhandledException, then "App failed to initialize", andRunAsyncfaultsfail:log entriesHandledApplication.UnhandledException; nothing faultsTwo other runs failed in JavaScript before the app code ran (
window.setImmediate is not a function, and once nothing loaded). The same load flake showed up while validating #25859, so they're excluded.Compile:
Uno.UI.Runtime.Win32andUno.UIbuild with analyzers on, with no warnings in the changed files.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code