After iPadOS 17.4, AVCaptureMetadataOutput no longer detects QR codes on some devices.

I'm creating an app that uses AVCaptureSession to pass camera input to AVCaptureMetadataOutput and scan QRCode.

After updating to iPadOS 17.4, an issue has occurred where the delegate method of AVCaptureMetadataOutputObjectsDelegate is not called on some devices. The following devices are experiencing this issue.

  • iPad (7th Gen)
  • iPad (6th Gen)
  • iPad Pro (10.5)
  • iPad Pro (12.9 2nd Gen)

This issue has not occur on any other devices I have. This may only occur on devices with model number "iPad7,x".

I tried running the AVFoundation sample code on the Apple Developer site on the above device. The same problem still occurs. https://developer.apple.com/documentation/avfoundation/capture_setup/avcambarcode_detecting_barcodes_and_faces

Are any additional settings required after iPadOS17.4? Or is there some problem on the OS side?

Same here too.

We also found that on some specific iPads running iPadOS 17.4, even with the "Scan QR Codes" in Settings -> Camera is on, we still can't use the native camera app to scan QR codes, there is no response from Camera app.

I don't know the solution yet, but I found a workaround without using AVCaptureMetadataOutput.
This workaround has been confirmed to work properly on iPad (7th Gen).

WORKAROUND:

  1. Set AVCaptureVideoDataOutput to the output of AVCaptureSession instead of AVCaptureMetadataOutput.
    captureSession.beginConfiguration()

    // Add video input.
    ...

    // Set AVCaptureVideoDataOutput to the output of AVCaptureSession.
    let videodataOutput = AVCaptureVideoDataOutput()
    if captureSession.canAddOutput(videodataOutput) {
        captureSession.addOutput(videodataOutput)
        // Set AVCaptureVideoDataOutputSampleBufferDelegate implemented object.
        videodataOutput.setSampleBufferDelegate(delegate, queue: videoDataOutputQueue)
    }

    captureSession.commitConfiguration()

    sessionQueue.async {
        self.session.startRunning()
    }
  1. Detect the barcode of the sampleBuffer received by the delegate using the Vision.framework
extension CameraViewController: AVCaptureVideoDataOutputSampleBufferDelegate {

    func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {

        // convert sampleBuffer to CVImageBuffer.
        guard let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }

        let handler = VNSequenceRequestHandler()
        let barcodesDetectionRequest = VNDetectBarcodesRequest { (request, error) in

            if let error = error {
                // handle error.
                NSLog("Error: %@", error.localizedDescription)
                return
            }

            guard let results = request.results else { return }            
            for result in results {
                if let barcode = result as? VNBarcodeObservation, validBarcodeTypes.contains(barcode.symbology),
                   let capturedCode = barcode.payloadStringValue {

                    NSLog("captured Code: %@", capturedCode)
                }
            }
        }

        // If necessary, specify the barcode type you want to detect.
        barcodesDetectionRequest.symbologies = [.qr, .code128]

        try? handler.perform([barcodesDetectionRequest], on: imageBuffer)
    }
}

We also have the same stuation. In our case, that happens only when we scan QR code with 6 and 7th Gen iPads. With 8th or more Gen iPads, it dosen't happen. We hope this problem is going to be solved soon.

+1

I have the same problem and am trying to solve it.

Upgrade 17.4.1 will be fine

I don't have access to any of the affected devices, but my customer says he installed 17.4.1, and our app still is not able to scan barcodes. Anyone else?

iOS 17.4.1 still has the issue for barcodes (QR code issue was resolved). No official notification from Apple though. There's a Stack Overflow about this too: https://stackoverflow.com/questions/78128010/ipados-17-4-avcapturemetadataoutput-delegate-not-called-qrscanner

Thank you all for replying.

Upgrading to iPadOS 17.4.1 only fixed scanning QR codes, and upgrading to iPadOS 17.5 beta seems to fix scanning other barcodes as well.

After iPadOS 17.4, AVCaptureMetadataOutput no longer detects QR codes on some devices.
 
 
Q