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 - https://github.com/mortenjust/Capture-device/blob/main/Capture%20device/ViewController.swift#L72
Then, add the device's input to the session and grab the layer from the session.
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
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 - https://github.com/mortenjust/Capture-device/tree/main/Capture%20device
0
0
998