1 Reply
      Latest reply on Jun 17, 2019 5:13 PM by gchiste
      Hannah_Swift Level 1 Level 1 (0 points)

        I have two ViewControllers one with the ARSCNView and one with just some data. When switching back from the second view controller to the first I can't get the ARSession to work right. It loses completely the orientation and can't detect the feature points correctly.


        I already trief saving the world map and restoring it after the Back Button from one view to another is hit.

        I also tried all the resetting stuff on the Session that is already provided on stack overflow

        I do overwrite those methods:


        override func viewWillDisappear(_ animated: Bool) {
                // Pause the view's session
                print("view did disappear")
                sceneView.session.getCurrentWorldMap { (worldMap, error) in
                    guard let worldMap = worldMap else {
                        print("Error getting current world map.")
                    do {
                        try self.archive(worldMap: worldMap)
                        DispatchQueue.main.async {
                            print("World map is saved.")
                    } catch {
                        fatalError("Error saving world map: \(error.localizedDescription)")
        override func viewWillAppear(_ animated: Bool) {
                let worldMapData = retrieveWorldMapData(from: worldMapURL)
                var worldMap: ARWorldMap? = nil
                if worldMapData != nil {
                    worldMap = unarchive(worldMapData: worldMapData!)
                resetTrackingConfiguration(with: worldMap)
        override func viewDidAppear(_ animated: Bool) {
         func resetTrackingConfiguration(with worldMap: ARWorldMap? = nil) {
             let configuration = ARWorldTrackingConfiguration()
            configuration.planeDetection = [.horizontal]
            let options: ARSession.RunOptions = [.resetTracking, .removeExistingAnchors]
            if let worldMap = worldMap {
               configuration.initialWorldMap = worldMap
               print("Found saved world map.")
            } else {
               print("Move camera around to map your surrounding space.")
            sceneView.debugOptions = [.showFeaturePoints, .showWireframe]
            sceneView.session.run(configuration, options: options

        I  just want my ARSession to work normal after hitting the back button of the UINavigation