iOS crash Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException
See original GitHub issueHi,
I am using this plugin v5.0.2 with Xamarin.Forms 5.0.0.2012 and I am having a crash on iOS. Everything works fine in Android.
The crash happens just before opening the view that contains the gvcamera. The flash light gets on but the app crashes soon after and the view is not displayed.
This is what I get in the output
2021-03-18 21:42:26.590 app.iOS[395:31157] -[UIWindow windowScene]: unrecognized selector sent to instance 0x10df7bea0
2021-03-18 21:42:46.877 app.iOS[395:31196] XPC connection interrupted
2021-03-18 21:42:53.895 app.iOS[395:31157] [AppCenterCrashes] ERROR: +[MSACWrapperLogger MSACWrapperLog:tag:level:]/10 Unhandled Exception:
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UIWindow windowScene]: unrecognized selector sent to instance 0x10df7bea0
Native stack trace:
0 CoreFoundation 0x000000018f206f10 <redacted> + 252
1 libobjc.A.dylib 0x000000018e3d4a40 objc_exception_throw + 56
2 CoreFoundation 0x000000018f11e154 <redacted> + 0
3 UIKitCore 0x00000001bbc525c0 <redacted> + 280
4 CoreFoundation 0x000000018f20c810 <redacted> + 1412
5 CoreFoundation 0x000000018f20e4bc _CF_forwarding_prep_0 + 92
6 app.iOS 0x000000010827b9c0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39855572
7 app.iOS 0x00000001081fd9a8 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39339452
8 app.iOS 0x0000000109fb09ac FBMLNLx_SRLRegistrySharedInstanceForProviders + 70481344
9 app.iOS 0x0000000109fb0560 FBMLNLx_SRLRegistrySharedInstanceForProviders + 70480244
10 app.iOS 0x000000010721fc90 FBMLNLx_SRLRegistrySharedInstanceForProviders + 22702244
11 app.iOS 0x000000010adb613c mono_pmip + 28192
12 app.iOS 0x000000010ae723f8 mono_pmip + 798940
13 app.iOS 0x000000010ae75c5c mono_pmip + 813376
14 app.iOS 0x0000000106e19f8c FBMLNLx_SRLRegistrySharedInstanceForProviders + 18484128
15 app.iOS 0x0000000106e48bd4 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18675688
16 UIKitCore 0x00000001bc0c7f44 <redacted> + 1380
17 QuartzCore 0x00000001937e8a34 <redacted> + 184
18 QuartzCore 0x00000001937ed9c4 <redacted> + 324
19 QuartzCore 0x000000019374c9d4 <redacted> + 340
20 QuartzCore 0x000000019377b2f4 <redacted> + 608
21 UIKitCore 0x00000001bbc1e400 <redacted> + 172
22 UIKitCore 0x00000001bbd0dfb0 <redacted> + 5516
23 UIKitCore 0x00000001bbd0683c <redacted> + 152
24 CoreFoundation 0x000000018f1955b8 <redacted> + 24
25 CoreFoundation 0x000000018f195538 <redacted> + 88
26 CoreFoundation 0x000000018f194e1c <redacted> + 176
27 CoreFoundation 0x000000018f18fce8 <redacted> + 1040
28 CoreFoundation 0x000000018f18f5b8 CFRunLoopRunSpecific + 436
29 GraphicsServices 0x0000000191403584 GSEventRunModal + 100
30 UIKitCore 0x00000001bbc24bc8 UIApplicationMain + 212
31 app.iOS 0x0000000108298a78 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39974540
32 app.iOS 0x00000001081d1dc0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39160276
33 app.iOS 0x00000001081d1d44 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39160152
34 app.iOS 0x0000000106e4ef30 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18701124
35 app.iOS 0x000000010721fc90 FBMLNLx_SRLRegistrySharedInstanceForProviders + 22702244
36 app.iOS 0x000000010adb613c mono_pmip + 28192
37 app.iOS 0x000000010ae723f8 mono_pmip + 798940
38 app.iOS 0x000000010ae78650 mono_pmip + 824116
39 app.iOS 0x000000010ad946d0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 85045988
40 app.iOS 0x000000010af7d8d8 xamarin_GetFolderPath + 20100
41 app.iOS 0x0000000106e4ee38 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18700876
42 libdyld.dylib 0x000000018ec4fb94 <redacted> + 4
at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:407
at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:126
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSend(intptr,intptr)
at UIKit.UIWindow.get_WindowScene () [0x0000d] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIWindow.g.cs:476
at GoogleVisionBarCodeScanner.UICameraPreview.setPreviewOrientation () [0x0003a] in <07a2a8628e5f48b4a932d4ede11d52d7>:0
at GoogleVisionBarCodeScanner.UICameraPreview.LayoutSubviews () [0x00008] in <07a2a8628e5f48b4a932d4ede11d52d7>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at app.iOS.Application.Main (System.String[] args) [0x00001] in /Users/.../app.iOS/Main.cs:17
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSend(intptr,intptr)
at UIKit.UIWindow.get_WindowScene () [0x0000d] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIWindow.g.cs:476
at GoogleVisionBarCodeScanner.UICameraPreview.setPreviewOrientation () [0x0003a] in <07a2a8628e5f48b4a932d4ede11d52d7>:0
at GoogleVisionBarCodeScanner.UICameraPreview.LayoutSubviews () [0x00008] in <07a2a8628e5f48b4a932d4ede11d52d7>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at app.iOS.Application.Main (System.String[] args) [0x00001] in /Users/.../app.iOS/Main.cs:17 0 CoreFoundation 0x000000018f206f10 <redacted> + 252
1 libobjc.A.dylib 0x000000018e3d4a40 objc_exception_throw + 56
2 CoreFoundation 0x000000018f11e154 <redacted> + 0
3 UIKitCore 0x00000001bbc525c0 <redacted> + 280
4 CoreFoundation 0x000000018f20c810 <redacted> + 1412
5 CoreFoundation 0x000000018f20e4bc _CF_forwarding_prep_0 + 92
6 app.iOS 0x000000010827b9c0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39855572
7 app.iOS 0x00000001081fd9a8 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39339452
8 app.iOS 0x0000000109fb09ac FBMLNLx_SRLRegistrySharedInstanceForProviders + 70481344
9 app.iOS 0x0000000109fb0560 FBMLNLx_SRLRegistrySharedInstanceForProviders + 70480244
10 app.iOS 0x000000010721fc90 FBMLNLx_SRLRegistrySharedInstanceForProviders + 22702244
11 app.iOS 0x000000010adb613c mono_pmip + 28192
12 app.iOS 0x000000010ae723f8 mono_pmip + 798940
13 app.iOS 0x000000010ae75c5c mono_pmip + 813376
14 app.iOS 0x0000000106e19f8c FBMLNLx_SRLRegistrySharedInstanceForProviders + 18484128
15 app.iOS 0x0000000106e48bd4 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18675688
16 UIKitCore 0x00000001bc0c7f44 <redacted> + 1380
17 QuartzCore 0x00000001937e8a34 <redacted> + 184
18 QuartzCore 0x00000001937ed9c4 <redacted> + 324
19 QuartzCore 0x000000019374c9d4 <redacted> + 340
20 QuartzCore 0x000000019377b2f4 <redacted> + 608
21 UIKitCore 0x00000001bbc1e400 <redacted> + 172
22 UIKitCore 0x00000001bbd0dfb0 <redacted> + 5516
23 UIKitCore 0x00000001bbd0683c <redacted> + 152
24 CoreFoundation 0x000000018f1955b8 <redacted> + 24
25 CoreFoundation 0x000000018f195538 <redacted> + 88
26 CoreFoundation 0x000000018f194e1c <redacted> + 176
27 CoreFoundation 0x000000018f18fce8 <redacted> + 1040
28 CoreFoundation 0x000000018f18f5b8 CFRunLoopRunSpecific + 436
29 GraphicsServices 0x0000000191403584 GSEventRunModal + 100
30 UIKitCore 0x00000001bbc24bc8 UIApplicationMain + 212
31 app.iOS 0x0000000108298a78 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39974540
32 app.iOS 0x00000001081d1dc0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39160276
33 app.iOS 0x00000001081d1d44 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39160152
34 app.iOS 0x0000000106e4ef30 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18701124
35 app.iOS 0x000000010721fc90 FBMLNLx_SRLRegistrySharedInstanceForProviders + 22702244
36 app.iOS 0x000000010adb613c mono_pmip + 28192
37 app.iOS 0x000000010ae723f8 mono_pmip + 798940
38 app.iOS 0x000000010ae78650 mono_pmip + 824116
39 app.iOS 0x000000010ad946d0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 85045988
40 app.iOS 0x000000010af7d8d8 xamarin_GetFolderPath + 20100
41 app.iOS 0x0000000106e4ee38 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18700876
42 libdyld.dylib 0x000000018ec4fb94 <redacted> + 4
2021-03-18 21:42:53.941 app.iOS[395:31157] Unhandled managed exception: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UIWindow windowScene]: unrecognized selector sent to instance 0x10df7bea0
Native stack trace:
0 CoreFoundation 0x000000018f206f10 <redacted> + 252
1 libobjc.A.dylib 0x000000018e3d4a40 objc_exception_throw + 56
2 CoreFoundation 0x000000018f11e154 <redacted> + 0
3 UIKitCore 0x00000001bbc525c0 <redacted> + 280
4 CoreFoundation 0x000000018f20c810 <redacted> + 1412
5 CoreFoundation 0x000000018f20e4bc _CF_forwarding_prep_0 + 92
6 app.iOS 0x000000010827b9c0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39855572
7 app.iOS 0x00000001081fd9a8 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39339452
8 app.iOS 0x0000000109fb09ac FBMLNLx_SRLRegistrySharedInstanceForProviders + 70481344
9 app.iOS 0x0000000109fb0560 FBMLNLx_SRLRegistrySharedInstanceForProviders + 70480244
10 app.iOS 0x000000010721fc90 FBMLNLx_SRLRegistrySharedInstanceForProviders + 22702244
11 app.iOS 0x000000010adb613c mono_pmip + 28192
12 app.iOS 0x000000010ae723f8 mono_pmip + 798940
13 app.iOS 0x000000010ae75c5c mono_pmip + 813376
14 app.iOS 0x0000000106e19f8c FBMLNLx_SRLRegistrySharedInstanceForProviders + 18484128
15 app.iOS 0x0000000106e48bd4 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18675688
16 UIKitCore 0x00000001bc0c7f44 <redacted> + 1380
17 QuartzCore 0x00000001937e8a34 <redacted> + 184
18 QuartzCore 0x00000001937ed9c4 <redacted> + 324
19 QuartzCore 0x000000019374c9d4 <redacted> + 340
20 QuartzCore 0x000000019377b2f4 <redacted> + 608
21 UIKitCore 0x00000001bbc1e400 <redacted> + 172
22 UIKitCore 0x00000001bbd0dfb0 <redacted> + 5516
23 UIKitCore 0x00000001bbd0683c <redacted> + 152
24 CoreFoundation 0x000000018f1955b8 <redacted> + 24
25 CoreFoundation 0x000000018f195538 <redacted> + 88
26 CoreFoundation 0x000000018f194e1c <redacted> + 176
27 CoreFoundation 0x000000018f18fce8 <redacted> + 1040
28 CoreFoundation 0x000000018f18f5b8 CFRunLoopRunSpecific + 436
29 GraphicsServices 0x0000000191403584 GSEventRunModal + 100
30 UIKitCore 0x00000001bbc24bc8 UIApplicationMain + 212
31 app.iOS 0x0000000108298a78 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39974540
32 app.iOS 0x00000001081d1dc0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39160276
33 app.iOS 0x00000001081d1d44 FBMLNLx_SRLRegistrySharedInstanceForProviders + 39160152
34 app.iOS 0x0000000106e4ef30 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18701124
35 app.iOS 0x000000010721fc90 FBMLNLx_SRLRegistrySharedInstanceForProviders + 22702244
36 app.iOS 0x000000010adb613c mono_pmip + 28192
37 app.iOS 0x000000010ae723f8 mono_pmip + 798940
38 app.iOS 0x000000010ae78650 mono_pmip + 824116
39 app.iOS 0x000000010ad946d0 FBMLNLx_SRLRegistrySharedInstanceForProviders + 85045988
40 app.iOS 0x000000010af7d8d8 xamarin_GetFolderPath + 20100
41 app.iOS 0x0000000106e4ee38 FBMLNLx_SRLRegistrySharedInstanceForProviders + 18700876
42 libdyld.dylib 0x000000018ec4fb94 <redacted> + 4
(Foundation.MonoTouchException)
at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:407
at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:126
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSend(intptr,intptr)
at UIKit.UIWindow.get_WindowScene () [0x0000d] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIWindow.g.cs:476
at GoogleVisionBarCodeScanner.UICameraPreview.setPreviewOrientation () [0x0003a] in <07a2a8628e5f48b4a932d4ede11d52d7>:0
at GoogleVisionBarCodeScanner.UICameraPreview.LayoutSubviews () [0x00008] in <07a2a8628e5f48b4a932d4ede11d52d7>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at app.iOS.Application.Main (System.String[] args) [0x00001] in /Users/.../app.iOS/Main.cs:17
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSend(intptr,intptr)
at UIKit.UIWindow.get_WindowScene () [0x0000d] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIWindow.g.cs:476
at GoogleVisionBarCodeScanner.UICameraPreview.setPreviewOrientation () [0x0003a] in <07a2a8628e5f48b4a932d4ede11d52d7>:0
at GoogleVisionBarCodeScanner.UICameraPreview.LayoutSubviews () [0x00008] in <07a2a8628e5f48b4a932d4ede11d52d7>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at app.iOS.Application.Main (System.String[] args) [0x00001] in /Users/.../app.iOS/Main.cs:17
Thank you for your help!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Foundation.MonoTouchException: Objective-C exception ...
Steps to Reproduce Create a class extending LabelRenderer Run the app Expected Behavior NO CRASH Actual Behavior CRASH: it seems to crash on ......
Read more >Foundation.MonoTouchException has been thrown, ...
I am getting following error, while I run native iOS application within Xamarin. Foundation.MonoTouchException has been thrown Objective-C ...
Read more >Xamarin iOS VPN app extension not starting packet tunnel ...
Unhandled Exception: Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: ...
Read more >Xamarin Editor controls crashes on iOS 13.x
MonoTouchException : 'Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[NSCFSet addObject:]: attempt to insert nil".
Read more >C#: Monotouch crashes on button click after upgrade
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFType btnSave:]: unrecognized selector sent to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @JimmyPun610 I understand why you went back to the original UIDeviceOrientation code for 12 and below, but this fix reopens the bug you fixed in https://github.com/JimmyPun610/BarcodeScanner.XF/commit/3d5c389d945b878aa63dd4976515894a9195dd3d
In iOS 12 if you open the scanner while the phone is in landscape the video preview is rotated, and really awkward to use. Maybe is possible to fix the issue on iOS 12 without the UIInterfaceOrientation?
Updated version 5.0.3 which has another approach for iOS 12 or below. The approach is using previous version one.