-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[image_picker] Fix image_picker Hanging After Attempting to Open Unavailable Camera on iOS Simulator #1844
Conversation
I believe the imagePickerControllerDidCancel is a delegate method in the if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
_imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
[_viewController presentViewController:_imagePickerController animated:YES completion:nil];
} else {
[[[UIAlertView alloc] initWithTitle:@"Error"
message:@"Camera not available."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
} |
A full search for the name returns no results except the declaration. As for factoring out the code you showed, what exactly do you propose? I am only passingly familiar with Objective-C. |
@chgibb no worries. So OBJC has a delegation pattern. Basically our ImagePickerPlugin conform to the UIImagePickerControllerDelegate protocol. One of the method in the protocol is imagePickerControllerDidCancel. So the iOS framework is calling |
@cyanglaz I believe that fundamentally, a result is not being returned in the event that the camera is not available. The
immediately following the "Camera not available" dialog also appears to resolve the issue. I realize that is simply the method body of the didCancel delegate, but it was my understanding that lines |
Adding self.result(nil);
self.result = nil;
_arguments = nil; makes much more sense! Do you mind to update the PR with this change? |
@cyanglaz absolutely! I will make the change on Monday and ping you again for review and approval. I appreciate the timely and kind discussion and feedback! |
Made the change @cyanglaz . |
@chadidi CI seems not happy about some formatting, do you mind reformat? |
…ailable Camera on iOS Simulator (flutter#1844)
Description
This PR resolves the description given in the title. image_picker hangs on iOS simulator after being rejected for the camera being unavailable.
Related Issues
flutter/flutter #18095 describes very similar behaviour, except with respect to the gallery and video picker.
flutter/plugins #595 introduced the
FLTImagePickerPlugin#imagePickerControllerDidCancel
method, however it is never actually called anywhere in the code base. This PR simply makes use of it.Checklist
///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?