Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Essentials/src/MediaPicker/MediaPicker.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,14 @@ class PhotoPickerDelegate : PHPickerViewControllerDelegate

public override void DidFinishPicking(PHPickerViewController picker, PHPickerResult[] results)
{
// Null out the presentation delegate handler before dismiss to prevent a GC race condition.
// Without this, Dispose() on PhotoPickerPresentationControllerDelegate can fire tcs.TrySetResult([])
// while the async CompletedHandler is still processing (especially slow for HEIC transcoding).
if (picker.PresentationController?.Delegate is PhotoPickerPresentationControllerDelegate pd)
{
pd.Handler = null;
}

var captured = results?.Length > 0 ? results : [];
picker.DismissViewController(true, () => CompletedHandler?.Invoke(captured));
}
Expand Down
Loading