title: Intermittent crash after UIImagePickerController with camera
body: <p>We have an app that is working stable, but occasionally users report that they get crashes when they use the function to take a picture with the camera.</p>
  
  <p>The problem is that the crash seems to happen just when <code>UIImagePickerController</code> is closed and the control is returned to the app.</p>
  
  <p>We set the delegate when the pickerController is loaded </p>
  
  <pre><code>- (IBAction)popupShootPhoto:(id)sender {
      // Detect if camera is available, otherwise exit
      if (![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
      {
          return;
      }
  
      UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
      pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
      pickerController.delegate = self;
      [self presentViewController:pickerController animated:YES completion:nil];
  }
  </code></pre>
  
  <p>When the app resumes, the photo is normally processed in the callback to the regular delegate method.</p>
  
  <pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  </code></pre>
  
  <p>The problem is that we cannot reproduce the problem. All we have to work from are the crash logs that we have available in the organizer from the devices.</p>
  
  <p>This is what the crashing thread typically look like, there are no references to our own code, so we have not much to work from. </p>
  
  <p><a href="https://i.stack.imgur.com/SeZot.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SeZot.jpg" alt="enter image description here"></a></p>
  
  <p>Can anyone suggest an approach to resolve or troubleshoot problems like this? The problem has been the same on both iOS 9 and still exists on iOS 10.</p>