Search code examples
iosscenekitarkitsceneview

Sceneview freezes when present web view controller


I'm using Safari Services kit to present a web view when an SCNode is clicked. However, when I go back from the safariVC to my VC with the sceneView, the sceneView is frozen even though I restart the session by re-running the session.

I read on this website that presenting another VC kills the scene view thread and I would just like confirmation. Basically I want to know whether it is possible to present another VC and be able to go back to the sceneView and "resume" the scenView

Note:

  • VC = ViewController

Code

How I present my safari web VC

func presentWebView(){
    if let url = URL(string: "https://www.amazon.com/"){
        let safariVC = SFSafariViewController(url: url)
        self.present(safariVC, animated: true, completion: nil)
    }
}

How I restart my session

if let worldSessionConfig = sessionConfig as? ARWorldTrackingSessionConfiguration {
    worldSessionConfig.planeDetection = .horizontal
    session.run(worldSessionConfig, options: [.resetTracking, .removeExistingAnchors])
}

Solution

  • Use sceneView.session.pause() when you present safariVC and then use sceneView.session.run to restart session when safariVC is dismissed.