-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Conversation
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -129,7 +129,9 @@ - (void)imagePickerController:(UIImagePickerController *)picker | |||
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; | |||
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; | |||
[_imagePickerController dismissViewControllerAnimated:YES completion:nil]; | |||
|
|||
if (!_result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets mention in a comment that dismissViewControllerAnimated
doesn't immediately prevents further didFinishPickingMediaWithInfo
invocations.
Awesome, thank you so much! I literally had this exact same bug. Will try to see if it works now. |
Pardon my naivety....but if I simply upgrade my flutter plugins, will this solution be there too? |
If you look at the 'versions' of the image_picker plugin on pub (https://pub.dartlang.org/packages/image_picker#-versions-tab-) you can see that they published a new version today. I've tested it and the issue has gone away. |
Thanks Will! |
Fix ImagePicker Crash on IOS by checking safe guarding _result to be not nil. The method dismissViewControllerAnimated does not immediately prevent further didFinishPickingMediaWithInfo invocations. So the code in the delegate method get triggered multiple times if user taps multiple times. The crash is caused because the _result block is nil and gets called again. By safe guarding it, the code will only be triggered once and will not cause crash. Another way to fix the crash would be put the code handling selection inside the completion handler inside the dismissViewControllerAnimated:completion method. This will cause a bit delay on user experience since the completion handler is called after dismissing view controller animation finishes. So the fix provided in this PR is favored.
This reverts commit 63f0589.
@cyanglaz still reproduce in version 0.6.5+1 2020-04-21 18:10:06.706981+0400 Runner[3369:1008611] CGImageSourceCreateWithData:3273: *** ERROR: CGImageSourceCreateWithData: data is nil |
My iOS app crashes when I try to upload a file. It was working just fine before I upgraded image_picker from version ^0.6.6+4 to ^0.7.2+1. Thoughts?
|
While uploading images from the gallery in IOS device getting this error.
|
fix an IOS crash when the image picker got tapped multiple times. flutter/flutter#20214
When the image in the imagePicker was tapped multiple times, the delegate method didFinishPickingMediaWithInfo gets called multiple times. _result is set to nil at the end of the didFinishPickingMediaWithInfo call.
When the second didFinishPickingMediaWithInfo gets triggered, because _result is nil, crash is caused.
We can also fix it by putting the code after selection inside the completion handler, it will cause a little delay in image showing up after completion. So directly checking if _result is nil and stop the process would be more efficient.