Bug 46110 - UIImagePickerController| Crash | iOS 10
Summary: UIImagePickerController| Crash | iOS 10
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 10.0 (iOS10)
Hardware: Macintosh Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-10-28 04:26 UTC by Jeff
Modified: 2016-11-03 06:47 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
sample app (14.54 KB, application/x-zip-compressed)
2016-10-28 04:26 UTC, Jeff
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Jeff 2016-10-28 04:26:38 UTC
Created attachment 18256 [details]
sample app

the app will crash if you take around 200 photos on iPad mini2, 400 photos on iPad air 2 (both on iOS10). 

i have upload the sample application. 


----
=== Xamarin Studio Enterprise ===

Version 6.1.1 (build 15)
Installation UUID: be76f971-1aa2-4867-bc00-f06c373e99d7
Runtime:
	Mono 4.6.1 (mono-4.6.0-branch-c8sr0/ef43c15) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406010005

=== NuGet ===

Version: 3.4.3.0

=== Xamarin.Profiler ===

Version: 0.17.0.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.0 (11246)
Build 8A218a

=== Xamarin.iOS ===

Version: 10.0.1.10 (Visual Studio Enterprise)
Hash: ad1cd42
Branch: cycle8-sr0-xi
Build date: 2016-10-03 15:18:44-0400

=== Xamarin.Android ===

Version: 6.1.2.21 (Visual Studio Enterprise)
Android SDK: Not found

=== Xamarin Android Player ===

Not Installed

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 601010015
Git revision: fa52f02641726146e2589ed86ec4097fbe101888
Build date: 2016-09-22 08:03:02-04
Xamarin addins: 75d65712af93d54dc39ae4c42b21dfa574859fd6
Build lane: monodevelop-lion-cycle8-sr0

=== Operating System ===

Mac OS X 10.11.6
Darwin Junhai-rmbp.lan 15.6.0 Darwin Kernel Version 15.6.0
    Thu Jun 23 18:25:34 PDT 2016
    root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
Comment 1 Vincent Dondain [MSFT] 2016-10-31 10:56:25 UTC
Hi Jeff,

Profiling shows no evidence of a leak in managed code.

I've done some digging on this issue and the result is that native code seems to be leaking or it's caching too much stuff and eventually crashes. Maybe it relies on memory warning to empty the cache which it can't do when you automate taking pictures.

They might not have expected taking hundreds of pictures without destroying the `UIImagePickerController`.

In any case I managed to reproduce this issue with a quick Objective C test case and opened a radar about it.

I'm gonna close this issue as there's nothing we can do about it, I hope Apple fix it. In the meantime I'd recommend not automating taking pictures, likely when you use it manually, it has time to catch memory warnings, I've not been able to make it crash manually.

Sadly I can't share a radar link so let me paste its information here:

*******************************************

**Area:**
UIKit

**Summary:**
We are trying to automate taking pictures and found out that iOS (UIImagePickerController) is likely leaking or it is relying on memory warnings to empty its cash, preventing automation.

**Steps to Reproduce:**
Here's the code to reproduce. Note that I've attached a test case with this bug.

```
- (IBAction)ButtonToPush:(id)sender {
    UIButton *shutter = [[UIButton alloc] init];
    
    vc = [[UIImagePickerController alloc] init];
    [[vc view] setUserInteractionEnabled:YES];
    [vc setMediaTypes:@[@"public.image"]];
    [vc setSourceType:UIImagePickerControllerSourceTypeCamera];
    [vc setCameraDevice:UIImagePickerControllerCameraDeviceRear];
    [vc setCameraCaptureMode:UIImagePickerControllerCameraCaptureModePhoto];
    [vc setCameraFlashMode:UIImagePickerControllerCameraFlashModeOff];
    [vc setAllowsEditing:NO];
    [vc setShowsCameraControls:NO];
    
    [shutter setFrame:CGRectMake(0, 0, 100, 100)];
    [shutter setTitle:@"Take" forState:UIControlStateNormal];
    [shutter addTarget:self action:@selector(shutterButton_TouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
    
    [vc setCameraOverlayView:shutter];
    [vc setDelegate:self];
    
    [self presentViewController:vc animated:YES completion:nil];
}

- (void)shutterButton_TouchUpInside:(UIButton*)button
{
    [NSTimer scheduledTimerWithTimeInterval:.3 repeats:YES block:^(NSTimer * _Nonnull timer) {
        [vc takePicture];
        NSLog(@"Took picture %d", count++);
    }];
}
```

**Expected Results:**
We should be able to take unlimited pictures.

**Actual Results:**
Crashed around 400 pics.

**Version:**
10.1

**Configuration:**
iPhone 7 32GB

**Attachments:**
'CameraTest.zip' was successfully uploaded.

*******************************************
Comment 2 Vincent Dondain [MSFT] 2016-10-31 10:57:04 UTC
Here's the attached native test case: https://www.dropbox.com/s/9ihi9n3guc919bx/CameraTestNative.zip?dl=0
Comment 3 Jeff 2016-11-03 06:47:01 UTC
Thanks you Vincent.