Bug 17953 - Crash when using camera on iPad
Summary: Crash when using camera on iPad
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.0.4.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-02-22 21:48 UTC by Bob Reck
Modified: 2014-03-26 13:14 UTC (History)
5 users (show)

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


Attachments
Crash log. (33.65 KB, application/octet-stream)
2014-02-22 21:48 UTC, Bob Reck
Details
Symbolicated Crash Log from last crash. (35.63 KB, text/plain)
2014-02-22 22:14 UTC, Bob Reck
Details
Crash log from 2-24-14 at 3:59pm. (56.18 KB, application/octet-stream)
2014-02-24 16:06 UTC, Bob Reck
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:
VERIFIED FIXED

Description Bob Reck 2014-02-22 21:48:05 UTC
Created attachment 6124 [details]
Crash log.

Xamarin, 

I've been trying to figure out a problem that some of my users are having. I can't figure this out and need some expert input. In my app, I have a view where users enter information about an item and then can attach photos. When they launch the camera a photo is taken and then returned to a UIImageView on the view. This works fine on the iPhone and iPod Touch. However, I have a number of reports of crashing happening on iPads and iPad Minis. I have been able to recreate the problem on my iPad 2, but not consistently.

I have one particular user who always has the problem and I have tried all types of changes to fix the problem, but nothing has worked. This crash happens when the user's device opens the camera to take the photo. I'm starting to think it's a bug because it only happens on the iPad. But I need help determining what is causing it if it's not a bug.

I asked this particular user to get me some crash logs. I have attached the most recent one below. However, I have a feeling it's not going to help much because it's not symbolicated. (Can I get it symbolicated if it came from their device? If so, please explain how.)

Please help,
Thanks!
Bob
Comment 1 Bob Reck 2014-02-22 22:13:44 UTC
I was able to figure out how to symbolicate the crash and have attached it. Thanks.
Bob
Comment 2 Bob Reck 2014-02-22 22:14:52 UTC
Created attachment 6125 [details]
Symbolicated Crash Log from last crash.

If you can help me make some sense of this and why my app might be crashing, I'd be very grateful. Thanks!
Bob
Comment 3 Rolf Bjarne Kvinge [MSFT] 2014-02-24 04:47:19 UTC
A managed exception was thrown somewhere inside FirearmSafe.AddFirearm:

13  FirearmSafe                   	0x00518376 mono_arm_throw_exception (exceptions-arm.c:157)
[...]
17  FirearmSafe                   	0x0015c734 FirearmSafe.AddFirearm:<SaveButtonHandler>m__5 + 2580

no exception handler for this exception was found, so Xamarin.iOS terminated the app (this is normal procedure when no exception handlers are found).

Unfortunately the crash report does not give any clues as to why the exception occurred, nor any information about the exception itself. There are a couple of things you can try:

* Update to Xamarin.iOS 7.0.6 if you haven't already, and turn of LLVM in the builds you give to this customer. This will make the crash reports symbolicate better (in particular the ___lldb_unnamed_function* names will not show up anymore).
* Ask the customer to get any output to the device console (https://developer.apple.com/library/ios/qa/qa1747/_index.html) - Xamarin.iOS will print a lot of information about the exception itself here.
* Add an exception handler in FirearmSafe.AddFirearm that reports back to you (or shows the customer an error message explaining the problem).
Comment 4 Bob Reck 2014-02-24 16:03:38 UTC
Rolf, 

Thanks for the reply and you have some great things to try here. I will definitely do that. 

I just sat here for 20 minutes adding and removing and re-adding photos and finally got a crash. Here's what the console put out. I will also attache the accompanying crash log. Please help me track this down.

Thanks,
Bob


Feb 24 15:59:25 Bobs-iPad FirearmSafe[4349] <Warning>: 
	Unhandled Exception:
	0   FirearmSafe                         0x01769b13 mono_handle_exception_internal + 1886
	1   FirearmSafe                         0x017693af mono_handle_exception + 10
	2   FirearmSafe                         0x017635fb mono_arm_throw_exception + 102
	3   FirearmSafe                         0x00f2b9c4 throw_exception + 68
	4   FirearmSafe                         0x01822c94 objc_skip_type + 0
	5   FirearmSafe                         0x01812f18 monotouch_register + 0
	6   CoreFoundation                      0x30f7c24f <redacted> + 578
	7   libobjc.A.dylib                     0x3b75890f <redacted> + 174
	8   libc++abi.dylib                     0x3b00d1c7 <redacted> + 78
	9   libc++abi.dylib                     0x3b00cd2d __cxa_increment_exception_refcount + 0
	10  libobjc.A.dylib                     0x3b7587f7 objc_exception_rethrow + 42
	11  CoreFoundation                      0x30eafc9d CFRunLoopRunSpecific + 640
	12  CoreFoundation                      0x30eafa0b CFRunLoopRunInMode + 106
	13  GraphicsServices                    0x35b90283 GSEventRunModal + 138
	14  UIKit                               0x33753049 UIApplicationMain + 1136
	at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x00110>
	at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
	at FirearmSafe.Application.Main (string[]) [0x0000d] in /Users/bobreck/Documents/iOSDevelopment/FirearmSafe/FirearmSafe/Main.cs:18
	at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0x000c8>
	19  FirearmSafe                         0x01777487 mono_jit_runtime_invoke + 1134
	20  FirearmSafe                         0x017bf08d mono_runtime_invoke + 88
	21  FirearmSafe                         0x017c2e0d mono_runtime_exec_main + 276
	22  FirearmSafe                         0x017c2c5d mono_runtime_run_main + 424
	23  FirearmSafe                         0x01761571 mono_jit_exec + 48
	24  FirearmSafe                         0x0180bee0 main + 2468
	25  libdyld.dylib                       0x3bc60ab7 <redacted> + 2
Feb 24 15:59:25 Bobs-iPad FirearmSafe[4349] <Warning>: Unhandled managed exception: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: Application tried to present a nil modal view controller on target <AddFirearm: 0x147d08c0>. (MonoTouch.Foundation.MonoTouchException)
	(null)
Feb 24 15:59:25 Bobs-iPad FirearmSafe[4349] <Error>: Stacktrace:
Feb 24 15:59:25 Bobs-iPad FirearmSafe[4349] <Error>: 
	Native stacktrace:
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	0   FirearmSafe                         0x0176a5b5 mono_handle_native_sigsegv + 260
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	1   FirearmSafe                         0x0176f917 sigabrt_signal_handler + 102
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	2   libsystem_platform.dylib            0x3bd7b063 _sigtramp + 42
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	3   libsystem_pthread.dylib             0x3bd80a33 pthread_kill + 58
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	4   libsystem_c.dylib                   0x3bcc7ffd abort + 76
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	5   FirearmSafe                         0x01822b7c fetch_virt_property + 0
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	6   FirearmSafe                         0x0176aa8b mono_invoke_unhandled_exception_hook + 66
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	7   FirearmSafe                         0x01777db7 mono_thread_abort_dummy + 62
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	8   FirearmSafe                         0x0176a26f mono_handle_exception_internal + 3770
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	9   FirearmSafe                         0x017693af mono_handle_exception + 10
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	10  FirearmSafe                         0x017635fb mono_arm_throw_exception + 102
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	11  FirearmSafe                         0x00f2b9c4 throw_exception + 68
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	12  FirearmSafe                         0x01822c94 objc_skip_type + 0
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	13  FirearmSafe                         0x01812f18 monotouch_register + 0
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	14  CoreFoundation                      0x30f7c24f <redacted> + 578
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	15  libobjc.A.dylib                     0x3b75890f <redacted> + 174
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	16  libc++abi.dylib                     0x3b00d1c7 <redacted> + 78
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	17  libc++abi.dylib                     0x3b00cd2d __cxa_increment_exception_refcount + 0
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	18  libobjc.A.dylib                     0x3b7587f7 objc_exception_rethrow + 42
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	19  CoreFoundation                      0x30eafc9d CFRunLoopRunSpecific + 640
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	20  CoreFoundation                      0x30eafa0b CFRunLoopRunInMode + 106
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	21  GraphicsServices                    0x35b90283 GSEventRunModal + 138
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	22  UIKit                               0x33753049 UIApplicationMain + 1136
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	23  FirearmSafe                         0x00aa505c wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 272
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	24  FirearmSafe                         0x00725ac8 MonoTouch_UIKit_UIApplication_Main_string___string_string + 300
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	25  FirearmSafe                         0x001114c8 FirearmSafe_Application_Main_string__ + 172
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	26  FirearmSafe                         0x00ebd2d0 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	27  FirearmSafe                         0x01777487 mono_jit_runtime_invoke + 1134
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	28  FirearmSafe                         0x017bf08d mono_runtime_invoke + 88
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	29  FirearmSafe                         0x017c2e0d mono_runtime_exec_main + 276
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	30  FirearmSafe                         0x017c2c5d mono_runtime_run_main + 424
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	31  FirearmSafe                         0x01761571 mono_jit_exec + 48
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	32  FirearmSafe                         0x0180bee0 main + 2468
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 	33  libdyld.dylib                       0x3bc60ab7 <redacted> + 2
Feb 24 15:59:26 Bobs-iPad FirearmSafe[4349] <Error>: 
	=================================================================
	Got a SIGABRT while executing native code. This usually indicates
	a fatal error in the mono runtime or one of the native libraries 
	used by your application.
	=================================================================
Feb 24 15:59:26 Bobs-iPad ReportCrash[4910] <Notice>: ReportCrash acting against PID 4349
Feb 24 15:59:27 Bobs-iPad ReportCrash[4910] <Notice>: Formulating crash report for process FirearmSafe[4349]
Feb 24 15:59:27 Bobs-iPad com.apple.launchd[1] (UIKitApplication:com.bobreck.firearmsafe[0xa752][4349]) <Warning>: (UIKitApplication:com.bobreck.firearmsafe[0xa752]) Job appears to have crashed: Abort trap: 6
Feb 24 15:59:27 Bobs-iPad backboardd[29] <Warning>: Application 'UIKitApplication:com.bobreck.firearmsafe[0xa752]' exited abnormally with signal 6: Abort trap: 6
Feb 24 15:59:28 Bobs-iPad ReportCrash[4910] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/FirearmSafe_2014-02-24-155926_Bobs-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
Comment 5 Bob Reck 2014-02-24 16:06:03 UTC
Created attachment 6135 [details]
Crash log from 2-24-14 at 3:59pm.

This is the crash I was able to produce on my iPad 2. The accompanying console log output is attached in a comment to this report.
Bob
Comment 6 Rolf Bjarne Kvinge [MSFT] 2014-02-25 07:08:43 UTC
This is what happens:

> Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: Application tried to present a nil modal view controller on target <AddFirearm: 0x147d08c0>.

and this is where it happens in your source code (apparently you call PresentViewController here):

> 5   FirearmSafe                   	0x00145028 FirearmSafe.Camera:TakePicture (Camera.cs:160)

From our source code I see that PresentViewController will throw an ArgumentNullException if you pass a null view controller, so what the Objective-C exception claims seems to be wrong.

However I believe that somehow the view controller you're presenting has been disposed, in which case it's Handle property is IntPtr.Zero, and this would defeat the null check we've added to PresentViewController, as well as pass a null pointer to Objective-C, causing the message "Application tried to present a nil modal view controller".

You should be able to confirm this by adding a Console.WriteLine (controller.Handle); just before calling PresentViewController in your FirearmSafe.Camera:TakePicture method.
Comment 7 Bob Reck 2014-02-25 22:17:33 UTC
Rolf, 
Again, thank you. I have made a few changes and pushed out a new copy to a couple beta testers. I have not heard back yet so I don't know if this is good or bad news. I tried a lot on my own iPad and was unable to create a crash scenario. 

Thank you very much! I will post back here again when I know a result. For now, I'd like to keep this open just in case.

Bob
Comment 8 Bob Reck 2014-02-28 11:36:59 UTC
Rolf, 
It seems that my problem has been corrected. The PresentViewController appears to have been getting a null because I was calling a dispose of the view that I was using. There was some error in the logic. Oddly enough, this issue was only affecting the iPad users, not iPhone users. I can't explain why, but the same code was used on both.

Anyway, it appears to be fixed now and I thank you very much. I have been trying to track this down for months.

Thank you,
Bob
Comment 9 Mohit Kheterpal 2014-03-26 13:14:01 UTC
As per comment 7 and comment 8, this issue does not exist any more.

Hence closing this issue. Marking its status verified.