My app has 2 targets, iOS and visionOS. It uses some Metal code for rendering.
If I compile it with Swift 5, rendering works as expected.
With Swift 6, rendering hits unexpectedly an internal breakpoint:
This happens for iOS and visionOS, for the simulators and the devices.
Apparently, code that is executed to run on a certain queue is executed on another queue. The only queue related to Metal in my code is a MTLCommandQueue
.
I guess this is a bug in the library, but I am of course not sure.
Is there anything I can do to get the code running?
I found the instruction that does not work under Swift 6 (I should have done this earlier, sorry).
My app uses a PerspectiveCamera
in a RealityKit entity.
Currently there is bug in RealityKit (confirmed by Apple) that does not allow to use the output of an additional PerspectiveCamera
directly. Instead, one has to use a RealityRenderer
.
To its property entities
, a PerspectiveCamera
can be appended. Its output is rendered to a MTLTexture
. It can be assigned to the metalLayer
of a UIKit UIView
, which is then displayed as a UIViewRepresentable
in SwiftUI.
A RealityRenderer
has a function updateAndRender
that renders its entities including the output of a PerspectiveCamera
, see here.
This function works under Swift 5, but hits the internal breakpoint under Swift 6, before the handler onComplete
is called.
So I guess this is a bug in RealityKit, and I will write a bug report.