Crash when setting preview layer on SceneKit material's diffuse contents

In my Mac app, I'm mirroring my iOS device to a Scenekit Object's material.

This works great on my Intel Mac, but not on my M1 Mac Mini.

Here's how I do it

First, make sure connected iOS devices can be discovered as AVCaptureDevices with this snippet

Then, add the device's input to the session and grab the layer from the session.

Code Block
let device = AVCaptureDevice.devices(for: .muxed).first! input = try! AVCaptureDeviceInput(device: device) session.addInput(input!) let layer = AVCaptureVideoPreviewLayer(session: session)

Finally, set the layer as the material's diffuse contents
Code Block
boxNode.geometry?.firstMaterial?.diffuse.contents = layer

What happens
On Intel, the device is now mirrored on the material. On M1, it crashes with a Bad Access exception.

I've tried holding on to all variables by setting them as class properties, but that was not it.

I've tried mirroring to an NSView's layer, and that works fine.

You can check out the entire project here