UIImagePickerController with flash on crashes when phone is locked during -takePicture

Originator:curtis.duhn
Number:rdar://28108858 Date Originated:08/31/2016
Status:Open Resolved:
Product:UIKit Product Version:iOS 9.3.5. I have Crashlytics reports for this on iOS 8, 9, and 10.
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
My app uses a UIImagePickerController with a custom cameraOverlayView that has a shutter button and flash button to toggle between On/Off/Auto. When the flash is on (picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn), and the user locks their phone with the power button while a picture is being taken (i.e. immediately after -takePicture is called), the UIImagePickerController crashes. See the attached crash report.

Steps to Reproduce:
1. Present UIImagePickerController with shutter button on custom overlay and cameraFlashMode = UIImagePickerControllerCameraFlashModeOn.
2. Push shutter button.
3. Immediately (before or during the flash), hit the iPhone's power button to lock it.



Expected Results:
No crash. Ideally finish taking the picture and call imagePickerController:didFinishPickingMediaWithInfo: on the delegate.

Actual Results:
The UIImagePickerController crashes with:

FatalException: NSInvalidArgumentException
*** setObjectForKey: object cannot be nil (key: UIImagePickerControllerOriginalImage)

This happens inside inside __CreateInfoForImage, called from PLNotifyImagePickerOfImageAvailability.

Notes:
I was also able to replicate this by dismissing the UIImagePickerController via the app's UI rather than hitting the power button. I disabled user interaction in the app while the picture is being taken to prevent that scenario, but I can't disable the power button.

I tried changing my settings to require a passcode after one minute rather than immediately, thinking maybe this had something to do with data protection, but I was still able to replicate the crash reliably.

Configuration:
iPhone 6s, 64GB. AT&T. I also have Crashlytics reports for this on other iPhone models. No iPads, but that might be a coincidence.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!