Skip to content

Parallel copies of route in Router can get out of sync #3343

@1ec5

Description

@1ec5

Router implementations store both an IndexedRouteResponse (that is, a RouteResponse plus a route index) and a RouteProgress (that is, a Route plus a leg index etc.) side by side. As a result, they effectively hold two parallel copies of the current Route that can get out of sync. For example, after a reroute, RouteController sets the routeProgress property but neglects to update the indexedRouteResponse property:

strongSelf._routeProgress = RouteProgress(route: route, options: routeOptions, legIndex: 0)
strongSelf._routeProgress.currentLegProgress.stepIndex = 0
strongSelf.announce(reroute: route, at: location, proactive: false)

This contrasts to LegacyRouteController, which does happen to set both properties:

let routeOptions = routeOptions ?? routeProgress.routeOptions
routeProgress = RouteProgress(route: routes[indexedRouteResponse.routeIndex], options: routeOptions)
self.indexedRouteResponse = indexedRouteResponse

In both RouteController and LegacyRouteController, routeProgress is publicly settable but indexedRouteResponse is not. This makes it entirely possible for client code to have inconsistent behavior depending on how it gets the route from the Router.

/cc @mapbox/navigation-ios

Metadata

Metadata

Assignees

Labels

CoreWork related to core navigation and integrations.bugSomething isn’t workingjira-sync-completeop-exRefactoring, Tech Debt or any other operational excellence work.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions