5

I am trying to implement ARKit of iOS 11 beta in my app(Tabbed application). But as said in ARKit Session Paused and Not Resuming thread, whenever i change the tab to another view controller and come back, the ARSession is getting freezed and not resuming.

Is it possible to implement ARSCNView in a tabbed application so that if you come back i can resume the ARSession? If so how to do it?

Vasilii Muravev
  • 3,063
  • 17
  • 45
Vidhya Sri
  • 1,773
  • 1
  • 17
  • 46

1 Answers1

6

Yes, you can:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    let configuration = ARWorldTrackingSessionConfiguration()
    sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    sceneView.session.pause()
}

Stop session when view will disappear, and rerun session with clearing anchors and resetting tracking when view will appear. Also to avoid appearing and disappearing ASCNView better to use popup view controllers.

For better user experience, see how Apple did those popover screens in their demo project

Vasilii Muravev
  • 3,063
  • 17
  • 45
  • 5
    Yep. Even if you fix the "freezing" problem, you're effectively starting the user's AR experience over again from scratch if you leave for another full screen view controller and come back. Better to use popovers or similar to keep the AR view running, or design your app so that you don't need to leave an experience in progress. – rickster Jul 12 '17 at 16:01
  • 1
    @rickster 100% agree, Apple has good demo with those popovers https://developer.apple.com/sample-code/wwdc/2017/PlacingObjects.zip – Vasilii Muravev Jul 12 '17 at 16:04
  • 1
    @VasiliiMuravev Yes i have used the same sample code provided by apple and have also implemented sceneview.session.pause in viewWillDisappear. But still if i change the tab and come again, the session freezes. – Vidhya Sri Jul 13 '17 at 06:51
  • this doesn't work for me. the app still freezes when come back too – Weslley Wellington Nov 05 '18 at 10:48