Skip to content

Remove duplicate polyline decoding #210

Closed

Description

@ericrwolfe

Polylines are decoded 6 times on every new location update (9 times if a new step!) in NavigationEngine.handleRequest:

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();

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.

cc @cammace @danesfeder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions