-
Notifications
You must be signed in to change notification settings - Fork 326
Fix routeProgress get out of sync with NavNative status #3432
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
Conversation
cf9627e to
315ae00
Compare
1ec5
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
315ae00 to
8d446d3
Compare
|
16f2dfd to
9bcb0f4
Compare
68799c2 to
5553cf2
Compare
| strongSelf.announce(reroute: route, at: location, proactive: false) | ||
|
|
||
| guard case let .route(routeOptions) = response.options else { | ||
| //TODO: Can a match hit this codepoint? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we discuss this and remove the TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is here for a long time, who can verify it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a bring-your-own-route workflow, the developer would have to supply a RouteOptions that would simulate the RouteResponse converted from the MapMatchingResponse. The workflow also currently requires the developer to preempt rerouting and set the new route manually (using the method that’s becoming asynchronous in this PR). #3464 tracks streamlining this workflow. We had been getting lucky, because #3191 had been morphing MapMatchingOptions into RouteOptions. But now that that issue is fixed, it may be a little easier for us to get into this situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1ec5 You seem to have a good grasp of this issue. Can you suggest what shall we do when we hit this code path?
1ec5
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whew! I mostly focused on whatever had outstanding questions, as well as the public API, but I didn’t look very closely at the test changes.
| strongSelf.announce(reroute: route, at: location, proactive: false) | ||
|
|
||
| guard case let .route(routeOptions) = response.options else { | ||
| //TODO: Can a match hit this codepoint? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a bring-your-own-route workflow, the developer would have to supply a RouteOptions that would simulate the RouteResponse converted from the MapMatchingResponse. The workflow also currently requires the developer to preempt rerouting and set the new route manually (using the method that’s becoming asynchronous in this PR). #3464 tracks streamlining this workflow. We had been getting lucky, because #3191 had been morphing MapMatchingOptions into RouteOptions. But now that that issue is fixed, it may be a little easier for us to get into this situation.
Sources/MapboxNavigation/NavigationViewControllerDelegate.swift
Outdated
Show resolved
Hide resolved
a124fa5 to
73a6da0
Compare
- `NavigationService.updateRoute`, `RouteController.updateRoute` is no longer synchronous. This change is needed because NavNative implementation is asynchronous, and we need to know when this operation completes so that we can update local properties with a new route. Otherwise, we can end up in a situation when the SDK state doesn't match with the nav status callback received from NavNative. - `userIsOnRoute(_:status:)` incorrectly assumes that the invalid route state is an off-route event. The invalid route state is reported when there is no route set in a native navigator, that happens during passive navigation. - It is no longer possible to set `RouteController.routeProgress` property synchronously for the same reason as why `RouteController.updateRoute` is asynchronous. - `updateNavigator` incorrectly referenced old `routeProgress` in the parameters to NavNative's `setRoute` method. - `RouteProgress.legIndexHandler` removed as it is no longer needed. `RouteProgress.legIndex` should be updated only after NavNative status callback, otherwise they will be out-of-sync. `RouteController.advanceLegIndex` is the correct method to change legIndex, then it will be updated in `RouteProgress`. - `NavigationEventsManagerTestDoubles.flush` method was adjusted to work closer to real world. Without clearing enqueuedEvents, if flus is called two times, flushed events will contain two duplicates. - A lot of `RouteController` dependent tests are fixed, some restored.
Probably addresses some symptoms of Parallel copies of route in Router can get out of sync #3343
Fixes Fix and enable
NavigationServiceTests. #3375Fixes Crash: RouteController.updateIndexes(status:progress:) #3298
Fixes Restore disabled test #3128
Fixes [Bug]: Crashed navigation session. Precondition failed: The stepIndex is higher than steps count #3461
NavigationService.updateRoute,RouteController.updateRouteis nolonger synchronous. This change is needed because NavNative
implementation is asynchronous, and we need to know when this operation
completes so that we can update local properties with a new route.
Otherwise, we can end up in a situation when the SDK state doesn't match
with the nav status callback received from NavNative.
userIsOnRoute(_:status:)incorrectly assumes that the invalid routestate is an off-route event. The invalid route state is reported when
there is no route set in a native navigator, that happens during passive
navigation.
It is no longer possible to set
RouteController.routeProgressproperty synchronously for the same reason as why
RouteController.updateRouteis asynchronous.updateNavigatorincorrectly referenced oldrouteProgressin theparameters to NavNative's
setRoutemethod.RouteProgress.legIndexHandlerremoved as it is no longer needed.RouteProgress.legIndexshould be updated only after NavNative statuscallback, otherwise they will be out-of-sync.
RouteController.advanceLegIndexis the correct method to changelegIndex, then it will be updated in
RouteProgress.NavigationEventsManagerTestDoubles.flushmethod was adjusted towork closer to real world. Without clearing enqueuedEvents, if flus is
called two times, flushed events will contain two duplicates.
A lot of
RouteControllerdependent tests are fixed, some restored.Next: