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

Native Router #4791

Merged
merged 3 commits into from
Oct 27, 2021
Merged

Native Router #4791

merged 3 commits into from
Oct 27, 2021

Conversation

korshaknn
Copy link
Contributor

@korshaknn korshaknn commented Sep 6, 2021

Description

This PR removes platform side hybrid/onboard/offboard routers and adds RouterWrapper object. RouterWrapper translates router requests and route refresh requests to NavNative using RouterInterface.

refresh tests are blocked with RoutingProfile issue

Screenshots or Gifs

@korshaknn korshaknn added the ⚠️ DO NOT MERGE PR should not be merged! label Sep 6, 2021
@korshaknn korshaknn self-assigned this Sep 6, 2021
@korshaknn korshaknn requested review from RingerJK and a team September 6, 2021 09:21
@korshaknn korshaknn force-pushed the knn-native-router branch 2 times, most recently from aad83d5 to 1900612 Compare September 13, 2021 12:48
Copy link

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

@vanmaxim just double-checking, does Nav Native respect the Common SDK OfflineSwitch and the connectivity listener it's tied to?

@mskurydin
Copy link
Member

@LukasPaczos The hybrid router doesn't use the connectivity manager right now - it makes 2 requests in parallel, and if the online one fails, it uses the results from the onboard router.

@LukasPaczos
Copy link

The hybrid router doesn't use the connectivity manager right now - it makes 2 requests in parallel, and if the online one fails, it uses the results from the onboard router.

But since the HTTP client from Common SDK does respect the offline switch, then the resulting behavior will be correct after all 👍 We might just possibly log unnecessary errors or warnings for that failed HTTP request. Should we adjust Nav Native to respect the offline switch?

Also, should we make the fallback requests sequential instead of parallel? We are trading the speed of the fallback response for some CPU usage, do you think it's worth it when most of the fallback requests will never be used? Not saying it's bad behavior, just wanted to get your opinion.

Copy link

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

The implementation LGTM to me in general but there seems to be one bug where onboard requests cannot be canceled:

request_not_canceled.mp4

This uses the IndependentRouteGenerationActivity which does integrate cancellation of previous route requests whenever a new one is scheduled. We should see only the second route but we see both because the first request couldn't be canceled.

This works correctly when the connection is available and offboard router is used but doesn't when the onboard router is used.

@korshaknn
Copy link
Contributor Author

korshaknn commented Sep 14, 2021

This uses the IndependentRouteGenerationActivity which does integrate cancellation of previous route requests whenever a new one is scheduled. We should see only the second route but we see both because the first request couldn't be canceled.
This works correctly when the connection is available and offboard router is used but doesn't when the onboard router is used.

@LukasPaczos it's NN bug, right?
@mskurydin

@LukasPaczos
Copy link

it's NN bug, right?

Yes, looks like it.

@mskurydin
Copy link
Member

@LukasPaczos @korshaknn could you file a ticket for on-board router with more details?

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

Took this for a quick spin and for me when disabling connectivity I always get Route request failed. It seems Onboard is not currently working 🤔

cc @mskurydin @LukasPaczos

@mskurydin
Copy link
Member

Route request failed.

Could you check what response the on-board router returns and file an issue? Wondering if the tiles are in place (the output of tilestore contents with find will help too).

@korshaknn
Copy link
Contributor Author

@Guardiola31337 checked with Turn by turn activity from examples. Work both onboard and offboard

@Guardiola31337
Copy link
Contributor

@korshaknn

checked with Turn by turn activity from examples. Work both onboard and offboard

Setup wise, what's different between Turn by turn and IndependentRouteGenerationActivity examples? I was testing IndependentRouteGenerationActivity based on @LukasPaczos's comment #4791 (review)

@Guardiola31337
Copy link
Contributor

Noting that I re-tested IndependentRouteGenerationActivity and I'm still able to reproduce #4791 (review)

@korshaknn
Copy link
Contributor Author

Noting that I re-tested IndependentRouteGenerationActivity and I'm still able to reproduce #4791 (review)

there is a bug on NN side. Onboard router requests can not be cancelled.
Other than that NN router works fine.

@Guardiola31337
Copy link
Contributor

ui-robo-tests are ❌

Caused by: MapboxInvalidModuleException(type=NavigationRouter)
	at com.mapbox.common.module.provider.MapboxModuleProvider.createModule(Unknown Source:260)
	at f.c.f.b.d.<init>(Unknown Source:415)
	at f.c.f.b.e.a(Unknown Source:15)
	at com.mapbox.navigation.examples.core.MapboxVoiceActivity.k0(Unknown Source:26)
	at com.mapbox.navigation.examples.core.MapboxVoiceActivity.u(Unknown Source:0)
	at com.mapbox.navigation.examples.core.MapboxVoiceActivity.onCreate(Unknown Source:68)
	at android.app.Activity.performCreate(Activity.java:8000)
	at android.app.Activity.performCreate(Activity.java:7984)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
	... 11 more

This is Proguard (minifyEnabled true). Adding RouteWrapper here

-keep class com.mapbox.navigation.route.internal.hybrid.MapboxHybridRouter {*;}
does the trick 💃

@korshaknn
Copy link
Contributor Author

@Guardiola31337 @LukasPaczos @kmadsen
RouteRefreshTest works again, used RoutingTilesOptions to mock NN requests.

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a 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 @korshaknn :shipit:

Copy link

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -0,0 +1 @@
{"availableVersions":["2021_10_15-03_00_00","2021_10_09-03_00_00","2021_10_03-03_00_00","2021_09_17-03_00_00","2021_09_12-03_00_00","2021_09_05-03_00_00","2021_09_04-03_00_00","2021_08_23-14_04_46","2021_08_23-03_00_00","2021_08_21-03_00_00","2021_08_16-03_00_00","2021_08_08-03_00_00","2021_07_31-03_00_00","2021_07_25-03_00_00","2021_07_17-03_00_00","2021_07_10-03_00_00","2021_07_04-03_00_00","2021_06_27-03_00_00","2021_06_20-03_00_00","2021_06_13-03_00_00","2021_06_06-03_00_00","2021_06_05-03_00_00","2021_05_30-03_00_00","2021_05_23-03_00_00","2021_05_16-03_00_00","2021_05_09-03_00_00","2021_05_01-03_00_00","2021_04_26-03_00_00","2021_04_25-03_00_00","2021_04_18-03_00_00"],"metadata":{"2021_10_15-03_00_00":{"map":{"tileset_version":"2021_10_15-03_00_00"}},"2021_10_09-03_00_00":{"map":{"tileset_version":"2021_10_09-03_00_00"}},"2021_10_03-03_00_00":{"map":{"tileset_version":"2021_10_03-03_00_00"}},"2021_09_17-03_00_00":{"map":{"tileset_version":"2021_09_17-03_00_00"}},"2021_09_12-03_00_00":{"map":{"tileset_version":"2021_09_12-03_00_00"}},"2021_09_05-03_00_00":{"map":{"tileset_version":"2021_09_05-03_00_00"}},"2021_09_04-03_00_00":{"map":{"tileset_version":"2021_09_04-03_00_00"}},"2021_08_23-14_04_46":{"map":{}},"2021_08_23-03_00_00":{"map":{}},"2021_08_21-03_00_00":{"map":{}},"2021_08_16-03_00_00":{"map":{}},"2021_08_08-03_00_00":{"map":{}},"2021_07_31-03_00_00":{"map":{}},"2021_07_25-03_00_00":{"map":{}},"2021_07_17-03_00_00":{"map":{}},"2021_07_10-03_00_00":{"map":{}},"2021_07_04-03_00_00":{"map":{}},"2021_06_27-03_00_00":{"map":{}},"2021_06_20-03_00_00":{"map":{}},"2021_06_13-03_00_00":{"map":{}},"2021_06_06-03_00_00":{"map":{}},"2021_06_05-03_00_00":{"map":{}},"2021_05_30-03_00_00":{"map":{}},"2021_05_23-03_00_00":{"map":{}},"2021_05_16-03_00_00":{"map":{}},"2021_05_09-03_00_00":{"map":{}},"2021_05_01-03_00_00":{"map":{}},"2021_04_26-03_00_00":{"map":{}},"2021_04_25-03_00_00":{"map":{}},"2021_04_18-03_00_00":{"map":{}}}}

Choose a reason for hiding this comment

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

Will we need to keep updating this file? Do we need to mock it in general? We are not mocking routing tiles request (yet), so why do we need to mock the routing tiles version requests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't need to update it, we mock it to prevent mockWebServer exception

throw Error(
                    """Request url:
                      |${request.path}
                      |is not handled.
                      |
                      |Available handlers:
                      |$formattedHandlersBuilder
                    """.trimMargin()
                )

We are not mocking routing tiles request (yet), so why do we need to mock the routing tiles version requests?

not 100% sure, looks like because version request made by NN and tiles request by common (Tilestore).
I mocked it because of the mockWebServer exception.

Copy link

@LukasPaczos LukasPaczos Oct 26, 2021

Choose a reason for hiding this comment

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

I see, since we redirect everything localhost, the onboard router will probably always fail because it has no tiles. This shouldn't impact the test as long as the device doesn't go offline.

@korshaknn korshaknn removed the ⚠️ DO NOT MERGE PR should not be merged! label Oct 26, 2021
@Guardiola31337
Copy link
Contributor

instrumentation-tests are failing now 😬

@korshaknn
Copy link
Contributor Author

@Guardiola31337 fixed

@Guardiola31337
Copy link
Contributor

There are still some random test failures 👀

10-26 11:54:18.191: I/nav-native(27906): Waypoints were not passed to setRoute. Trying to restore it from route itself.
10-26 11:54:18.191: W/nav-native(27906): Cannot find via_waypoints in passed route. On-board waypoints matching will be used.
10-26 11:54:18.191: W/nav-native(27906): Cannot find via_waypoints in passed route. On-board waypoints matching will be used.
10-26 11:54:18.192: I/nav-native(27906): Successful route response. Metadata: 
10-26 11:54:18.215: D/MbxNavigationTelemetry(27906): populateNavigationEvent
10-26 11:54:18.216: D/MbxNavigationTelemetry(27906): class com.mapbox.navigation.core.telemetry.events.NavigationDepartEvent event sent
10-26 11:54:18.217: W/System.err(27906): java.lang.NullPointerException: Null distance
10-26 11:54:18.225: W/System.err(27906): 	at com.mapbox.api.directions.v5.models.$AutoValue_DirectionsRoute.<init>($AutoValue_DirectionsRoute.java:40)
10-26 11:54:18.225: W/System.err(27906): 	at com.mapbox.api.directions.v5.models.AutoValue_DirectionsRoute.<init>(AutoValue_DirectionsRoute.java:28)
10-26 11:54:18.225: W/System.err(27906): 	at com.mapbox.api.directions.v5.models.AutoValue_DirectionsRoute$GsonTypeAdapter.read(AutoValue_DirectionsRoute.java:280)
10-26 11:54:18.225: W/System.err(27906): 	at com.mapbox.api.directions.v5.models.AutoValue_DirectionsRoute$GsonTypeAdapter.read(AutoValue_DirectionsRoute.java:31)
10-26 11:54:18.225: W/System.err(27906): 	at com.google.gson.Gson.fromJson(Gson.java:932)
10-26 11:54:18.225: W/System.err(27906): 	at com.google.gson.Gson.fromJson(Gson.java:1003)
10-26 11:54:18.225: W/System.err(27906): 	at com.google.gson.Gson.fromJson(Gson.java:975)
10-26 11:54:18.225: W/System.err(27906): 	at com.mapbox.api.directions.v5.models.DirectionsRoute.fromJson(DirectionsRoute.java:182)
10-26 11:54:18.225: W/System.err(27906): 	at com.mapbox.api.directions.v5.models.DirectionsRoute.fromJson(DirectionsRoute.java:204)
10-26 11:54:18.225: W/System.err(27906): 	at com.mapbox.navigation.core.routealternatives.RouteAlternativesController$nativeObserver$1.onRouteAlternativesChanged(RouteAlternativesController.kt:70)
10-26 11:54:18.225: E/nav-native(27906): RouteAlternativesControllerWorker unhandled observer unknown exception

Same as #5036 (comment) cc @mskurydin

10-26 11:54:26.608: E/AndroidRuntime(28442): FATAL EXCEPTION: MockWebServer TaskRunner
10-26 11:54:26.608: E/AndroidRuntime(28442): Process: com.mapbox.navigation.instrumentation_tests, PID: 28442
10-26 11:54:26.608: E/AndroidRuntime(28442): java.lang.Error: Request url:
10-26 11:54:26.608: E/AndroidRuntime(28442): /route-tiles/v2/mapbox/driving-traffic/versions?access_token=pk.eyJ1IjoiYWNjb3VudHMtbW9iaWxlbmF2LW1hcGJveCIsImEiOiJja3Q0dXZ6NXowMmVnMnducnJoNzVtNGduIn0.4am14Nd7WFl4uvSWD2XmPQ
10-26 11:54:26.608: E/AndroidRuntime(28442): is not handled.
10-26 11:54:26.608: E/AndroidRuntime(28442): Available handlers:
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at com.mapbox.navigation.testing.ui.http.MockWebServerRule$1.dispatch(MockWebServerRule.kt:46)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at okhttp3.mockwebserver.MockWebServer$SocketHandler.processOneRequest(MockWebServer.kt:600)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at okhttp3.mockwebserver.MockWebServer$SocketHandler.handle(MockWebServer.kt:551)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at okhttp3.mockwebserver.MockWebServer$serveConnection$$inlined$execute$1.runOnce(TaskQueue.kt:220)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at okhttp3.internal.concurrent.TaskRunner.runTask(TaskRunner.kt:116)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at okhttp3.internal.concurrent.TaskRunner.access$runTask(TaskRunner.kt:42)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at okhttp3.internal.concurrent.TaskRunner$runnable$1.run(TaskRunner.kt:65)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-26 11:54:26.608: E/AndroidRuntime(28442): 	at java.lang.Thread.run(Thread.java:818)
10-26 11:54:26.611: W/ActivityManager(860): Error in app com.mapbox.navigation.instrumentation_tests running instrumentation ComponentInfo{com.mapbox.navigation.instrumentation_tests.test/androidx.test.runner.AndroidJUnitRunner}:
10-26 11:54:26.611: W/ActivityManager(860):   java.lang.Error
10-26 11:54:26.611: W/ActivityManager(860):   java.lang.Error: Request url:
10-26 11:54:26.611: W/ActivityManager(860): /route-tiles/v2/mapbox/driving-traffic/versions?access_token=pk.eyJ1IjoiYWNjb3VudHMtbW9iaWxlbmF2LW1hcGJveCIsImEiOiJja3Q0dXZ6NXowMmVnMnducnJoNzVtNGduIn0.4am14Nd7WFl4uvSWD2XmPQ
10-26 11:54:26.611: W/ActivityManager(860): is not handled.
10-26 11:54:26.611: W/ActivityManager(860): Available handlers:
10-26 11:54:26.612: D/CrashJobIntentService(28442): onHandleWork
10-26 11:54:26.612: W/CrashReporter(28442): Root directory doesn't exist
10-26 11:54:26.613: D/AndroidRuntime(28404): Shutting down VM
10-26 11:54:26.614: I/ActivityManager(860): Force stopping com.mapbox.navigation.instrumentation_tests appid=10098 user=0: finished inst
10-26 11:54:26.614: I/ActivityManager(860): Killing 28442:com.mapbox.navigation.instrumentation_tests/u0a98 (adj 0): stop com.mapbox.navigation.instrumentation_tests

Refs. #4791 (comment)

@korshaknn
Copy link
Contributor Author

I've fixed alternatives parsing (routeRequest instead of a route) and moved util fun to base module.
Check the last commit
cc @LukasPaczos @kmadsen @Guardiola31337

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a 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 @korshaknn

@Guardiola31337
Copy link
Contributor

Going ahead and merging here in preparation for the upcoming release 🚀

Hope you don't mind @korshaknn

@Guardiola31337 Guardiola31337 merged commit 8a95a40 into main Oct 27, 2021
@Guardiola31337 Guardiola31337 deleted the knn-native-router branch October 27, 2021 20:45
@korshaknn korshaknn added the skip changelog Should not be added into version changelog. label Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Should not be added into version changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.