CameraManager icon indicating copy to clipboard operation
CameraManager copied to clipboard

QR Detection Only Works Once Per Session

Open Yrban opened this issue 4 years ago • 0 comments

When I trigger the QR detection via the following code, it will only read one QR code. My code:

    fileprivate func startQRCodeDetection() {
        cameraManager.startQRCodeDetection { (result) in
            switch result {
            case .success(let value):
                qrString = value
            case .failure(let error):
                NSLog("\ncameraManager.startQRCodeDetection failed with error %@", error.localizedDescription)
            }
        }
        qrScannerIsActive = true
    }
    
    fileprivate func stopQRCodeDetection() {
        cameraManager.stopQRCodeDetection()
        qrScannerIsActive = false
        qrString = nil
    }

I think I traced one issue to stopQRCodeDetection() in CameraManager. Line 821 fails and I otherwise can't see where qrOutput is ever set to anything from nil, therefore, line 822, captureSession?.removeOutput(output) is not called. I am not sure that that is the root of my problem that I am seeing, but it may need addressing. Thanks.

Yrban avatar Feb 05 '21 18:02 Yrban