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 route refresh not starting #4831

Merged
merged 2 commits into from
Sep 16, 2021
Merged

Conversation

LukasPaczos
Copy link
Member

@LukasPaczos LukasPaczos commented Sep 16, 2021

Description

Closes #4829. Fixes a regression potentially from #4755.

A route is not set synchronously in the MapboxTripSession anymore, so we cannot use a synchronous getter for it in the RouteRefreshController.

We could potentially use a synchronous getter from MapboxDirectionsSession instead as #4830 proposes but it's exposed to the same risk as the previous MapboxTripSession getter - route setting is run on a callback (RoutesObserver) and we don't guarantee that the route setting process is synchronous. We could change MapboxDirectionsSession to work asynchronously in the future and run into the same exact regression.

This PR instead uses the RoutesObserver to restart the refresh timer.

Changelog

<changelog>Fixed an issue where the route was never refreshed because of an internal timer not starting when a new route was set.</changelog>

@LukasPaczos LukasPaczos added bug Defect to be fixed. release blocker Needs to be resolved before the release. needs backporting Requires cherry-picking to a currently running release branch labels Sep 16, 2021
@LukasPaczos LukasPaczos requested a review from a team September 16, 2021 15:22
@@ -408,7 +408,6 @@ class MapboxNavigation(
tripSession,
logger
)
routeRefreshController.restart()
Copy link
Contributor

Choose a reason for hiding this comment

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

💯 like how this way can delete some interactions

?.takeIf { it.isUuidValidForRefresh() }
if (route != null) {
private fun refreshRoute(route: DirectionsRoute) {
val isValid = route.routeOptions()?.enableRefresh() == true && route.isUuidValidForRefresh()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little on the fence of having it come from the external caller. The tripSession is still needed with route progress

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should just call routeRefreshController.restart() without the route

RouteRefreshController depends on directionsSession so it can access the primary route on its own.

Also, that reduces the tests you need to add to the overpowered MapboxNavigation.

@@ -576,7 +575,6 @@ class MapboxNavigation(
rerouteController?.interrupt()
routeAlternativesController.interrupt()
directionsSession.setRoutes(routes, initialLegIndex)
routeRefreshController.restart()
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@LukasPaczos LukasPaczos merged commit be55ec7 into main Sep 16, 2021
@LukasPaczos LukasPaczos deleted the lp-fix-refresh-start-timing branch September 16, 2021 17:33
LukasPaczos added a commit that referenced this pull request Sep 16, 2021
* fix route refresh not starting

* removed route from the TripSession interface to clearly make DirectionsSession the source of truth
@LukasPaczos LukasPaczos removed the needs backporting Requires cherry-picking to a currently running release branch label Sep 16, 2021
abhishek1508 pushed a commit that referenced this pull request Sep 16, 2021
* fix route refresh not starting

* removed route from the TripSession interface to clearly make DirectionsSession the source of truth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect to be fixed. release blocker Needs to be resolved before the release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Route refresh instrumentation tests are failing
2 participants