I'm using a ZXingScannerFragment as part of a FragmentActivity that displays a view of the camera managed by ZXing. There is a callback associated with the detection of a QR code.
If I scan a QR code, the camera view will freeze for a fraction of a second before the callback is called. If I flip the device during this interval, I get two Java.Lang.RuntimeException "Camera is being used after Camera.release() was called", where the stack trace does not contain any part of my code. The stack traces are very long due to containing unmanaged code; the [full text is here][1] but excerpts are below.
As you can see, the exception appears to originate in ZXing.Mobile.ZXingScannerFragment.ShutdownCamera(). Is this configuration change handled correctly in the ZXing library, and am I doing something wrong? Or does this appear to be a problem with the library itself? As far as I can tell, I am unable to catch this exception in my Xamarin-managed code.
Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00078>
at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue*) [0x00063] in /Users/builder/data/lanes/1780/3518c4ce/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:571
at Android.Hardware.Camera.SetPreviewCallback (Android.Hardware.Camera/IPreviewCallback) [0x00044] in /Users/builder/data/lanes/1780/3518c4ce/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Hardware.Camera.cs:5106
at ZXing.Mobile.ZXingSurfaceView.ShutdownCamera () <IL 0x0001d, 0x000a7>
at ZXing.Mobile.ZXingScannerFragment.OnPause () <IL 0x0000c, 0x00077>
at Android.Support.V4.App.Fragment.n_OnPause (intptr,intptr) <IL 0x0000a, 0x0009f>
at (wrapper dynamic-method) object.17d8fe32-32a6-432b-9ceb-41f3b8011084 (intptr,intptr) <IL 0x00011, 0x0004b>
--- End of managed exception stack trace ---
Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00078>
at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue*) [0x00063] in /Users/builder/data/lanes/1780/3518c4ce/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:571
at Android.Hardware.Camera.SetPreviewCallback (Android.Hardware.Camera/IPreviewCallback) [0x00044] in /Users/builder/data/lanes/1780/3518c4ce/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Hardware.Camera.cs:5106
at ZXing.Mobile.ZXingSurfaceView.ShutdownCamera () <IL 0x0001d, 0x000a7>
at ZXing.Mobile.ZXingScannerFragment.OnPause () <IL 0x0000c, 0x00077>
at Android.Support.V4.App.Fragment.n_OnPause (intptr,intptr) <IL 0x0000a, 0x0009f>
at (wrapper dynamic-method) object.17d8fe32-32a6-432b-9ceb-41f3b8011084 (intptr,intptr) <IL 0x00011, 0x0004b>
--- End of managed exception stack trace ---
[1]:
http://pastebin.com/xjL9Md58
Kind regards,
Geir Smestad