Avoid async void in SKXamlCanvas. #2720
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
SKXamlCanvas
- Process Crashes when Exceptions are Thrown inPaintSurface
Event Triggered by Background Thread unoplatform/uno#15123API 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 theDispatcher.RunAsync
method. However, if any business code throws an exception in thePaintSurface
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