Repository navigation
Closed
Description
Polylines are decoded 6 times on every new location update (9 times if a new step!) in NavigationEngine.handleRequest:
Lines 63 to 72 in 05a2f56
| private void handleRequest(final NewLocationModel newLocationModel) { | |
| final RouteProgress routeProgress = generateNewRouteProgress( | |
| newLocationModel.mapboxNavigation(), newLocationModel.location()); | |
| final List<Milestone> milestones = checkMilestones( | |
| previousRouteProgress, routeProgress, newLocationModel.mapboxNavigation()); | |
| final boolean userOffRoute = isUserOffRoute(newLocationModel, routeProgress); | |
| final Location location = !userOffRoute && newLocationModel.mapboxNavigation().options().snapToRoute() | |
| ? getSnappedLocation(newLocationModel.mapboxNavigation(), newLocationModel.location(), routeProgress) | |
| : newLocationModel.location(); | |
- 3-6x in
generateNewRouteProgress():- 1x in
userSnappedToRoutePosition() - 2x in
stepDistanceRemaining()first here and also here vianextManeuverPosition() - Repeat all of the above if it's a new step
- 1x in
- 1x in
isUserOffRoute()viauserTrueDistanceFromRoute() - 2x in
SnapToRoute.getSnappedLocation()viasnapLocationLatLng()andsnapLocationBearing()
Polyline decoding is expensive especially on long route steps and if GPS updates are frequent, so decoding the polylines a single time when you parse the route json and storing the resulting List<Position> coordinates as part of each LegStep will help significantly with memory usage and general performance.
Metadata
Metadata
Assignees
Labels
No labels
Activity