Repository navigation
feat: Opt-in surfacing of input, dispatcher, and resource-lookup errors - #23281
MartinZikmund wants to merge 31 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds opt-in feature flags to surface previously swallowed input, dispatcher, and unresolved resource errors, aligning Uno behavior more closely with WinUI while keeping defaults unchanged for apps. It also implements real XamlParseException types and enables stricter exception propagation in SamplesApp for development.
Changes:
- Added input and dispatcher exception propagation flags and wiring across routed events, pointer handling, and native dispatcher paths.
- Added unresolved resource throwing through
ResourceResolution.ThrowOnUnresolvedResource. - Added runtime tests and real
Microsoft.UI.Xaml.Markup/Windows.UI.Xaml.MarkupXamlParseExceptionimplementations.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Uno.UI/UI/Xaml/UIElement.RoutedEvents.cs |
Routes SafeRaiseEvent/SafeRaiseTunnelingEvent exceptions through unhandled exception handling when enabled. |
src/Uno.UI/UI/Xaml/UIElement.Pointers.UIKit.cs |
Applies input exception propagation to UIKit touch handlers. |
src/Uno.UI/UI/Xaml/UIElement.Pointers.cs |
Applies input exception propagation to pointer event raising. |
src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.Managed.cs |
Propagates top-level managed pointer failures after recovery when enabled. |
src/Uno.UI/UI/Xaml/DependencyObjectStore.Theming.cs |
Detects unresolved resource bindings and throws XamlParseException when configured. |
src/Uno.UI/UI/Xaml/Application.cs |
Adds fatal unhandled exception raising that preserves stack traces. |
src/Uno.UI/FeatureConfiguration.cs |
Adds public opt-in flags for input, dispatcher, and resource resolution behavior. |
src/Uno.UI/Extensions/ApplicationExtensions.cs |
Adds helper to raise or rethrow unhandled exceptions when no app is available. |
src/Uno.UI.RuntimeTests/Tests/Uno_UI/Given_FeatureConfiguration_UnhandledExceptions.cs |
Adds runtime coverage for flag-off/on input behavior, dispatcher swallow behavior, and unresolved resources. |
src/Uno.UI.Dispatching/Native/NativeDispatcher.cs |
Adds dispatcher exception propagation flag and bypasses catch/log path when enabled. |
src/Uno.UI.Dispatching/Native/NativeDispatcher.Android.cs |
Applies dispatcher exception propagation to Android choreographer animation dispatch. |
src/Uno.Foundation/Windows.UI.Xaml.Markup/XamlParseException.cs |
Adds real Windows namespace XamlParseException constructors. |
src/Uno.Foundation/Microsoft.UI.Xaml.Markup/XamlParseException.cs |
Adds real Microsoft namespace XamlParseException constructors. |
src/Uno.Foundation/Generated/2.0.0.0/Windows.UI.Xaml.Markup/XamlParseException.cs |
Updates generated partial to skip manually implemented constructors. |
src/Uno.Foundation/Generated/2.0.0.0/Microsoft.UI.Xaml.Markup/XamlParseException.cs |
Updates generated partial to skip manually implemented constructors. |
src/SamplesApp/SamplesApp.Shared/App.xaml.cs |
Enables input and dispatcher exception propagation in SamplesApp development builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
222c032 to
debbec4
Compare
dcd5eb6 to
f14a80e
Compare
|
Claude finished @MartinZikmund's task in 6m 44s —— View job PR Review
SummaryThe feature design is solid: opt-in flags with sane defaults, clean High (correctness / must-fix)
Medium (design / needs decision)
Low (housekeeping)
What looks good:
|
WinAppSDK sync generator drift detected on
|
|
Claude finished @MartinZikmund's task in 6m 31s —— View job PR Review
SummaryThe overall design is sound: opt-in flags with sane defaults, clean 2 high-severity correctness issues remain open in the dispatcher changes:
1 medium documentation issue:
1 low / style issue:
What looks good:
|
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtysHhpUBtfo8zye9x9
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNtysHhpUBtfo8zye9x9
|
Claude finished @MartinZikmund's task in 15s —— View job PR ReviewVerdict: ship. I found no new issues. This was a code-inspection review only. I did not build or run tests, and the clone has no merge base with Earlier open items, checked against the current head:
Still open, not blocking:
|
🤖 Addressed PR comments up to this point@morning4coffe-dev, on your changes-requested review:
Review threads: 23 replied and resolved. The |
|
The build 248028 found UI Test snapshots differences: Details
|
GitHub Issue: closes #19197
PR Type:
✨ Feature
What changed? 🚀
Current behavior
Three classes of bugs in Uno-based apps look like "the UI did nothing" because the framework silently swallows the exception:
RaisePointerEvent,SafeRaiseEvent,SafeRaiseTunnelingEvent,InputManager.OnTopLevelFatalError) are caught and logged.NativeDispatcher.RunAction,DispatchItemsToChoreographer) are caught and logged.{StaticResource Foo}/{ThemeResource Foo}lookups that resolve to nothing only log"Couldn't statically resolve resource Foo"; the property silently stays at its default.WinUI does the opposite in all three cases: it raises
Application.UnhandledExceptionandFAIL_FASTs on input failures, lets dispatcher work items propagate to the platform pump, and throwsMicrosoft.UI.Xaml.Markup.XamlParseException(HRESULTE_FAIL/AG_E_PARSER_FAILED_RESOURCE_FIND) on missing resources.New behavior
Three opt-in feature flags, default off (no behavior change for existing apps):
FeatureConfiguration.UnhandledExceptionHandling.PropagateInputExceptionsApplication.UnhandledException. If the app marks itHandled = true, the event keeps routing to the remaining handlers and ancestors (WinUI:DXamlCore::FireEventreports,CEventManagerkeeps raising); otherwise it is re-thrown. Each exception is reported once, even when it unwinds through several catch sites.FeatureConfiguration.UnhandledExceptionHandling.PropagateDispatcherExceptionsNativeDispatcher.RunActionandDispatchItemsToChoreographerraiseApplication.UnhandledException; if unhandled, the exception propagates to the platform message pump (WinUI:FinalUnhandledErrorDetected→ErrorHelper::ProcessUnhandledError→FAIL_FAST).FeatureConfiguration.ResourceResolution.ThrowOnUnresolvedResourceAG_E_PARSER_FAILED_RESOURCE_FIND. A{StaticResource}or{ThemeResource}still unresolved once its owner is loaded throwsXamlParseException(WinUI throws at parse; Uno resolves these later). A{ThemeResource}whose pinned dictionary and the global theme resources lack the key for a newly applied theme throwsCOMException0x800F1000from the theme change (e.g. theRequestedThemesetter), without falling back to application resources. Behaviour verified against a WinAppSDK 2.5.1 probe.Supporting changes:
Application.RaiseUnhandledExceptionhelper +RaiseUnhandledExceptionOrThrowextension. ExistingRaiseRecoverableUnhandledExceptionis unchanged and still used by animations, drag/drop, etc.Microsoft.UI.Xaml.Markup.XamlParseException(andWindows.UI.Xaml.Markup.XamlParseException) promoted from[NotImplemented]stub to a real exception type with the three standard constructors.StyleHelper.UseUwpStyles(), which removes the Fluent resources from a live app (a WinUI crash too) and now suspends the flag for its scope.Latent bugs surfaced (and fixed) by turning the flags on
Flipping
PropagateInputExceptions/PropagateDispatcherExceptionson in SamplesApp immediately made two previously-swallowed failures visible, so they are fixed here as well — they are the proof the flags do what they claim:Windows.Globalization.Calendar—FirstYearInThisEra/LastYearInThisErareturned absolute years instead of era-years, which threw once the exception stopped being swallowed (fix(globalization): Express First/LastYearInThisEra as era-years).ItemsViewTests— two tests exerciseLinedFlowLayout, which is not implemented in Uno (see [Repeater] Port LinedFlowLayout (new layout) #22909); they previously "passed" on a swallowed exception and are now[Ignore]d like the three sibling LinedFlowLayout tests already in that file.The unresolved-resource throw is done in the public
UpdateResourceBindingsmethod after the defensiveInnerUpdateResourceBindingswrapper returns, so nocatch (XamlParseException) throw;passthroughs are needed in unrelated swallow sites.PR Checklist ✅
Given_FeatureConfiguration_UnhandledExceptions(15 tests covering both flag states for input, dispatcher, and resource lookup, including handled-exception routing, single reporting, theme-switch misses and HighContrast keys served by the global theme).Screenshots Compare Test Runresults — N/A (no visual changes).