ARKit Session Not Resuming After Showing Modal

In my ARKit app I am presenting a modal window. When I close the modal and go back to the ARSCNView then I find out that the session is paused due to this code:



  override func viewWillDisappear(_ animated: Bool) {
            super.viewWillDisappear(animated)
        
            // Pause the view's session
            sceneView.session.pause()
        }


When I close the modal and go back to the ARKit camera view screen this code gets fired:





    override func viewWillAppear(_ animated: Bool) {
            super.viewWillAppear(animated)
        
            // Create a session configuration
            let configuration = ARWorldTrackingSessionConfiguration()
        
            // Run the view's session
            sceneView.session.run(configuration)
        }


But this code never resumes the session. The screen is completely frozen on the last image it read. Any ideas?


I changed my viewWillAppear to the following and still frozen at the frame. Possible BUG!


override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
       
        /
        let configuration = ARWorldTrackingSessionConfiguration()
       
        sceneView.session.delegate = self
       
        if self.isPaused {
            sceneView.session.run(sceneView.session.configuration!)
        } else {
            /
            sceneView.session.run(configuration)
        }
    }

Replies

Bump. Same issue here. Using Xcode 9 Beta 3

Seeing the same issue.

Bump. Same issue on beta 3

Are you sure viewWillAppear is actually getting called? I can get the sceneView to pause and resume the AR session with the same code.

Bump. Same issue on beta 3, I can add the following observations,


The AR session is executing in the background since func session(_ session: ARSession, cameraDidChangeTrackingState camera: ARCamera) is getting called with updates about the tracking state.


The camera is also operating in the background since the session.currentFrame?.capturedImage updates with new frames.


It seems like the ARSCNView won't update or call func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval), like the SCNView is in a stopped state.

Bump. Same issue on Beta 3


Yes I have confirmed viewWillAppear is actually getting called both on the first appearance and after dismissing the Modal screen.

This seems to have been fiixed in Beta 4

I’m not seeing this fixed in Beta4 --AR Camera is still frozen after returning to the ARSceneView.


Confirmed that viewDidLoad is called when returning to the parent ARSceneView, and re-running the SceneView configuration doesn’t do anything.

I had the same problem. Fixed it with showing the modal view like this:



myModalViewController.modalPresentationStyle = .custom
self.present(myModalViewController, animated: true, completion: nil)


In addition I didn't pause the ARSession. But I´m not sure if this has any effect on this.

Confirmed this is fixed with Xcode Beta4 and iOS 11 beta 4.