mapbox-navigation-android icon indicating copy to clipboard operation
mapbox-navigation-android copied to clipboard

Deliver routes back in RoutesObserver only when they were processed successfully

Open LukasPaczos opened this issue 3 years ago • 5 comments

Refs https://github.com/mapbox/mapbox-navigation-android/pull/5653 where we introduced a dependency for MapboxNavigation#setNavigationRoutes to only deliver the routes back in RoutesObserver after they were processed by the native navigator.

This opens up an opportunity to only return routes that were successfully processed by the native navigator. A route might be valid for display on the map, valid for camera operations, etc. while for any reason not being valid for navigation from Nav Native perspective. Filtering invalid routes out would prevent user confusion and made it easier for developers to catch a problem if a route they set is not delivered back.

We could extend the RoutesUpdatedResult with a collection of routes that were not processed successfully and the reasons for that.

cc @Guardiola31337 @RingerJK @VysotskiVadim

LukasPaczos avatar Apr 11 '22 11:04 LukasPaczos

After discussing this issue with NN the following case was found: if at the moment when we enter OffRoute state the location puck reaches some of the alternative routes, we will switch to said alternative instead of doing the reroute. And this alternative does not necessarily have the same destination (if it's provided by the user, also valid for continuation alternatives). So it can actually be a completely different route. This may cause some issues with telemetry and billing. We should probably discuss what we want to do with it.

cc @mskurydin @DenisPryt @AhmerKhan1 @zugaldia @Guardiola31337

dzinad avatar Jun 21 '22 11:06 dzinad

In general the NN behaviour is the following:

  • if there's an error in setRoutes method, the primary route was not set to native navigator;
  • if there's no error in setRoutes method, the size of alternatives in NativeSetRouteResult is the same as the size of input list
  • if some of the alternative routes are invalid, the setRoutes method will NOT return an error but they will be excluded later in onRouteAlternativesChanged method.

So I guess that in the context of this issue we can just stop notifying RoutesObservers in case setRoutes method returned an error. Please correct me if I'm wrong. cc @mapbox/navigation-android

dzinad avatar Jun 21 '22 12:06 dzinad

Additionally to above

  • the SDK doesn't handle a setRoute error, where turn-by-turn navigation is not started https://github.com/mapbox/mapbox-navigation-android/blob/1a2557ef6872d11675f5d5dff340f429a379674f/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt#L797-L811

RingerJK avatar Jun 21 '22 12:06 RingerJK

I understand that https://github.com/mapbox/mapbox-navigation-android/pull/5946 addresses failures with the primary route and we're waiting for Nav Native to be able to filter out alternatives immediately as well before we can fully resolve this ticket?

LukasPaczos avatar Jul 07 '22 11:07 LukasPaczos

I understand that https://github.com/mapbox/mapbox-navigation-android/pull/5946 addresses failures with the primary route and we're waiting for Nav Native to be able to filter out alternatives immediately as well before we can fully resolve this ticket?

Yes, the NN issue is linked.

dzinad avatar Jul 07 '22 12:07 dzinad