yannickl / QRCodeReader.swift

Simple QRCode reader in Swift
MIT License
1.33k stars 330 forks source link

Deadlock on QRCodeReaderView::setupComponents #129

Open nburyak opened 6 years ago

nburyak commented 6 years ago

Once in while I have a deadlock. I can reproduce it sporadically. Currently I'm investigating the issue however haven't figured out the fix.

screen shot 2018-02-05 at 22 38 00

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x0000000181074138 libsystem_kernel.dylib`__psynch_mutexwait + 8
    frame #1: 0x000000018118b660 libsystem_pthread.dylib`_pthread_mutex_lock_wait + 96
    frame #2: 0x000000018118b5a4 libsystem_pthread.dylib`_pthread_mutex_lock_slow$VARIANT$mp + 264
    frame #3: 0x00000001807b49e8 libobjc.A.dylib`recursive_mutex_tt<false>::lock() + 16
    frame #4: 0x00000001807b8248 libobjc.A.dylib`objc_sync_enter + 28
    frame #5: 0x0000000186ed3fb4 AVFoundation`-[AVCaptureSession _buildAndRunGraph] + 668
    frame #6: 0x0000000186ece048 AVFoundation`-[AVCaptureSession _commitConfiguration] + 120
    frame #7: 0x0000000186ed03c0 AVFoundation`-[AVCaptureSession _addVideoPreviewLayer:exceptionReason:] + 512
    frame #8: 0x0000000186ee0bb4 AVFoundation`-[AVCaptureVideoPreviewLayer setSession:] + 216
    frame #9: 0x0000000186ee0554 AVFoundation`-[AVCaptureVideoPreviewLayer _initWithSession:makeConnection:] + 1008
    frame #10: 0x00000001029720c0 DC App`@nonobjc AVCaptureVideoPreviewLayer.init(session:) at QRCodeReader.swift:0
    frame #11: 0x0000000102969b98 DC App`AVCaptureVideoPreviewLayer.__allocating_init(session:) at QRCodeReader.swift:0
    frame #12: 0x0000000102969b20 DC App`closure #1 in QRCodeReader.previewLayer.getter(self=0x00000001c02e2a80) at QRCodeReader.swift:72
    frame #13: 0x0000000102969a14 DC App`QRCodeReader.previewLayer.getter(self=0x00000001c02e2a80) at QRCodeReader.swift:73
    frame #14: 0x00000001029e23e8 DC App`QRCodeReaderView.addComponents(self=0x0000000103e2c550) at QRCodeReaderView.swift:183
  * frame #15: 0x00000001029e0134 DC App`QRCodeReaderView.setupComponents(showCancelButton=false, showSwitchCameraButton=false, showTorchButton=false, showOverlayView=false, reader=0x00000001c02e2a80, self=0x0000000103e2c550) at QRCodeReaderView.swift:79
    frame #16: 0x000000010293d978 DC App`ScanCodeViewController.viewDidLoad(self=0x0000000103f1d570) at ScanCodeViewController.swift:40
    frame #17: 0x000000010293dfc8 DC App`@objc ScanCodeViewController.viewDidLoad() at ScanCodeViewController.swift:0
yannickl commented 6 years ago

Have you find a way to reproduce it?

iwasrobbed-ks commented 4 years ago

Likely need to stop the camera session before changing the configuration and then start it again before setting the new session into the preview layer