fix(ios): prevent duplicate cancel callbacks in image picker - #11
Closed
kosmydel wants to merge 1 commit into
Closed
fix(ios): prevent duplicate cancel callbacks in image picker#11kosmydel wants to merge 1 commit into
kosmydel wants to merge 1 commit into
Conversation
…icker cancel delegates
There was a problem hiding this comment.
Pull request overview
This PR updates the iOS implementation of react-native-image-picker to prevent duplicate “cancel” callbacks (and the resulting crash) when the picker is dismissed while async photo loading is still in-flight.
Changes:
- Introduces a
photoSelectedflag to ensure the callback is only consumed once per picker session. - Adds early-return guards in
imagePickerControllerDidCancel:andpresentationControllerDidDismiss:to avoid duplicate cancel emissions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I don't have a repro; this is a bit of a guess at a fix for the Sentry issue
AI-driven repro scenario when it could happen:
The race requires the async photo load to still be in-flight when the dismiss fires — it won't happen on fast local photos.
NOBRIDGEmode).dispatch_group_notifyblock fires afterpresentationControllerDidDismiss:has already consumed the callback → crash.presentationControllerDidDismiss:setsphotoSelected = YES; the notify block early-returns → no crash.