Skip to content

Uno Platform Skia Desktop: UnhandledException event doesn't fire for async/dispatcher callbacks #53

@TimGels

Description

@TimGels

Summary

During App.xaml.cs refactoring, discovered that Application.UnhandledException does not reliably catch exceptions on Uno Platform Skia Desktop targets. This is a known Uno Platform limitation (issue #6569).

Affected Areas

Any code that throws exceptions from:

  • DispatcherQueue.TryEnqueue callbacks
  • DispatcherQueueTimer.Tick handlers
  • Async event handlers (async void)

Current Workaround

Critical event handlers should wrap code in try-catch and manually send ExceptionDialogMessage:

someHandler += (s, e) =>
{
    try
    {
        // Code that might throw
    }
    catch (Exception ex)
    {
        WeakReferenceMessenger.Default.Send(new ExceptionDialogMessage(
            Title: "Error",
            Summary: "An error occurred.",
            Exception: ex,
            Timestamp: DateTimeOffset.Now));
    }
};

What Still Works

  • Application.UnhandledException - fires for some synchronous UI exceptions
  • AppDomain.CurrentDomain.UnhandledException - catches fatal exceptions (app still crashes)
  • TaskScheduler.UnobservedTaskException - fires on GC for unobserved task exceptions

References

  • Uno Platform issue #6569 - Exception handling inconsistencies (still open for Skia targets)
  • Uno.Sdk version: 6.5.0-dev.100

Metadata

Metadata

Assignees

No one assigned

    Labels

    skiauno-platformIssues related to Uno Platform framework behavior. May require upstream fix.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions