Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on iOS with the latest version (3.4.x) #720

Closed
g123k opened this issue Aug 8, 2023 · 15 comments · Fixed by #781
Closed

Crash on iOS with the latest version (3.4.x) #720

g123k opened this issue Aug 8, 2023 · 15 comments · Fixed by #781
Assignees
Labels
crash ios Platform iOS

Comments

@g123k
Copy link
Contributor

g123k commented Aug 8, 2023

Hi everyone,

On iOS, I have the following crash when returning to a Flutter application:

mobile_scanner/MobileScanner.swift:224: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
mobile_scanner/MobileScanner.swift:224: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
    frame #0: 0x00000001a6554a2c libswiftCore.dylib`_swift_runtime_on_report
libswiftCore.dylib`:
->  0x1a6554a2c <+0>: ret    
libswiftCore.dylib`:
    0x1a6554a30 <+0>: b      0x1a6554a2c               ; _swift_runtime_on_report
libswiftCore.dylib`:
    0x1a6554a34 <+0>: adrp   x8, 366461
    0x1a6554a38 <+4>: ldrb   w0, [x8, #0x994]
Target 0: (Runner) stopped.
@g123k
Copy link
Contributor Author

g123k commented Aug 8, 2023

@ened Hi!

Your PR cd506eb introduces this crash. Any idea how to fix it?

@ened
Copy link
Contributor

ened commented Aug 9, 2023

Looking at it now..

@ened
Copy link
Contributor

ened commented Aug 9, 2023

I added a PR #726 but unfortunately did not test it - if you could take a look (dependency_overrides) and retest it would be great. @g123k

@g123k
Copy link
Contributor Author

g123k commented Aug 9, 2023

I added a PR #726 but unfortunately did not test it - if you could take a look (dependency_overrides) and retest it would be great. @g123k

Thanks for your quick changes, but even by setting IPHONEOS_DEPLOYMENT_TARGET to 15, I have the following error:

Could not build the precompiled application for the device.
Swift Compiler Error (Xcode): Concurrency is only available in iOS 13.0.0 or newer
/Users/g123k/.pub-cache/git/mobile_scanner-3baf60b2ab6ba09c91029ae62677dc20a63c0562/ios/Classes/MobileScanner.swift:122:189

Swift Compiler Error (Xcode): Concurrency is only available in iOS 13.0.0 or newer
/Users/g123k/.pub-cache/git/mobile_scanner-3baf60b2ab6ba09c91029ae62677dc20a63c0562/ios/Classes/SwiftMobileScannerPlugin.swift:101:85

@vlazdra
Copy link

vlazdra commented Aug 9, 2023

I just experienced this as well, luckily in development.
This is what Sentry has caught on my end:

Runner | +0xe3253c | MobileScanner.start (MobileScanner.swift:224)

            DispatchQueue.main.async {
                completion(
                    MobileScannerStartParameters(
                        width: Double(dimensions.height),
                        height: Double(dimensions.width),
                        hasTorch: self.device.hasTorch,
                        textureId: self.textureId
                    )
                )
            }
        }

EXC_BREAKPOINT
Exception 6, Code 1, Subcode 4318586172

I'm not sure if it the same issue, but iOS is crashing.

Edit: The hasTorch line is crashing.

@binhvtKova
Copy link

Hi @vlazdra,

I'm also using latest version 3.4.1 and few days ago I encounter the crash maybe same with this on my firebase craslytics
Screenshot 2023-08-29 at 10 11 17

My case the crashing line is MobileScanner.start(barcodeScannerOptions:returnImage:cameraPosition:torch:detectionSpeed:completion:) + 228 (MobileScanner.swift:228)

It's same with your detecting.

@phillipjacobs
Copy link

Hi @vlazdra,

I'm also using latest version 3.4.1 and few days ago I encounter the crash maybe same with this on my firebase craslytics Screenshot 2023-08-29 at 10 11 17

My case the crashing line is MobileScanner.start(barcodeScannerOptions:returnImage:cameraPosition:torch:detectionSpeed:completion:) + 228 (MobileScanner.swift:228)

It's same with your detecting.

@binhvtKova what was your fix/workaround for this. Did you just end up reverting versions. I'm getting the exact same crash as you.

MobileScanner.start(barcodeScannerOptions:returnImage:cameraPosition:torch:detectionSpeed:completion:) + 228 (MobileScanner.swift:228)

@jack24254029
Copy link

Same issue

#1	0x0000000104a8147c in closure #1 in closure #1 in MobileScanner.start(barcodeScannerOptions:returnImage:cameraPosition:torch:detectionSpeed:completion:) at /Users/alan.chang/.pub-cache/hosted/pub.dev/mobile_scanner-3.4.1/ios/Classes/MobileScanner.swift:224

image

@emrahkenan
Copy link

+1

Crashed: com.apple.main-thread 0 Runner 0xa86894 partial apply for closure #1 in closure #1 in MobileScanner.start(barcodeScannerOptions:returnImage:cameraPosition:torch:detectionSpeed:completion:) + 374508 (MobileScanner.swift:374508) 1 Runner 0xa83a64 thunk for @escaping @callee_guaranteed () -> () + 362684 (<compiler-generated>:362684) 2 libdispatch.dylib 0x2320 _dispatch_call_block_and_release + 32 3 libdispatch.dylib 0x3eac _dispatch_client_callout + 20 4 libdispatch.dylib 0x126a4 _dispatch_main_queue_drain + 928 5 libdispatch.dylib 0x122f4 _dispatch_main_queue_callback_4CF + 44 6 CoreFoundation 0x98c28 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 7 CoreFoundation 0x7a560 __CFRunLoopRun + 1992 8 CoreFoundation 0x7f3ec CFRunLoopRunSpecific + 612 9 GraphicsServices 0x135c GSEventRunModal + 164 10 UIKitCore 0x39cf58 -[UIApplication _run] + 888 11 UIKitCore 0x39cbbc UIApplicationMain + 340 12 Runner 0x7ca4 main + 6 (AppDelegate.swift:6) 13 ??? 0x1b55b0dec (Missing)

@navaronbracke navaronbracke self-assigned this Oct 12, 2023
@navaronbracke
Copy link
Collaborator

I think I know what the problem is here. As indicated, there is a problem with

            DispatchQueue.main.async {
                completion(
                    MobileScannerStartParameters(
                        width: Double(dimensions.height),
                        height: Double(dimensions.width),
                        hasTorch: self.device.hasTorch,
                        textureId: self.textureId
                    )
                )
            }

specifically self.device.hasTorch. I think that accessing the device is the problem here.

Will fix this soon.

@navaronbracke
Copy link
Collaborator

Hi all, could anyone verify if #781 fixes the issue?

dependencies:
 mobile_scanner:
    git:
      url: https://github.com/navaronbracke/mobile_scanner.git
      ref: fix_issue_720

@gabrielyea
Copy link

@navaronbracke Just tested your fix multiple times, my app is no longer crashing. Before it was constantly crashing after scanning anything with the error message Unexpectedly found nil while implicitly unwrapping an Optional value

@navaronbracke
Copy link
Collaborator

@gabrielyea Thanks a lot for confirming!

@radivojeostojic
Copy link

We've been encountering a substantial number of crashes on Firebase Crashlytics related to this bug in the latest release, version 3.5.2. Has anyone else noticed the same thing?

Runner
MobileScanner.swift - Line 223
closure #1 in MobileScanner.start(barcodeScannerOptions:returnImage:cameraPosition:torch:detectionSpeed:completion:) + 223

@navaronbracke
Copy link
Collaborator

@radivojeostojic That seems to point to https://github.com/juliansteenbakker/mobile_scanner/blob/master/ios/Classes/MobileScanner.swift#L223

Could you file a different issue for this? Including the full stacktrace would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash ios Platform iOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.