MapUserStyleObserver does not handle local JSON styles

Open
#7,824 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
android, kotlin
Domain
mobile-dev

Research direction

Start with MapUserStyleObserver.kt at the referenced line and inspect how the style URL is handled when the style is loaded from MainCarSession.kt. Reproduce the Android Auto flow with a local JSON style, then verify that both local JSON and cloud-based styles avoid the reported IndexOutOfBoundsException.

Written by the indexing model from the issue text.

Description

Android API: 33
Mapbox Navigation SDK version: 3.0.4

Steps to trigger behavior
  1. Use the android-auto example from this repo as a basis.
  2. Load a map style from a local JSON file in android-auto-app/src/main/java/com/mapbox/navigation/examples/androidauto/car/MainCarSession.kt
  3. Search a route to a destination and start a trip.
Expected behavior

Navigation SDK for Android Auto should handle both cloud-based as well as local JSON styles.

Actual behavior

The following error is thrown:

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    at java.util.Collections$SingletonList.get(Collections.java:5042)
    at com.mapbox.navigation.ui.androidauto.navigation.MapUserStyleObserver.updateState(MapUserStyleObserver.kt:29)
    at com.mapbox.navigation.ui.androidauto.navigation.MapUserStyleObserver.onAttached(MapUserStyleObserver.kt:19)
    at com.mapbox.navigation.ui.androidauto.navigation.roadlabel.CarRoadLabelRenderer.onAttached(CarRoadLabelRenderer.kt:77)
    at com.mapbox.maps.extension.androidauto.CarMapSurfaceOwner.registerObserver$extension_androidauto_release(CarMapSurfaceOwner.kt:54)
    at com.mapbox.maps.extension.androidauto.MapboxCarMap.registerObserver(MapboxCarMap.kt:149)
    at com.mapbox.navigation.ui.androidauto.freedrive.FreeDriveCarScreen$1.onResume(FreeDriveCarScreen.kt:46)
    at androidx.lifecycle.DefaultLifecycleObserverAdapter.onStateChanged(DefaultLifecycleObserverAdapter.kt:26)
    at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.jvm.kt:320)
    at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.jvm.kt:257)
    at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.jvm.kt:293)
    at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.jvm.kt:142)
    at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.jvm.kt:124)
    at androidx.car.app.Screen.lambda$dispatchLifecycleEvent$1$androidx-car-app-Screen(Screen.java:340)
    at androidx.car.app.Screen$$ExternalSyntheticLambda1.run(Unknown Source:4)
    at androidx.car.app.utils.ThreadUtils.runOnMain(ThreadUtils.java:38)
    at androidx.car.app.Screen.dispatchLifecycleEvent(Screen.java:328)
    at androidx.car.app.ScreenManager.popInternal(ScreenManager.java:375)
    at androidx.car.app.ScreenManager.popToRoot(ScreenManager.java:216)
    at com.mapbox.navigation.ui.androidauto.screenmanager.MapboxScreenManager.replaceTop(MapboxScreenManager.kt:235)
    at com.mapbox.navigation.ui.androidauto.screenmanager.MapboxScreenManager.onReplaceTop(MapboxScreenManager.kt:230)
    at com.mapbox.navigation.ui.androidauto.screenmanager.MapboxScreenManager.onScreenEvent(MapboxScreenManager.kt:210)
    at com.mapbox.navigation.ui.androidauto.screenmanager.MapboxScreenManager.access$onScreenEvent(MapboxScreenManager.kt:68)
    at com.mapbox.navigation.ui.androidauto.screenmanager.MapboxScreenManager$lifecycleObserver$1$onCreate$1$1.emit(MapboxScreenManager.kt:81)
    at com.mapbox.navigation.ui.androidauto.screenmanager.MapboxScreenManager$lifecycleObserver$1$onCreate$1$1.emit(MapboxScreenManager.kt:81)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:382)
    at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:235)
    at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:191)
    at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:163)
    at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:474)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:508)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:497)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:368)
    at kotlinx.coroutines.flow.SharedFlowImpl.tryEmit(SharedFlow.kt:399)
    at com.mapbox.navigation.ui.androidauto.screenmanager.MapboxScreenManager$Companion.replaceTop(MapboxScreenManager.kt:292)
    at com.mapbox.navigation.ui.androidauto.preview.CarRoutePreviewScreen.onGetTemplate$lambda$2(CarRoutePreviewScreen.kt:128)
    at com.mapbox.navigation.ui.androidauto.preview.CarRoutePreviewScreen.$r8$lambda$cjvY8ej50Xno8ZQZK_I0s37EBd0(Unknown Source:0)
    at com.mapbox.navigation.ui.androidauto.preview.CarRoutePreviewScreen$$ExternalSyntheticLambda1.onClick(Unknown Source:2)
    at androidx.car.app.model.OnClickDelegateImpl$OnClickListenerStub.lambda$onClick$0$androidx-car-app-model-OnClickDelegateImpl$OnClickListenerStub(OnClickDelegateImpl.java:96)
    at androidx.car.app.model.OnClickDelegateImpl$OnClickListenerStub$$ExternalSyntheticLambda0.dispatch(Unknown Source:2)
    at androidx.car.app.utils.RemoteUtils.lambda$dispatchCallFromHost$0(RemoteUtils.java:148)
    at androidx.car.app.utils.RemoteUtils$$ExternalSyntheticLambda1.run(Unknown Source:6)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8762)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@67854e4, Dispatchers.Main.immediate]

As far as I can tell, the reason seems to be this expectation of an URL scheme.

Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapbox/mapbox-navigation-android

All issues in mapbox/mapbox-navigation-android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.