When New View appears on Scene View App is Freezed

Viewed 1170

In one of my iOS App development project, whenever I am trying to push a view on ARSCNView. the app is freezing here below is my code. Please suggest an appropriate solution if you are aware of the same.

-> getting app froze when push view on sceneView controller

 let session = ARSession()
        var sessionConfig: ARSessionConfiguration = ARWorldTrackingSessionConfiguration()
        var use3DOFTracking = false {
            didSet {
                if use3DOFTracking {
                    sessionConfig = ARSessionConfiguration()
                }
                sessionConfig.isLightEstimationEnabled = true
                session.run(sessionConfig)
            }
        }    
    }

override func viewDidLoad() {
        super.viewDidLoad()
        self.setupScene()
        setupSession()
}

override func viewWillAppear(_ animated: Bool) {
        self.tabBarController?.tabBar.isHidden = false
        session.run(sessionConfig, options: [.resetTracking, .removeExistingAnchors])
    }

override func viewDidDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    session.pause()
}


 func setupScene() {
        sceneView.delegate = self
        sceneView.session = session
        sceneView.antialiasingMode = .multisampling4X
        sceneView.automaticallyUpdatesLighting = false

        sceneView.preferredFramesPerSecond = 60
        sceneView.contentScaleFactor = 1.3
        //sceneView.showsStatistics = true

        enableEnvironmentMapWithIntensity(25.0)

        if let camera = sceneView.pointOfView?.camera {
            camera.wantsHDR = true
            camera.wantsExposureAdaptation = true
            camera.exposureOffset = -1
            camera.minimumExposure = -1
        }
    }

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