Skip to content

Provide a global uncaught exception handler similar to WPF and other toolkits #12040

@Therzok

Description

@Therzok

Steps to Reproduce

  1. Have any exception bubble through to the UI loop
  2. Observe the app crashes with SIGABRT
  3. By adding a try/catch around NSApplicationMain you catch the exception but the application's main loop still stops.

This can be seen with native shell implementations of VSMac.

Expected Behavior

Xamarin.Mac should provide some event to listen on for uncaught exceptions. That would allow applications to avoid crashes most of the time, by having the main loop driven by the toolkit handling them.

See the equivalent WPF API here: https://docs.microsoft.com/en-us/dotnet/api/system.windows.application.dispatcherunhandledexception?redirectedfrom=MSDN&view=net-5.0

Actual Behavior

The exception bubbles through to NSApplicationMain caller, because there is no manual RunLoop handling happening on Xamarin.Mac's side. That means, we let AppKit handle running the loop iterations, so we have no ability to get monitor for exceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThe issue or pull request is an enhancement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions