I have a photo editing app which uses a simple Metal Render to display CIFilter output images. It works just fine in Swift 5 but in Swift 6 it crashes on starting the Metal command buffer with an error in the Queue : com.Metal.CompletionQueueDispatch (serial).
The crash is occurring before I can debug.. I changed the command buffer to report MTLCommandBufferDescriptorStatus errorOptions = .encoderExecutionStatus.
No luck with getting insight into the source of the crash.. Likewise the error is happening before any of the usual Metal debug tools are enabled.
The Metal render works just fine in Swift 5 and also works fine with almost all of the Swift Compiler Upcoming feature flags set to Yes. [The "Default Internal Imports" flag is still No. (the number of compile errors with this setting is absolutely scary! but that's another topic)
Do you have any suggestions on debugging or ideas on why the Metal library is crashing in Swift 6???
Everything is current release versions and hardware.
Thanks to Quinn's extended explaination in another thread the problem is fixed by adding @Sendable to the Metal command queue command buffer's completion handler. The app is now running on Swift 6
commandBuffer.addCompletedHandler { @Sendable (_ commandBuffer)-> Swift.Void in ...
The compiler team should consider adding information that can be used for correcting the problem. Right now the assert crash is completely cryptic to me and has no usable information about the cause.
[(https://developer.apple.com/forums/thread/764777?answerId=807248022#807248022)]