uno: Exception handling inconsistencies
Current behavior
See attached project. The MainPage contains 2 buttons:
- “Click Me - Sync!” -> This one does
throw new Exception();directly in the event handler. - “Click Me - Async!” -> This one first does
await Task.Delay(1000);and then the samethrow new Exception();
In App.xaml.cs, I attached a handler to App.UnhandledException. Running on UWP shows me the MessageDialog for both buttons, the way I would expect it.
Expected behavior
I tested the following platforms:
Skia / WPF:
- Sync button: the exception is printed to the console, but the event doesn’t trigger.
- Async button: the exception is printed to console, but the application crashes. Event doesn’t trigger
Skia / Gtk:
- Sync button: the exception is printed to the console, but the event doesn’t trigger.
- Async button: the exception is printed to console, but the event doesn’t trigger
WebAssembly:
- Sync button: the exception is printed to the console, but the event doesn’t trigger.
- Async button: the exception is printed to console, but the event doesn’t trigger
Android:
- Sync button: the exception is printed to the debug output pane, but the event doesn’t trigger.
- Async button: the exception is printed to debug output pane, but the application crashes. Event doesn’t trigger
I haven’t tested this on iOS or macOS.
How to reproduce it (as minimally and precisely as possible)
Described above.
Workaround
I could do manual error handling all over my code, but then still I’m at risk of random errors popping up.
Works on UWP/WinUI
Yes
Environment
Nuget Package:
- Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
- Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
- Uno.SourceGenerationTasks
- Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
- Other:
Nuget Package Version(s): 3.8.13
Affected platform(s):
- iOS
- Android
- WebAssembly
- WebAssembly renderers for Xamarin.Forms
- macOS
- Skia
- WPF
- GTK (Linux)
- Tizen
- Windows
- Build tasks
- Solution Templates
IDE:
- Visual Studio 2017 (version: )
- Visual Studio 2019 (version: )
- Visual Studio for Mac (version: )
- Rider Windows (version: )
- Rider macOS (version: )
- Visual Studio Code (version: )
Relevant plugins:
- Resharper (version: )
Anything else we need to know?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 1
- Comments: 21 (18 by maintainers)
I’ll start working on this, and see what I end up with. 😃
I’ll see what I can do to fix these cases. For other events, I suggest we’ll tackle them when we find them.