Post

Replies

Boosts

Views

Activity

Reply to Crash inside of Vision framework during VNImageRequestHandler use
I might have found a workaround, which might just work for your cases as well. As indicated in my previous post, I tried working around the issue by not using VNImageRequestHandler, but rather by using the CoreML model's predictions directly. In that case, I still passed it a CGImage. The generated CoreML model classes though also expose methods that accept a CVPixelBuffer as input - and the crash occurs in a function that converts the CGImage to a CVPixelBuffer. I put symbolic breakpoints at -[VNWeakTypeWrapperCollection addObject:droppingWeakZeroedObjects:], which was consistently called before this change, and is no longer called after creating the CVPixelBuffers manually. I hope this may help others as well - and I hope the problem stays away with this. If I still get issues, will keep you posted.
Topic: Machine Learning & AI SubTopic: General Tags:
Feb ’25
Reply to Crash inside of Vision framework during VNImageRequestHandler use
I'm still experiencing these same issues in iOS 18.3 and up. I tried working around using Vision's VNImageRequestHandler by using my CoreML model directly, but I end up with a similar stack trace, resulting in the same crash: "*** -[NSMutableArray removeObjectsAtIndexes:]: index 0 in index set beyond bounds for empty array" 0 CoreFoundation 0x1a091e5fc __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x19de99244 objc_exception_throw + 88 (objc-exception.mm:356) 2 CoreFoundation 0x1a09b309c -[NSMutableArray removeObjectsAtIndexes:] + 960 (NSMutableArray.m:309) 3 Vision 0x1c1a314bc -[VNWeakTypeWrapperCollection _enumerateObjectsDroppingWeakZeroedObjects:usingBlock:] + 244 (VNWeakTypeWrapper.mm:126) 4 Vision 0x1c1a31154 -[VNWeakTypeWrapperCollection addObject:droppingWeakZeroedObjects:] + 172 (VNWeakTypeWrapper.mm:137) 5 Vision 0x1c1a36eec -[VNSession initWithCachingBehavior:] + 316 (VNSession.mm:352) 6 Vision 0x1c1c656f4 -[VNImageBuffer initWithCGImage:orientation:options:] + 56 (VNImageBuffer.mm:954) 7 CoreML 0x1bc73e534 -[_MLVNFrameworkHandle createPixelBufferFromCGImage:constraint:cropRect:cropAndScaleOption:options:error:] + 160 (_MLVNFrameworkHandle.m:275) 8 CoreML 0x1bc8093d4 +[MLFeatureValue(MLImageConversion) featureValueWithCGImage:constraint:options:error:] + 172 (MLFeatureValue+MLImageConversion.m:136) 9 CoreML 0x1bc8094f0 +[MLFeatureValue(MLImageConversion) featureValueWithCGImage:pixelsWide:pixelsHigh:pixelFormatType:options:error:] + 132 (MLFeatureValue+MLImageConversion.m:118) 10 MyApp 0x10223b3f8 @nonobjc MLFeatureValue.__allocating_init(cgImage:pixelsWide:pixelsHigh:pixelFormatType:options:) + 40 (/<compiler-generated>:0) 11 MyApp 0x10223b3f8 specialized mlModelInput.__allocating_init(imageWith:iouThreshold:confidenceThreshold:) + 40 (mlModel.swift:45) 12 MyApp 0x10223b3f8 mlModelInput.__allocating_init(imageWith:iouThreshold:confidenceThreshold:) + 40 (/<compiler-generated>:0) Is this issue being addressed soon, or might there at least be a viable workaround? It didn't seem to occur pre-iOS18/macOS15
Topic: Machine Learning & AI SubTopic: General Tags:
Feb ’25