2

I have setup a AR project. All seems to be working but I am not able to keep the AR session going when I present and dismiss a view controller over it.

So, I have a AR session setup like Xcode's sample project shows. Pretty simple. I then do this when the user taps on a button on the screen:

let myVC = MyVC()
present(myVC, animated: true) {

}

MyCV comes on screen and then I select an option, then the screen is dismissed:

dismiss(animated: true) {  }

After MyVC is dismissed the ARSession looks frozen on in the view controller.

So, I thought maybe I have to tell it to run again so I added this line in the completion:

dismiss(animated: true) { 
    self.sceneView.session.run(ARWorldTrackingSessionConfiguration())
}

Nothing.

then I check on the delegate calls to make sure I wasn't getting any error:

func session(_ session: ARSession, didFailWithError error: Error) {
    // Present an error message to the user

}

func sessionWasInterrupted(_ session: ARSession) {
    // Inform the user that the session has been interrupted, for example, by presenting an overlay

}

func sessionInterruptionEnded(_ session: ARSession) {
    // Reset tracking and/or remove existing anchors if consistent tracking is required

}

None of those is ever called during that process.

Why does the AR session appear frozen when precasting and dismissing a simple ViewController over it?

zumzum
  • 17,984
  • 26
  • 111
  • 172
  • What presentation style are you using for `MyVC`? See [ARKit Session Paused and Not Resuming](https://stackoverflow.com/q/44979559/957768). – rickster Jul 10 '17 at 21:55
  • @rickster I did not modify it, the default, UIModalPresentationStyle.fullScreen – zumzum Jul 10 '17 at 22:41
  • @rickster I just tried "UIModalPresentationStyle.popover" and same logic does not freeze the AR... so, it's working now with popover... so, this means I can't use a fullSCreen? – zumzum Jul 10 '17 at 22:43
  • As noted in the linked Q&A, you shouldn't *want* to present another VC fullscreen if you expect the user to come back to the same AR experience afterward, because the only "safe" thing you can do upon coming back from a period without tracking is lose all the AR content. – rickster Jul 10 '17 at 22:47
  • Yup, makes sense. I was thinking about this the wrong way. Thx. – zumzum Jul 11 '17 at 03:07

0 Answers0