I have been seeing some crash reports for my app on some devices (not all of them). The crash occurs while converting a CVPixelBuffer captured from Video to a JPG using VTCreateCGImageFromCVPixelBuffer from VideoToolBox. I have not been able to reproduce the crash on local devices, even under adverse memory conditions (many apps running in the background).
The field crash reports show that VTCreateCGImageFromCVPixelBuffer does the conversion in another thread and that thread crashed at call to vConvert_420Yp8_CbCr8ToARGB8888_vec.
Any suggestions on how to debug this further would be helpful.
Since the original post, changed the approach to create the JPEG image - used CIContext instead of VideoToolbox
let colorSpace = CGColorSpace(name: CGColorSpace.sRGB)
let jpeg = ciContext.jpegRepresentation(of: CIImage(cvPixelBuffer: pixelBuffer), colorSpace: colorSpace!)
It was still crashing. Attached is a crash log from using the CIContext approach.
I was able to reproduce the issue locally by using "Address Sanitizer" debug diagnostic setting in Xcode. Looks like the CVPixelBuffer may have some corruption in some cases. In any case, it is clear the issue is nothing to do with VideoToolbox.