Post

Replies

Boosts

Views

Activity

SKScene as SCNPlane material diffuse content frame drop or crash with scene prepare
Hello, I'm trying to place and play a local video on a detected ARKit image. Here's a code example which has either the frame drop (camera view freezes for ~ half a second) or the crash: guard let fileUrlString = Bundle.main.path(forResource: "videoname", ofType: "mp4") else { return }         let videoItem = AVPlayerItem(url: URL(fileURLWithPath: fileUrlString))         let videoPlayer = AVPlayer(playerItem: videoItem)         let videoNode = SKVideoNode(avPlayer: videoPlayer)         let videoScene = SKScene(size: CGSize(width: 1080, height: 1080))         videoScene.addChild(videoNode)         let videoPlane = SCNPlane(width: 0.1, height: 0.1)         /* CAUSE OF FRAME DROP ON FIRST ADDCHILDNODE */         videoPlane.firstMaterial?.diffuse.contents = videoScene         let videoPlaneNode = SCNNode(geometry: self.videoPlane)         videoPlaneNode.eulerAngles.x = -Float.pi * 0.5         /* CAUSE OF CRASH IF UNCOMMENTED WITH 		 videoScene AS MATERIAL DIFFUSE CONTENT */         self.sceneView.prepare([videoPlaneNode], completionHandler: { (success) in self.sceneView.scene.rootNode.addChildNode(videoPlaneNode)         })         self.sceneView.scene.rootNode.addChildNode(videoPlaneNode) I was trying to use the prepare method to avoid frame drops (not sure I'm using it correctly) but it crashes with this message: SceneKit`C3DSceneGetAnimationManager:>	0x1ac5c36b4 <+0>: ldr		x0, [x0, #0x48] 		0x1ac5c36b8 <+4>: ret		 EXC_BAD_ACCESS How can I solve this? Thanks
0
0
518
Jul ’20