Skip to content

EXC_BAD_ACCESS on await session.process(inputImage:) #458

@marek-ch

Description

@marek-ch

Hi!
I am trying to integrate BlinkID (v 7.6.0) on iOS (Swift 6, deployment target iOS 15).

We have custom UI, so I am trying to process the image using session.process function.
However if I create it from CMSampleBuffer, I am getting EXC_BAD_ACCESS (code=1, address=0x0) errors.

Here is code that reproduces the crash:

Task {
            let inputImage = InputImage(cameraFrame: CameraFrame(buffer: MBSampleBufferWrapper(cmSampleBuffer: buffer)))
            let result = await session.process(inputImage: inputImage)
            if result.processResult?.resultCompleteness.scanningStatus == .documentScanned {
                let finalResult = await session.getResult()
                print(finalResult)
            }       
        }

Crash happens on session.process call.
If I use uiImage instead, the processing goes ok, but for performance reasons and efficient memory management, I would prefer to use CMSampleBuffer approach.

My guess would be, that somewhere in implementation of MBSampleBufferWrapper might be some concurrency related bug. It looks like system is releasing the instance of cmSampleBuffer underneath (at the end of captureOutput function).

Here is my code that takes the cmSampleBuffer output:

// MARK: - AVCaptureVideoDataOutputSampleBufferDelegate
    func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
        Task {
            let result = await verifier.verifyBuffer(sampleBuffer)
            print(result)
        }
    }

where verifyBuffer calls the first snippet.

Thanks for helping me out in advance ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions