Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid async void in SKXamlCanvas. #2720

Merged
merged 1 commit into from Jan 31, 2024

Conversation

lindexi
Copy link
Contributor

@lindexi lindexi commented Jan 19, 2024

Description of Change

The async void will terminate here. And we can ignore the Dispatcher.RunAsync result and we can receive the exception from TaskScheduler.UnobservedTaskException.

See dotnet/runtime#76367

Bugs Fixed

API Changes

None.

Behavioral Changes

In the original behavior, if the SKXamlCanvas.Invalidate method is called in the background thread, it will be scheduled back to the main thread through the Dispatcher.RunAsync method. However, if any business code throws an exception in the PaintSurface event, it will cause the process to crash.

After the modification, if business code throws an exception in the PaintSurface event, the exception will be received in TaskScheduler.UnobservedTaskException, but the process will still be safe. This is very important for client applications as it can greatly enhance stability.

Required skia PR

None.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Merged related skia PRs
  • Changes adhere to coding standard
  • Updated documentation

The async void will terminate here. And we can ignore the Dispatcher.RunAsync result and we can receive the exception from TaskScheduler.UnobservedTaskException.

See dotnet/runtime#76367
@mattleibow mattleibow added the backport/release/2.x Backport this PR to release/2.x label Jan 31, 2024
@mattleibow mattleibow merged commit 08c711c into mono:main Jan 31, 2024
2 of 3 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 31, 2024
The async void will terminate here. And we can ignore the Dispatcher.RunAsync result and we can receive the exception from TaskScheduler.UnobservedTaskException.

See dotnet/runtime#76367

(cherry picked from commit 08c711c)
mattleibow pushed a commit that referenced this pull request Jan 31, 2024
The async void will terminate here. And we can ignore the Dispatcher.RunAsync result and we can receive the exception from TaskScheduler.UnobservedTaskException.

See dotnet/runtime#76367

(cherry picked from commit 08c711c)

Co-authored-by: lindexi <lindexi@users.noreply.github.com>
@lindexi lindexi deleted the t/lindexi/SKXamlCanvas branch March 22, 2024 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/release/2.x Backport this PR to release/2.x
Projects
None yet
2 participants