Help Needed: Error Codes in VCPHumanPoseImageRequest.mm[85] and NSArrayM insertObject

Hey all 👋🏼

We're currently working on a video processing project using the Vision framework (face, body and hand pose detection), and We've encountered a couple of errors that I need help with. We are on Xcode 16 Beta 3, testing on an iPhone 14 Pro running iOS 18 beta.

The error messages are as follows:

[LOG_ERROR] /Library/Caches/com.apple.xbs/Sources/MediaAnalysis/VideoProcessing/VCPHumanPoseImageRequest.mm[85]: code 18,446,744,073,709,551,598

encountered an unexpected condition: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil

What we've tried:

  1. Debugging: I’ve tried stepping through the code, but the errors occur before I can gather any meaningful insights.
  2. Searching Documentation: Looked through Apple’s developer documentation and forums but couldn’t find anything related to these specific error codes.
  3. Nil Check: Added checks to ensure objects are not nil before inserting them into arrays, but the error persists.

Here are my questions:

  1. Has anyone encountered similar errors with the Vision framework, specifically related to VCPHumanPoseImageRequest and NSArray operations?
  2. Is there any known issue or bug in the version of the framework I might be using? Could it also be related to the beta?
  3. Are there any additional debug steps or logging mechanisms I can implement to narrow down the cause?
  4. Any suggestions on how to handle nil objects more effectively in this context?

I would greatly appreciate any insights or suggestions you might have. Thank you in advance for your assistance!

Thanks all!

Answered by Frameworks Engineer in 797430022

This error looks like it may be related to a rare issue in the iOS 18 beta triggered by performing both hand pose and body pose detection under certain conditions. If you could provide more details about the specific requests used and how they are configured, or even better some code that reproduces the problem and/or a sysdiagnose report, we could confirm what the issue is and suggest a workaround.

This error looks like it may be related to a rare issue in the iOS 18 beta triggered by performing both hand pose and body pose detection under certain conditions. If you could provide more details about the specific requests used and how they are configured, or even better some code that reproduces the problem and/or a sysdiagnose report, we could confirm what the issue is and suggest a workaround.

Thanks for the fast reply! We have built this into a camera output delegate, for real-time performance improvements (or attempting to), depending on the user request, certain pose requests are added.

This is not crucial to the app, but it is something we'd like to implement, so any help is really appreciated!

From our initial troubleshooting, this is the code causing the problem:

public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
   
        let imageRequestHandler = VNImageRequestHandler(cmSampleBuffer: sampleBuffer, orientation: .up)
        
        var requests: [VNRequest] = []
        
        if self.selectedRequests.hand {
            let handPoseRequest = VNDetectHumanHandPoseRequest()
            requests.append(handPoseRequest)
        }
        
        if self.selectedRequests.body {
            let bodyPoseRequest = VNDetectHumanBodyPoseRequest()
            requests.append(bodyPoseRequest)
        }
        
        if self.selectedRequests.face {
            let faceRequest = VNDetectFaceLandmarksRequest()
            requests.append(faceRequest)
        }
        
        var spatialOutput = VisionOutput()
        
        // Perform the selected Vision requests
        do {
            try imageRequestHandler.perform(requests)
            
            // Process results for each request
            for request in requests {
                if let request = request as? VNDetectHumanHandPoseRequest {
                    spatialOutput.handPose = detectedHandPose(request: request)
                } else if let request = request as? VNDetectHumanBodyPoseRequest {
                    spatialOutput.bodyPose = detectedBodyPose(request: request)
                } else if let request = request as? VNDetectFaceLandmarksRequest {
                    spatialOutput.facePose = detectedFacePose(request: request)
                }
            }
        } catch {
            Logger.vision(level: .error, "Unable to perform the requests: \(error.localizedDescription).")
        }
        
        // Process the sample buffer to get an image (common for all cases)
        guard let bufferTest = sampleBuffer.imageBuffer else {
            return
        }
        spatialOutput.outputImage = createCGImage(from: bufferTest)
        
        DispatchQueue.main.async {
            self.output = spatialOutput
        }
    }

And for reference, here is one of the pose request functions:

func detectedBodyPose(request: VNRequest) -> [VNHumanBodyPoseObservation.JointName: VNRecognizedPoint]? {
        
        guard let bodyPoseResults = request.results as? [VNHumanBodyPoseObservation] else {
            return nil
        }
        
        guard let bodyPoseParts = try? bodyPoseResults.first?.recognizedPoints(.all) else {
            return nil
        }
        
        let filteredBodyPoseParts = bodyPoseParts.filter { $0.value.confidence > self.confidence }
        
        return filteredBodyPoseParts
    }

Any and all help is appreciated, when we have time, we can also provide a sample project with this.

This does look like a known issue on our end. As a temporary workaround, try explicitly setting the revision on the body pose request:

if self.selectedRequests.body {
    let bodyPoseRequest = VNDetectHumanBodyPoseRequest()
    bodyPoseRequest.revision = VNDetectHumanBodyPoseRequestRevision1
    requests.append(bodyPoseRequest)
}
Help Needed: Error Codes in VCPHumanPoseImageRequest.mm[85] and NSArrayM insertObject
 
 
Q