CIContext::heifRepresentation randomly crashing in iOS 16

The following call to heifRepresentation is causing occasional crashes in iOS 16.

context.heifRepresentation(of: image, format: CIFormat.RGBA8, colorSpace: perceptualColorSpace!, options: [kCGImageDestinationLossyCompressionQuality as CIImageRepresentationOption : 0.6] )

When we switch to context.jpegRepresentation:

return context.jpegRepresentation(of: image, colorSpace: perceptualColorSpace!, options: [kCGImageDestinationLossyCompressionQuality as CIImageRepresentationOption : compressionFactor])

The app runs fine.

Also, the context.heifRepresentation runs fine on iOS 15.

Can someone please help?

CIContext::heifRepresentation randomly crashing in iOS 16
 
 
Q