Request cancelled when trying to detect faces in photo using VNDetectFaceRectanglesRequest.

Hi, I am running the following code and I am getting an error that I was not able to find what is the cause of it. The code runs on its own queue.

Code:

let handler = VNImageRequestHandler(data: photoData, options: [:])
let request = VNDetectFaceRectanglesRequest { request, error in
  guard error == nil,  
        let results = request.results, 
        results.count > 0 else { 
          return
        }
}
request.preferBackgroundProcessing = true
try? handler.perform([request])

Error:

Error Domain=com.apple.vis Code=1 "request VNDetectFaceRectanglesRequest was cancelled" UserInfo={VNRequest=<VNDetectFaceRectanglesRequest: 0x600002044000> VNDetectFaceRectanglesRequestRevision3 preferBackgroundProcessing ROI=[0, 0, 1, 1], NSLocalizedDescription=request VNDetectFaceRectanglesRequest was cancelled}

Env: MacBook Pro M1 Xcode Version 13.3.1 Deployment Target iOS 13