VNImageRequestHandler perform 'unspecified error' on M1 MacBook Pro

I'm getting the following error when running a simple test of VNImageRequestHandler perform in Xcode:

failed: caught error: "Error Domain=com.apple.vis Code=9 "encountered an unexpected condition: Unspecified error" UserInfo={NSLocalizedDescription=encountered an unexpected condition: Unspecified error}

The test is as follows:

Code Block
    func testExample() throws {
        let bundle = Bundle(for: type(of: self))
        let image = UIImage(named: "image.jpeg", in: bundle, with: nil)!
        let imageRequestHandler = VNImageRequestHandler(cgImage: image.cgImage!)
        let captureQualityRequest = VNDetectFaceCaptureQualityRequest()
        try imageRequestHandler.perform([captureQualityRequest])
    }


This error is happening on Xcode 12.2 (and 12.3 beta), macOS 11.0.1, and a Late 2020 13" M1 MacBook Pro.

This does not happen on Xcode 12.2 and macOS 11.0.1 on an Intel MacBook Pro.

Sample project can be found here:
https://gitlab.com/kabucey/vnimagerequesthandlertest

Has anyone encountered this before?

Hello,

I'm only seeing a "Hello World" in the sample project you posted.

Also, could you try running the Image Saliency sample on your M1 MacBook.

Thanks!
This problem happens specifically with unit tests, and that test can be found in the sample project that was linked to.

The Image Saliency project runs fine but there aren't any unit tests in it.
Hi,

I get the same error when running in the Simulator on a 2020 M1 MacBook Pro. On Intel everything works as expected.

I have this same error. Does anyone have a solution yet? Thanks.

I have this same error also when running my code in iPhone simulator on my m1 MacBook Air. Does anyone have a solution yet? Thanks. 

I am getting the error on simulator with iPadOS config (iPad Pro 12.9-9inch). Running on a physical iPad - error does not occur. Simulator is running on an iMac (24-inch, M1, 2021)

I have the same error in xCode 13.1 while trying to run Vision in UnitTests. Did you find any solution meanwhile?

Still a problem on XCode 13.3, even running on Rosetta. Any Vision request from a test case in the simulator throws an error.

This is still happening as of Xcode 13.4.1.

This happens to me as well. Any workarounds so far?

I get a slightly different error in unit tests, only on my M1 laptop:

request VNDetectFaceRectanglesRequest was cancelled

But I found a solution!

#if targetEnvironment(simulator)
    faceDetectionRequest.usesCPUOnly = true
#endif
VNImageRequestHandler perform 'unspecified error' on M1 MacBook Pro
 
 
Q