mapbox-navigation-ios
mapbox-navigation-ios copied to clipboard
Puck keeps simulating on preview map after ending navigation
Mapbox Navigation SDK version
2.0.0
Steps to reproduce
- choose Example, choose a customized location, start navigation under simulation mode
- cancel navigation
Expected behavior
The user location indicator should stop because there's no location update
Actual behavior
There're continuous location update under the passive location provider, which triggers the user location indicator moving in the NavigationMapView as following:

Is this a one-time issue or a repeatable issue?
repeatable
Another thing that I've noticed is that on the latest version of Navigation SDK, which is based on v79.0 or higher, we'll start simulation after a couple of seconds of being stale. This is unexpected, since we do not have any location updates.
In fact we noticed this issue since we adopted Nav Native 78.0.0 as in the slack .
I've checked that it's nothing to do with the simulation mode. After the navigation service ends, we create a new NavigationMapView, and set PassiveLocationProvider to its mapView to override. But we still observe the location update sending from its locationManager, which is NavigationLocationManager that conforms to the CLLocationManager. Which means that even we set to fixed location to the iphone, there's still the location update from the background that simulates the navigation route. Even we manually set the allowsBackgroundLocationUpdates of the PassiveLocationManager.systemLocationManager to false, it still sending the location update.
And the cause seems to be that the navigator as the NavigatorObserver keeps observing location update even after the navigation service ends and the user is still in location in a PassiveLocationManager status. But the navigator still sending the simulated location update status to the NotificationCenter as in the following:
https://github.com/mapbox/mapbox-navigation-ios/blob/03523ae1a59e8949bf20fa09b2e6ee25ef5a05d5/Sources/MapboxCoreNavigation/CoreNavigationNavigator.swift#L249-L260
Hi @etl , could you take a look at this issue? We've observed the issues related with our navigator as following:
- when user is still, the
NavigatorObserverkeeps receiving the new navigation status as above . - when the navigation service ends, the
NavigatorObserverreceiving the simulated location update status from the last navigation session.
Right now in our example, when we cancel or end the navigation session, we nil out the NavigationViewController and stop the navigation service.
@ShanMa1991
Now, the navigator is sending statuses even when there are no UpdateLocations. This is done in order to run the simulation in places where GPS does not work. If you will receive thisNavigationStatus, then NavigationStatusOrigin will be equal to NavigationStatusOrigin::Unconditional.
If you don't need such statuses, you can unsubscribe from the observer, or use the pause() resume() methods
@mapbox/navigation-ios
I think we should unsubscribe from the observer when the user location is still. The simulated status sending from the background causes the rerouting event and a seconds-delay at the start of active navigation in our Example App. Several crashes are observed related with the unsynced routeProgress which triggers the precondition failure, when we start and cancel navigation several times.
Please consider pause/resume, that Stas mentioned, this was design specifically for similar cases.
A note: Pause/resume is controlled for billing purposes as well. Simply calling pause/resume from another place will likely to produce undefined behavior.
The simulated status sending from the background causes the rerouting event and a seconds-delay at the start of active navigation in our
ExampleApp.
@ShanMa1991 Can you please clarify what is meant by "from the background" in this case?
@S2Ler Right now we nil out the NavigationMapView for route preview after the active navigation session starts in our Example, but because the navigator stills sending simulated navigation status to the PassiveLocationManager even user is still, we could see the rerouting triggered. And I'm not quiet sure whether it's related with the delay of the start of the active navigation.
For the pause/resume, it would be one way to provide a fix to avoid the simulated location updates while user is still. But how could we stop dealing with the simulated (wrong) location status update in active/passive navigation?
For the pause/resume, it would be one way to provide a fix to avoid the simulated location updates while user is still. But how could we stop dealing with the simulated (wrong) location status update in active/passive navigation?
I don't think we should just filter out NavNative updates because we think that they are "incorrect". Maybe we shall use Navigator.resetRideSession after simulation.
navigator stills sending simulated navigation status to the PassiveLocationManager even user is still, we could see the rerouting triggered. And I'm not quiet sure whether it's related with the delay of the start of the active navigation.
I'm confused here. How sending status updates to PassiveLocationManager can trigger reroute?
And I'm not quiet sure whether it's related with the delay of the start of the active navigation.
Can you please provide more info. I don't quite understand this whole problem yet.
Several crashes are observed related with the unsynced
routeProgresswhich triggers thepreconditionfailure, when we start and cancel navigation several times.
I still not able to reproduce this crash. @ShanMa1991 what commit hash do you use for the tests? Can you make a video where this crash is reproduced in Xcode?
@S2Ler According to the NavNative side, that NavigationStatusOrigin::Unconditional says the status is simulated. If in this case, during the free drive or active navigation, should our navigator stop sending out the simulated status? For example, from the UI perspective, when the user is still and active navigation session ends, the map puck should be still. But right now the map puck shows the user is moving, and there's constant location update about the user.
But right now the map puck shows the user is moving, and there's constant location update about the user.
@ShanMa1991 Does this happens only after simulated active drive?
@S2Ler Not sure, because Navigator is expected to send out the simulated status when user is still. And when we cancel the navigation and shut down the app and then open again, it still happens.
user is still
By user is still, do you mean that we don't provide locations to Native Navigator or that we provide the same location every second?
user is still
By user is still, do you mean that we don't provide locations to Native Navigator or that we provide the same location every second?
I think @ShanMa1991 was referring to the user being at rest, not moving anywhere. It would surprise the user to see the puck keep moving if they aren’t moving. But Core Location normally continues to produce location updates at a steady rate regardless of the user’s inactivity. Moreover, if the application and SDK manages to completely shut off any location and heading updates going to the navigator, the navigator synthesizes its own simulated location updates to compensate. (SimulatedLocationManager does something similar during turn-by-turn navigation.)
@mskurydin , could you please take a look and suggest proper way to handle this?