mapbox / mapbox/mapbox-navigation-android
Navigation SDK 1.5 breaks off-route detection and voice instructions for first leg with >2 waypoints
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 651
- Forks
- 321
- PR merge metrics
- No merged PRs in 30d
Description
I've just upgraded my app from Navigation SDK 1.4.0 to 1.5.0 and have observed an issue.
If I create a route with >2 waypoints, and start navigation with the user located right at the first waypoint, then the navigation SDK reports that the user is off-route. I also noticed that the voice instructions that are read out are for the first step of the second leg (not the first leg).
The issue does not occur if:
1. I downgrade to 1.4.0
2. I use only two waypoints.
I can reliably reproduce this on 1.5.0 on both the simulator and a real phone. And it reliably does not appear on 1.4.0.
I'm using the simple Navigation UI component, and I have intentionally disabled rerouting (as I want the user to stick to the original route). Enabling re-routing does not make a difference - the user is still reported as being off-route (but then it re-routes them quite quickly afterwards).
**Android API: 30**
**Mapbox Navigation SDK version: 1.5.0 (issue does NOT occur with 1.4.0)**
### Minimal code example
@Override
public void onNavigationReady(boolean isRunning) {
if (!isRunning && navigationMapboxMap == null) {
if (navigationView.retrieveNavigationMapboxMap() != null) {
this.navigationMapboxMap = navigationView.retrieveNavigationMapboxMap();
CameraPosition position = new CameraPosition.Builder()
.target(new LatLng(51.48296,0.01291))
.zoom(15)
.build();
this.navigationMapboxMap.retrieveMap().setCameraPosition(position);
List coords = new LinkedList<>();
coords.add(Point.fromLngLat(0.012140957165058808, 51.4828513728437));
coords.add(Point.fromLngLat(0.0014954641793281098, 51.48814394775522));
coords.add(Point.fromLngLat(-0.002110267315146075, 51.50086499824096));
MapboxDirections dir = MapboxDirections.builder()
.waypoints(coords)
.overview(DirectionsCriteria.OVERVIEW_FULL)
.profile("walking")
.bannerInstructions(true)
.voiceInstructions(true)
.steps(true)
.voiceUnits("metric")
.accessToken(getString(R.string.mapbox_access_token))
.build();
dir.enqueueCall(new Callback() {
@Override
public void onResponse(Call call, Response response) {
DirectionsRoute route = response.body().routes().get(0);
doNav(route);
}
@Override
public void onFailure(Call call, Throwable t) {
}
});
}
}
}
private void doNav(DirectionsRoute route) {
NavigationOptions.Builder nb = new NavigationOptions.Builder(this).isDebugLoggingEnabled(true);
NavigationViewOptions.Builder builder = NavigationViewOptions.builder(this)
.navigationListener(this)
.directionsRoute(route)
.navigationOptions(nb.build())
.shouldSimulateRoute(false);
NavigationViewOptions navigationViewOptions = builder.build();
navigationView.startNavigation(navigationViewOptions);
// Do not re-route
navigationView.retrieveMapboxNavigation().setRerouteController(null);
this.offRouteObserver = b -> {
if (b) {
System.out.println("OFF ROUTE");
}
};
navigationView.retrieveMapboxNavigation().registerOffRouteObserver(this.offRouteObserver);
}
### Steps to trigger behavior
1. Start the Android simulator and set your current location to match the first waypoint (0.012140957165058808, 51.4828513728437)
2. Execute the sample code above, wait for navigation to begin
3. Observe that you're immediately reported off route. Also observe that the voice instruction that's read out is "Walk north east for 900 feet". This is the first voice instruction for leg=1, not leg=0
### Expected behavior
Routing should not report the user is off-route, and should read out the correct voice instruction.
### Actual behavior
User is reported as being off-route, and the incorrect voice instruction is read out.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with NavigationView.startNavigation and the route-leg handling used by registerOffRouteObserver and voice instructions. Reproduce the supplied three-waypoint example on SDK 1.5.0 at the first waypoint, then compare behavior with 1.4.0; done means no immediate off-route report and the first voice instruction comes from leg 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100