Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom LocationEngine is not always respected #1694

Closed
richjhart opened this issue Jan 23, 2019 · 7 comments
Closed

Custom LocationEngine is not always respected #1694

richjhart opened this issue Jan 23, 2019 · 7 comments

Comments

@richjhart
Copy link

Android API: 28 (Android 9)
Mapbox Navigation SDK version: 0.27.0

Steps to trigger behavior

  1. Provide a custom location engine (in this case based off a ReplayRouteLocationEngine) in the NavigationViewOptions options
  2. Begin navigation (using the custom LocationEngine)

Expected behavior

At all times, the route position is based on the locations provided by the custom LocationEngine. In our case it should exactly follow the route provided

Actual behavior

At the start of navigation, and on a few occasions throughout the route, the "route" location suddenly jumps to the user's real physical location before jumping back to the simulated position.

In general, this doesn't cause us too much problem as it's only very brief, but it is very strange and suggests that somehow the real GPS location is getting to the Navigation Engine, even though it should never be provided by a ReplayRouteLocationEngine.

I'm still in the process of putting some logging it to try to "catch" where it comes from.

@richjhart
Copy link
Author

Update: It seems in might only be a visual thing.

I have setup some logging to make it clear if the snapped location (in ProgressChangeListener.onProgressChange()), or the "real" location (from LocationEngineCallback<LocationEngineResult>.onSuccess(LocationEngineResult result) ever gives a value that doesn't match the route. (I have deliberately provided a route which is only in positive longitudes, while I'm in a negative longitude).

At the start, and a couple of times during the simulated route, the snapped location puck jumped back to my real location, but the locations seen by our code never did.

I've looked in the latest mapbox code and I notice that the layers that contain the snapped location puck (mapbox-location-shadow, etc), don't seem to appear in the code. Is this now handled elsewhere?

@danesfeder
Copy link
Contributor

@richjhart we will look into this, thanks for the debugging you've done already. We have been seeing some weird behavior from ReplayRouteLocationEngine > #1678.

Is there a reason you are passing ReplayRouteLocationEngine? You should also be able to set simulation to true in the NavigationViewOptions (we are using one in our code for simulation).

@danesfeder
Copy link
Contributor

Also if you're able to capture this in a .gif and attach that to this ticket, that would be great.

@richjhart
Copy link
Author

@danesfeder I will try to capture it when I get a chance - though it's possible it's the same as #1678 and maybe I just had something wrong with the debug code so missed it, or in our setup it behaves a bit differently.

The reason we're doing it this way is that we have three modes for development: normal, simulated, and manual. In both normal and simulated we want to be able to switch to manual so our LocationEngine is a wrapper which then either uses a real location engine or a replay engine. At any point we can shut down and ignore that one and use our own manual location.

@danesfeder
Copy link
Contributor

@richjhart As of #1615, the NavigationView just decides which LocationEngine to give to MapboxNavigation https://github.com/mapbox/mapbox-navigation-android/blob/master/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/location/LocationEngineConductor.java

Although maybe in this case, re-assigning the route (for replay) or some of that logic is throwing something off.

@richjhart
Copy link
Author

Of course now that I've tried to record the issue, it hasn't been happening. I'll keep an eye on it.

Nope that I am still just providing a single LocationEngine at the start. It's just that that LocationEngine may have another one underneath it.

@danesfeder
Copy link
Contributor

danesfeder commented Jan 25, 2019

@richjhart this ticket got me thinking and sure enough I believe I found a bug. In NavigationMapboxMap we were allowing the LocationComponent to activate a default LocationEngine in the background. So what seems to be happening here with the replay engine is your phone is obviously sitting in the same spot while replaying a route.

This means we have competing updates from the default engine in the component and the replay engine that you're providing. And sometimes the actual GPS update hits the component, causing the quick map movement back to your position.

In the NavigationMapboxMap, we should only ever use LocationComponet#forceLocationUpdate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants