Open narko opened 1 year ago
@kmadsen, we started seeing this issue in Android 13 that we cannot reproduce in our code. There must be something that is triggering a MapboxScreen.GEO_DEEPLINK
push in some phones. I wonder, if we could relax a bit the condition in GeoDeeplinkPlacesCarScreenFactory
and log the error instead of triggering an exception there.
Hey thanks for cutting the ticket and sorry I am just coming back from a vacation.
I think I see why this is possible.. The MapboxScreenManager
companion object has a lifecycle that is longer than the MapboxCarContext
. So the app can destroy the MapboxCarContext
and the geoDeeplinkPlacesProvider
, but it still thinks it's on the GEO_DEEPLINK
screen. Upon re-launching the car head unit, it tries to reload the GEO_DEEPLINK
screen but the geoDeeplinkPlacesProvider
has been cleared - so it crashes.
Look into GeoDeeplinkNavigateAction
. The code path to set the geoDeeplinkPlacesProvider
comes from a regular Intent
and geo formatted strings. So the exception would be impossible if the screen is shown with the GeoDeeplinkNavigateAction
I wonder, if we could relax a bit the condition in GeoDeeplinkPlacesCarScreenFactory and log the error instead of triggering an exception there.
This is fair. But, let me explain more because fixing the issue first may help us with SDK improvements. The exception is thrown to help developers know they need to use the GeoDeeplinkNavigateAction
when implementing the session. 🤔 But the cause seems to be unrelated to GEO_DEEPLINK
screen, it would happen to other screens too.
@narko Can you try resetting your screen when the Car lifecycle is destroyed? In the example app that would be here. https://github.com/mapbox/mapbox-navigation-android/blob/07ca7859ccdd56a40fa7c6df62ec32f4137ecac6/android-auto-app/src/main/java/com/mapbox/navigation/examples/androidauto/car/MainCarSession.kt#L102-L104
The default screen we have in the example is FREE_DRIVE, but it is possible that your default screen would be different than the one we have in the example
override fun onDestroy(owner: LifecycleOwner) {
mapboxCarMap.clearObservers()
MapboxScreenManager.replaceTop(MapboxScreen.FREE_DRIVE)
}
Thanks @kmadsen for the detailed explanation.
I wonder how I could try to reproduce the issue for sharing further details about the lifecycle hint.
One thing I realized is that in our session we use mapboxMapInstaller().install(initializer)
with a custom MapboxCarMapInitializer
for initializing mapboxCarMap
. It looks like this code already has an onDestroy
implementation doing mapboxCarMap.clearObservers()
https://github.com/mapbox/mapbox-maps-android/blob/main/extension-androidauto/src/main/java/com/mapbox/maps/extension/androidauto/MapboxCarMapSessionInstaller.kt#L92
Wouldn't this one be enough? Alternatively I could also override onDestroy
in the session directly.
Android API: 33
Mapbox Navigation SDK version: 2.11.0 androidauto-v0.22.0
Steps to trigger behavior
N/A
Expected behavior
No crash
Actual behavior
The app is crashing due to an
IllegalStateException
potentially because theMapboxScreenManager
is not set up on time.Logs