Skip to content
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

Fix routeProgress get out of sync with NavNative status #3432

Merged
merged 3 commits into from
Oct 12, 2021

Conversation

S2Ler
Copy link
Contributor

@S2Ler S2Ler commented Oct 4, 2021

  • Probably addresses some symptoms of Parallel copies of route in Router can get out of sync #3343

  • Fixes Fix and enable NavigationServiceTests.  #3375

  • Fixes 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.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.

Next:

  • Update comments.
  • Update documentation.
  • Update inline documentation.
  • Update changelog.

@S2Ler S2Ler requested a review from a team October 4, 2021 15:00
@S2Ler S2Ler self-assigned this Oct 4, 2021
@S2Ler S2Ler force-pushed the feature/async-updates-2 branch from cf9627e to 315ae00 Compare October 4, 2021 15:02
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is quite a PR. Can you say a bit more about what fixed #3343 and #3298?

@1ec5 1ec5 added this to the v2.0 milestone Oct 4, 2021
@1ec5 1ec5 added bug Something isn’t working Core Work related to core navigation and integrations. labels Oct 4, 2021
@S2Ler S2Ler force-pushed the feature/async-updates-2 branch from 315ae00 to 8d446d3 Compare October 5, 2021 09:06
@S2Ler
Copy link
Contributor Author

S2Ler commented Oct 5, 2021

Wow, this is quite a PR. Can you say a bit more about what fixed #3343 and #3298?

@S2Ler S2Ler force-pushed the feature/async-updates-2 branch from 16f2dfd to 9bcb0f4 Compare October 5, 2021 10:54
@S2Ler S2Ler marked this pull request as ready for review October 5, 2021 11:09
@S2Ler S2Ler force-pushed the feature/async-updates-2 branch 5 times, most recently from 68799c2 to 5553cf2 Compare October 6, 2021 05:46
@S2Ler S2Ler requested a review from a team October 6, 2021 07:14
@S2Ler S2Ler mentioned this pull request Oct 7, 2021
11 tasks
@S2Ler S2Ler requested review from a team and 1ec5 October 11, 2021 05:59
strongSelf.announce(reroute: route, at: location, proactive: false)

guard case let .route(routeOptions) = response.options else {
//TODO: Can a match hit this codepoint?
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

@1ec5 1ec5 left a 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?
Copy link
Contributor

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.

@S2Ler S2Ler force-pushed the feature/async-updates-2 branch 2 times, most recently from a124fa5 to 73a6da0 Compare October 12, 2021 09:57
S2Ler added 3 commits October 12, 2021 12:57
- `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.
@S2Ler S2Ler merged this pull request into feature/async-updates Oct 12, 2021
@S2Ler S2Ler deleted the feature/async-updates-2 branch October 12, 2021 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working Core Work related to core navigation and integrations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants