yannickl/QRCodeReader.swift

Crashed: session queue EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000e2685270

kuoliangkwong opened this issue · 1 comments

Crashed: session queue
0  libobjc.A.dylib                0x1a4bdcd70 objc_msgSend + 16
1  Foundation                     0x1a6468140 NSKeyValueWillChangeWithPerThreadPendingNotifications.llvm.10547614101533924569 + 580
2  AVFoundation                   0x1abac5968 -[AVCaptureFigVideoDevice setVideoZoomFactor:] + 384
3  AVFoundation                   0x1abae4a80 -[AVCaptureSession _updateDeviceActiveFormatsAndActiveConnections] + 2716
4  AVFoundation                   0x1abae3850 -[AVCaptureSession _buildAndRunGraph] + 104
5  AVFoundation                   0x1abadd818 -[AVCaptureSession _commitConfiguration] + 120
6  AVFoundation                   0x1abade578 -[AVCaptureSession addInput:] + 724
7  QRCodeReader                   0x1053a045c $S12QRCodeReaderAAC26configureDefaultComponents33_B9DC3D797F478C8B92B825BD13CC6026LL25withCaptureDevicePositionySo09AVCaptureqR0V_tF (QRCodeReader.swift:151)
8  QRCodeReader                   0x1053a6730 partial apply for QRCodeReader (<compiler-generated>)
9  QRCodeReader                   0x1053a0798 $SIeg_IeyB_TR (<compiler-generated>)
10 libdispatch.dylib              0x1a542d6c8 _dispatch_call_block_and_release + 24
11 libdispatch.dylib              0x1a542e484 _dispatch_client_callout + 16
12 libdispatch.dylib              0x1a53d5be0 _dispatch_lane_serial_drain$VARIANT$mp + 592
13 libdispatch.dylib              0x1a53d6728 _dispatch_lane_invoke$VARIANT$mp + 432
14 libdispatch.dylib              0x1a53deec8 _dispatch_workloop_worker_thread + 600
15 libsystem_pthread.dylib        0x1a56100dc _pthread_wqthread + 312
16 libsystem_pthread.dylib        0x1a5612cec start_wqthread + 4

I got the crash from my ios app.

Here's my code:

lazy var readerVC: QRCodeReaderViewController = {
        let builder = QRCodeReaderViewControllerBuilder {
            $0.reader = QRCodeReader(metadataObjectTypes: [.qr], captureDevicePosition: .back)
        }
        builder.showSwitchCameraButton = false
        return QRCodeReaderViewController(builder: builder)
    }()

I only call this when pressing the button, the crash happened before this is called:

@IBAction func onScanClicked(_ sender: Any) {
        readerVC.delegate = self
        readerVC.modalPresentationStyle = .formSheet
        present(readerVC, animated: true, completion: nil)
    }

I'm seeing the same error from our users but haven't been able to reproduce the issue myself.
Looking at the code shouldn't the addInput line be wrapped in something like this?

if session.canAddInput(_frontDeviceInput) {
session.addInput(_frontDeviceInput)
}