ARKit-CoreLocation icon indicating copy to clipboard operation
ARKit-CoreLocation copied to clipboard

Left the view and go back

Open hzuim opened this issue 5 years ago • 8 comments

Dear all,

When I leave the screen and return to the same screen the application freezes. The last message in the log says that:

camera did change tracking state: limited, initializing 2019-09-01 19:25:00.747079+0200 mylocations[6444:1562708] [Client] Discarding message for event 12 because of too many unprocessed messages 2019-09-01 19:25:00.748479+0200 mylocations[6444:1562708] [Client] Discarding message for event 12 because of too many unprocessed messages 2019-09-01 19:25:00.748845+0200 mylocations[6444:1562708] [Client] Discarding message for event 12 because of too many unprocessed messages 2019-09-01 19:25:00.749382+0200 mylocations[6444:1562708] [Client] Discarding message for event 12 because of too many unprocessed messages 2019-09-01 19:25:00.749853+0200 mylocations[6444:1562708] [Client] Discarding message for event 12 because of too many unprocessed messages

My code is:

override func viewDidLoad() { super.viewDidLoad()

    locationManager.delegate = self
    locationManager.desiredAccuracy = kCLLocationAccuracyBest
    locationManager.startUpdatingLocation()
    
    placesClient = GMSPlacesClient.shared()        
}

override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() sceneLocationView.frame = view.bounds }

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

override func viewWillAppear(_ animated: Bool) { locationManager.startUpdatingLocation() getPlaces() sceneLocationView.run() view.addSubview(sceneLocationView) }

Best Regards,

Hugo Zuim

hzuim avatar Sep 01 '19 17:09 hzuim

It seems that a UITabViewController is the issue here: https://github.com/hzuim/test

intere avatar Sep 03 '19 20:09 intere

Throwing away and recreating the SceneLocationView on viewWillAppear/WillDisappear "solved" it. in that the app no longer freezes. There's something that's getting wonky when switching tab views.

FWIW, this is the same behavior I see on Demo App when going to background/foreground. SceneLocationView setup is much more extensive in that app so I haven't tested my "solution". But perhaps there's a clue there.

class ARCLViewController: UIViewController {
    var sceneLocationView: SceneLocationView?
    
    override func viewWillAppear(_ animated: Bool) {
        let newSceneLocationView = SceneLocationView()
        newSceneLocationView.run()
        view.addSubview(newSceneLocationView)
        sceneLocationView = newSceneLocationView
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        // Pause the view's session
        
        sceneLocationView?.pause()
        sceneLocationView?.removeFromSuperview()
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        sceneLocationView?.frame = view.bounds
    }
}

halmueller avatar Sep 04 '19 01:09 halmueller

The sample project works correctly when built with Xcode 11b7 and run on an iPad 5th gen/iOS 13.0b (17A5572a) (final 13.0 beta as of 3 Sept, before the 13.1 beta dropped).

When built with Xcode 11b7 and run on an iPhone XS/12.4.1 I see the same freezes reported above.

halmueller avatar Sep 04 '19 10:09 halmueller

I seems like I experience the same issue, I see on the debugger that there is a deadlock. file: LocationNode.swift function: updatePositionAndScale: line 162: SCNTransaction.commit()

pichirichi avatar Sep 09 '19 13:09 pichirichi

I have a project built against 12.2 with Xcode 10.3 which I would expect to exercise this bug.

It does not. It happily goes into background and back to foreground and just keeps ticking. ARCL view works perfectly after app returns to foreground.

I have

        sceneLocationView?.pause()
        sceneLocationView?.removeFromSuperview()

in my viewWillDisappear() (and add/run calls in viewWillAppear()), but don't have the notification code in there to trigger the call when app is backgrounded.

This smells to me like something that can be fixed by requiring the latest SDK, and iOS version of current-1.

halmueller avatar Sep 10 '19 07:09 halmueller

Oh :(

Except that @hzuim's sample targets 12.4.

Resetting to "I don't understand this bug".

FWIW, I just ran the sample, and successfully switched to/away/to/away/to the ARCL tab. App didn't hang until the 2nd revisit of the ARCL tab (that is, the 3rd time I hit that tab).

halmueller avatar Sep 10 '19 07:09 halmueller

PR #249 fixed a memory leak specifically with the "dismiss and return back to POIViewController" sequence. You might want to pull the develop branch and retest.

Pilot-Marc avatar Nov 24 '19 20:11 Pilot-Marc

I had the problem too, but never happened again since ios 13 more infos: https://stackoverflow.com/a/44980399

ghost avatar Dec 06 '19 18:12 ghost