I am trying to restart the sceneView.session by using a function called restartSession(). I found that I was getting random crashes when calling this function.
My viewDidLoad():
override func viewDidLoad() {
super.viewDidLoad()
self.sceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints, ARSCNDebugOptions.showWorldOrigin]
self.sceneView.session.run(configuration)
self.sceneView.autoenablesDefaultLighting = true
}
My restartSession() function:
func restartSession() {
self.sceneView.session.pause()
self.sceneView.scene.rootNode.enumerateChildNodes { (node, _) in
node.removeFromParentNode()
}
self.sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
I am running Xcode 9.4 beta and iOS 11.3.1