-
Notifications
You must be signed in to change notification settings - Fork 319
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
Add route refresh #2570
Add route refresh #2570
Conversation
libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt
Outdated
Show resolved
Hide resolved
9fcd7d9
to
b3292ce
Compare
...rc/main/java/com/mapbox/services/android/navigation/v5/internal/navigation/RouteRefresher.kt
Outdated
Show resolved
Hide resolved
...rections-offboard/src/main/java/com/mapbox/navigation/route/offboard/MapboxOffboardRouter.kt
Show resolved
Hide resolved
@@ -27,7 +27,6 @@ internal object RouteBuilderProvider { | |||
.accessToken(accessToken) | |||
.voiceInstructions(true) | |||
.bannerInstructions(true) | |||
.enableRefresh(false) |
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.
This is a pain to find. I had to ask in #directions to figure it out
https://mapbox.slack.com/archives/C03KW1JQD/p1583881618015100
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.
Updating this feature to be enabled automatically with traffic profiles because that's the only place it's supported.
https://mapbox.slack.com/archives/C03KW1JQD/p1583883018020600?thread_ts=1583881618.015100&cid=C03KW1JQD
libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt
Outdated
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/routerefresh/RouteRefreshApi.kt
Outdated
Show resolved
Hide resolved
3f3c665
to
0f828c2
Compare
9cf1aa6
to
1093e96
Compare
Codecov Report
@@ Coverage Diff @@
## master #2570 +/- ##
=========================================
Coverage 29.04% 29.04%
Complexity 1062 1062
=========================================
Files 281 281
Lines 10832 10832
Branches 881 881
=========================================
Hits 3146 3146
Misses 7340 7340
Partials 346 346 |
531b0a0
to
a164785
Compare
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.
This is looking good so far @kmadsen
I've left some comments / questions to discuss before merging here.
Also, it'd be 💯 if we can add an example under the Navigation Core SDK
examples
showcasing the integration and the client options available and how can customize those (although it seems as it's enabled by default internally there are none 😬 - see my comments below).
...rections-offboard/src/main/java/com/mapbox/navigation/route/offboard/MapboxOffboardRouter.kt
Outdated
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/routerefresh/RouteRefreshApi.kt
Outdated
Show resolved
Hide resolved
...igation-core/src/main/java/com/mapbox/navigation/core/routerefresh/RouteRefreshController.kt
Outdated
Show resolved
Hide resolved
@@ -39,6 +39,7 @@ class MapboxOffboardRouter( | |||
) { | |||
mapboxDirections = RouteBuilderProvider.getBuilder(accessToken, context, skuTokenProvider) | |||
.routeOptions(routeOptions) | |||
.enableRefresh(routeOptions.isRefreshEnabled()) |
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.
We're enabling refresh by default, is that a good idea? How a client can disable it? Currently (in the legacy) this can be customized
Lines 105 to 112 in 0d4de74
/** | |
* This enables / disables refresh route. If not specified, it's enabled by default. | |
* | |
* @param enableRefreshRoute whether or not to enable route refresh | |
* @return this builder for chaining options together | |
*/ | |
fun enableRefreshRoute(enableRefreshRoute: Boolean) = | |
apply { this.enableRefreshRoute = enableRefreshRoute } |
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.
yeah this was the other option considered
https://github.com/mapbox/mapbox-java/compare/km-add-route-refresh?expand=1
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.
but those other options enable or disable route_refresh
even if it's not supported
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.
this way only enables route refresh if it's supported. the approaches have their pros/cons so I think the issue is picking one
private val routeRefreshRetrofit = RouteRefreshRetrofit() | ||
private val routeRefreshApi = RouteRefreshApi(routeRefreshRetrofit) | ||
|
||
var intervalSeconds: Long = TimeUnit.MILLISECONDS.toSeconds(routerRefreshTimer.restartAfterMillis) |
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.
We're not setting the interval anywhere which means that we're using the default value from MapboxTimer
Line 20 in 1656229
var restartAfterMillis = TimeUnit.MINUTES.toMillis(1) |
MapboxNavigationOptions
Lines 114 to 121 in 1656229
/** | |
* This sets the route refresh interval. If not specified, the interval is 5 minutes by default. | |
* | |
* @param intervalInMilliseconds for route refresh | |
* @return this builder for chaining options together | |
*/ | |
fun refreshIntervalInMilliseconds(intervalInMilliseconds: Long) = | |
apply { this.refreshIntervalInMilliseconds = intervalInMilliseconds } |
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.
was considering options here still. but this class can stay the same with each option
- add a function to MapboxNavigation to update the value
- add an option to NavigationOptions
- get the refresh rate from DirectionsResponse
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.
get the refresh rate from DirectionsResponse
Do we have this available? Is the plan to have it eventually? cc @mapbox/navigation-api
|
||
override fun onRefresh(directionsRoute: DirectionsRoute) { | ||
Log.i("RouteRefresh", "Successful refresh") | ||
tripSession.route = directionsRoute |
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.
Is this a good idea? Wondering if we should implement something similar to faster route in which we expose the route to the client and it's up to them to use it or not, instead of us always doing it internally 🤔
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 update the MapboxDirectionsSession#routes[0]
too 🤔? Actually, updating the MapboxDirectionsSession#routes
will end up updating MapboxTripSession#route
👀
Lines 440 to 448 in 1656229
private fun createInternalRoutesObserver() = object : RoutesObserver { | |
override fun onRoutesChanged(routes: List<DirectionsRoute>) { | |
if (routes.isNotEmpty()) { | |
tripSession.route = routes[0] | |
} else { | |
tripSession.route = null | |
} | |
} | |
} |
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.
Also noticed that we're updating the whole route in NN
Line 45 in 1656229
navigator.setRoute(value) |
RouteHandler
. Do you know if this has a performance impact? Probably yes because it's not the same to serialize the whole route rather than only updating the annotations of the current route.
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.
looking into update the annotations only now, i did try before but that was early on.
considered performance impacts and considered it minor since it's per minutes (opposed to per seconds)
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.
Another note is that legacy doesn't only update the navigator annotations. It also updates the entire route
https://github.com/mapbox/mapbox-navigation-android/blob/master/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/internal/navigation/RouteRefresherCallback.kt#L17
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.
Nah, that's not correct 👀
Lines 18 to 26 in cd4d864
} else { | |
route.legs()?.let { routeLegs -> | |
for (i in routeLegs.indices) { | |
routeLegs[i].annotation()?.toJson()?.let { annotationJson -> | |
mapboxNavigator.updateAnnotations(annotationJson, INDEX_FIRST_ROUTE, i) | |
} | |
} | |
} | |
} |
NEW_ROUTE
Line 17 in cd4d864
mapboxNavigation.startNavigation(directionsRoute, DirectionsRouteType.FRESH_ROUTE) |
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.
Yeah discussed offline, now see how fresh_route causes the condition in RouteHandler
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.
When attempting to only update annotations in NN, it didn't update the the traffic on the map.
ee15527
to
f3f9fc2
Compare
...igation-core/src/main/java/com/mapbox/navigation/core/routerefresh/RouteRefreshController.kt
Outdated
Show resolved
Hide resolved
11dd0bb
to
e7037a0
Compare
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.
Thanks for addressing the feedback @kmadsen
We should still think about how clients will enable / disable route refresh feature and how they can tune the refresh interval but we can work on that in a separate PR.
Great work 🍍
e7037a0
to
7c87897
Compare
Description
Resolves https://github.com/mapbox/navigation-sdks/issues/222
Related refactors
Update route line #2581
Improve the MapboxTimer #2575
Modularize faster route #2577
Current status is, ready for review
bug
,feature
,new API(s)
,SEMVER
, etc.)Goal
Keep traffic fresh while driving viewing a route, and/or navigating a route
Implementation
MapboxDirectionsRefresh
LegAnnotations
on the route (traffic data)What changed from 0.43
Example of the
LegAnnotation
jsonScreenshots or Gifs
Video of route being refreshed.
Notice that the route blinks.Testing
Please describe the manual tests that you ran to verify your changes
SNAPSHOT
upstream dependencies if needed) through testapp/demo app and run all activities to avoid regressionsChecklist
CHANGELOG
including this PRcc: @abhishek1508 @Guardiola31337 @olegzil