Crash inside of Vision predictWithCVPixelBuffer - Crashed: com.apple.VN.detectorSyncTasksQueue.VNCoreMLTransformer

Hello,

We have been encountering a persistent crash in our application, which is deployed exclusively on iPad devices. The crash occurs in the following code block:

        let requestHandler = ImageRequestHandler(paddedImage)
        var request = CoreMLRequest(model: model)
        request.cropAndScaleAction = .scaleToFit
        let results = try await requestHandler.perform(request)

The client using this code is wrapped inside an actor, following Swift concurrency principles.

The issue has been consistently reproduced across multiple iPadOS versions, including:

iPad OS - 18.4.0 iPad OS - 18.4.1 iPad OS - 18.5.0

This is the crash log -

          Crashed: com.apple.VN.detectorSyncTasksQueue.VNCoreMLTransformer
0  libobjc.A.dylib                0x7b98 objc_retain + 16
1  libobjc.A.dylib                0x7b98 objc_retain_x0 + 16
2  libobjc.A.dylib                0xbf18 objc_getProperty + 100
3  Vision                         0x326300 -[VNCoreMLModel predictWithCVPixelBuffer:options:error:] + 148
4  Vision                         0x3273b0 -[VNCoreMLTransformer processRegionOfInterest:croppedPixelBuffer:options:qosClass:warningRecorder:error:progressHandler:] + 748
5  Vision                         0x2ccdcc __119-[VNDetector internalProcessUsingQualityOfServiceClass:options:regionOfInterest:warningRecorder:error:progressHandler:]_block_invoke_5 + 132
6  Vision                         0x14600 VNExecuteBlock + 80
7  Vision                         0x14580 __76+[VNDetector runSuccessReportingBlockSynchronously:detector:qosClass:error:]_block_invoke + 56
8  libdispatch.dylib              0x6c98 _dispatch_block_sync_invoke + 240
9  libdispatch.dylib              0x1b584 _dispatch_client_callout + 16
10 libdispatch.dylib              0x11728 _dispatch_lane_barrier_sync_invoke_and_complete + 56
11 libdispatch.dylib              0x7fac _dispatch_sync_block_with_privdata + 452
12 Vision                         0x14110 -[VNControlledCapacityTasksQueue dispatchSyncByPreservingQueueCapacity:] + 60
13 Vision                         0x13ffc +[VNDetector runSuccessReportingBlockSynchronously:detector:qosClass:error:] + 324
14 Vision                         0x2ccc80 __119-[VNDetector internalProcessUsingQualityOfServiceClass:options:regionOfInterest:warningRecorder:error:progressHandler:]_block_invoke_4 + 336
15 Vision                         0x14600 VNExecuteBlock + 80
16 Vision                         0x2cc98c __119-[VNDetector internalProcessUsingQualityOfServiceClass:options:regionOfInterest:warningRecorder:error:progressHandler:]_block_invoke_3 + 256
17 libdispatch.dylib              0x1b584 _dispatch_client_callout + 16
18 libdispatch.dylib              0x6ab0 _dispatch_block_invoke_direct + 284
19 Vision                         0x2cc454 -[VNDetector internalProcessUsingQualityOfServiceClass:options:regionOfInterest:warningRecorder:error:progressHandler:] + 632
20 Vision                         0x2cd14c __111-[VNDetector processUsingQualityOfServiceClass:options:regionOfInterest:warningRecorder:error:progressHandler:]_block_invoke + 124
21 Vision                         0x14600 VNExecuteBlock + 80
22 Vision                         0x2ccfbc -[VNDetector processUsingQualityOfServiceClass:options:regionOfInterest:warningRecorder:error:progressHandler:] + 340
23 Vision                         0x125410 __swift_memcpy112_8 + 4852
24 libswift_Concurrency.dylib     0x5c134 swift::runJobInEstablishedExecutorContext(swift::Job*) + 292
25 libswift_Concurrency.dylib     0x5d5c8 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 156
26 libdispatch.dylib              0x13db0 _dispatch_root_queue_drain + 364
27 libdispatch.dylib              0x1454c _dispatch_worker_thread2 + 156
28 libsystem_pthread.dylib        0x9d0 _pthread_wqthread + 232
29 libsystem_pthread.dylib        0xaac start_wqthread + 8

We found an issue similar to us - https://developer.apple.com/forums/thread/770771.

But the crash logs are quite different, we believe this warrants further investigation to better understand the root cause and potential mitigation strategies.

Please let us know if any additional information would help diagnose this issue.

Answered by DTS Engineer in 849015022

Hello,

It looks like you're using the new API so the suggestion in https://developer.apple.com/forums/thread/770771 may not apply.

In order to fully diagnose the problem with help from framework engineering please send us a bug report using the Feedback Assistant. If possible, include a focused sample project that consistently reproduces the issue.

Hello,

It looks like you're using the new API so the suggestion in https://developer.apple.com/forums/thread/770771 may not apply.

In order to fully diagnose the problem with help from framework engineering please send us a bug report using the Feedback Assistant. If possible, include a focused sample project that consistently reproduces the issue.

Thanks for your help,

I have submitted the bug report using the Feedback Assistant. Unfortunately, the bug occurs quite randomly so it's not easy to create a focused project to reproduce the issue.

Would you have any ideas / are there any similar issues that might have come up recently? That would help us with the debugging of the issue.

Thank you!

On the crash, can you tell what Vision.framework is doing?

On my iOS 18.5 (I don't have iPad, but I suppose it's similar, if not same.), the crash point (-[VNCoreMLModel predictWithCVPixelBuffer:options:error:] + 148) is attempting to access .model property of VNCoreMLModel object.

(lldb) dis -s 0x00000001bc61626c -e 0x00000001bc61626c+148
Vision`-[VNCoreMLModel predictWithCVPixelBuffer:options:error:]:
:
    ;; x0 is self, which is `VNCoreMLModel` object.
    0x1bc616290 <+36>:  mov    x23, x0
:
    ;; Accessing `.model` property of the `VNCoreMLModel` object.
    0x1bc6162f8 <+140>: mov    x0, x23
    0x1bc6162fc <+144>: bl     0x1bc857f60               ; objc_msgSend$model
    ;; Return address
    0x1bc616300 <+148>: bl     0x1bdf7d200

If you see the same, I might suspect the MLModel object stored in CoreMLModelContainer is somehow broken, perhaps overreleased. (It's hard to tell whether it's a framework bug or application's bug. )

Crash inside of Vision predictWithCVPixelBuffer - Crashed: com.apple.VN.detectorSyncTasksQueue.VNCoreMLTransformer
 
 
Q