Alternative to `writeHEIF10Representation` for writing a `CIImage` to HEIF10

I'm running into hard crashes (EXC_BAD_ACCESS) when calling CIContext.writeHEIF10Representation or CIContext.heif10Representation from multiple threads. By contrast, concurrent access to writeHEIFRepresentation works fine.

Does anyone know any other way to write a CIImage to 10-bit HEIF? I've tried several alternatives using CVPixelBuffer and MTLTexture without success.

While I've filed a report through Feedback Assistant, I'm looking for a workaround. Writing thousands of 10-but hdr heif images within a single thread is an absolute throughput killer, whereas I can write any other image format without concurrency issues.

Thanks!

Answered by mallman in 748983022

Following up, Apple fixed this issue in macOS 13.3. Concurrent calls to CIContext.writeHEIF10Representation no longer crash. Thanks, Apple!

Are you using the same CIContext in all threads? And can you please post a screenshot of the stack when the crash happens?

Hi Frank. I have tried using one CIContext per thread as well as sharing one across threads. I've posted a dead simple Xcode workspace illustrating the crash with simple Swift and Objc apps at https://github.com/mallman/ConcurrentCoreImageHEIF10. Since there are many relevant threads with different stack traces when the app crashes, a screenshot of a single thread's stack trace really isn't very informative. I hope the project is helpful.

Accepted Answer

Following up, Apple fixed this issue in macOS 13.3. Concurrent calls to CIContext.writeHEIF10Representation no longer crash. Thanks, Apple!

Alternative to `writeHEIF10Representation` for writing a `CIImage` to HEIF10
 
 
Q