NativeScript / mlkit

Apache License 2.0
24 stars 9 forks source link

Activation of Torch Mode crashes on iPhone #7

Closed cjohn001 closed 2 years ago

cjohn001 commented 2 years ago

@triniwiz : I had a chance today to play a little around with the new plugin version. I was using the demo you provided in the plugin. (MLKit Core) When pushing the Toggle Camera button, the app crashes. The Crash dump is attached below. Seems like the set torch mode is not supported. Would be good to catch the exception and requesting the max value that could be set?

From the documentation it seems like range 0-1 can be valid but max value can also be lower.

https://developer.apple.com/documentation/avfoundation/avcapturedevice/1624609-settorchmodeonwithlevel?language=objc

Alternatively using constant as described here might work? https://developer.apple.com/documentation/avfoundation/avcapturemaxavailabletorchlevel?language=objc

Evaluating dispatch of UIEvent: 0x2803ac240; type: 0; subtype: 0; backing type: 11; shouldSend: 1; ignoreInteractionEvents: 0, systemGestureStateChange: 0 Sending UIEvent type: 0; subtype: 0; to windows: 1 Sending UIEvent type: 0; subtype: 0; to window: <UIWindow: 0x10991db10>; contextId: 0xAF442941 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[AVCaptureDevice setTorchMode:] The passed torchMode 1 is not supported - use -isTorchModeSupported: to discover valid torch modes' *** First throw call stack: (0x1811f104c 0x199865f54 0x19fbe7f04 0x1002760d0 0x10026eaf4 0x180e61914 0x180e63660 0x180e6ade4 0x180e6b958 0x180e761a8 0x1f14920f4 0x1f1491e94) Cache loaded with 4815 pre-cached in CacheData and 54 items in CacheExtra. CONSOLE LOG: Loading inspector modules... CONSOLE LOG: Finished loading inspector modules. networkd_settings_read_from_file initialized networkd settings by reading plist directly networkd_settings_read_from_file initialized networkd settings by reading plist directly nw_path_evaluator_start [12D0A17B-7940-4273-A8CE-0B67E0F77F1C generic, attribution: developer] path: satisfied (Path is satisfied), interface: en0, ipv4, dns