mapbox / mapbox-navigation-android

Mapbox Navigation SDK for Android
https://docs.mapbox.com/android/navigation/overview/
Other
621 stars 318 forks source link

Free Drive START events have always null location #3797

Open Guardiola31337 opened 3 years ago

Guardiola31337 commented 3 years ago

Follow up ticket from https://github.com/mapbox/mapbox-navigation-android/pull/3791#issuecomment-729733263

From my tests START events never have location (is always null) :disappointed:

We should check when the locationsCollector observer is registered because maybe trip session doesn't provide a location until the session is started but when it is started we immediately send event. The issue may be fixed if we do it after registering 🤔

cc @korshaknn

2020-11-18 11:29:20.995 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: Valid initialization
2020-11-18 11:29:43.459 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: session state is FREE_DRIVE
2020-11-18 11:29:43.459 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: sessionStop
2020-11-18 11:29:43.459 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: resetOriginalRoute
2020-11-18 11:29:43.459 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: resetRouteProgress
2020-11-18 11:29:43.459 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: trackFreeDrive START
2020-11-18 11:29:43.460 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: createFreeDriveEvent START
2020-11-18 11:29:43.476 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: populateFreeDriveEvent
2020-11-18 11:29:43.477 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: class com.mapbox.navigation.core.telemetry.events.NavigationFreeDriveEvent event sent
2020-11-18 11:29:43.504 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: Lifecycle monitor created
2020-11-18 11:29:43.509 25573-25573/com.mapbox.navigation.examples D/MAPBOX_TELEMETRY: onRawLocationChanged

onRawLocation is received after onNavigationSessionStateChanged when the event has been already sent.

override fun start() {
       if (state == TripSessionState.STARTED) {
           return
       }
       tripService.startService()
       startLocationUpdates()
       state = TripSessionState.STARTED
   }

startLocationUpdates is async and state executes the onSessionStateChanged right away before onRawLocationChanged.

We should investigate a different way to wait for the first location https://github.com/mapbox/mapbox-navigation-android/pull/3751#discussion_r521379048 and also discuss what to do if a session is started and no locations are received. Refs. https://github.com/mapbox/mapbox-navigation-android/issues/2827

cc @korshaknn @kmadsen @LukasPaczos

cc @korshaknn @kmadsen @LukasPaczos

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.