mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
476 stars 133 forks source link

State must be at least CREATED to move to DESTROYED, but was INITIALIZED #2445

Closed SamYStudiO closed 3 months ago

SamYStudiO commented 3 months ago

Environment

Observed behavior and steps to reproduce

I see a lot of crashes from firebase crashlytics but i can't reproduce it.

Fatal Exception: java.lang.IllegalStateException: State must be at least CREATED to move to DESTROYED, but was INITIALIZED in component com.mapbox.maps.plugin.lifecycle.ViewLifecycleOwner@180f36c
       at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.jvm.kt:131)
       at androidx.lifecycle.LifecycleRegistry.setCurrentState(LifecycleRegistry.jvm.kt:107)
       at com.mapbox.maps.plugin.lifecycle.ViewLifecycleOwner.doOnAttached(ViewLifecycleOwner.kt:73)
       at com.mapbox.maps.plugin.lifecycle.ViewLifecycleOwner.<init>(ViewLifecycleOwner.kt:60)
       at com.mapbox.maps.plugin.lifecycle.MapboxLifecyclePluginImpl.registerLifecycleObserver(MapboxLifecyclePluginImpl.kt:30)
       at com.mapbox.maps.plugin.MapPluginRegistry.onAttachedToWindow(MapPluginRegistry.kt:192)
       at com.mapbox.maps.MapController.onAttachedToWindow$sdk_release(MapController.kt:373)
       at com.mapbox.maps.MapView.onAttachedToWindow(MapView.kt:135)
       at android.view.View.dispatchAttachedToWindow(View.java:21308)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4239)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4246)
       at android.view.ViewGroup.addViewInner(ViewGroup.java:6001)
       at android.view.ViewGroup.addView(ViewGroup.java:5777)
       at android.view.ViewGroup.addView(ViewGroup.java:5717)
       at android.view.ViewGroup.addView(ViewGroup.java:5690)
       at android.view.ViewOverlay$OverlayViewGroup.add(ViewOverlay.java:208)
       at android.view.ViewGroupOverlay.add(ViewGroupOverlay.java:72)
       at androidx.transition.Visibility.onDisappear(Visibility.java:429)
       at androidx.transition.Visibility.createAnimator(Visibility.java:254)
       at androidx.transition.Transition.createAnimators(Transition.java:798)
       at androidx.transition.TransitionSet.createAnimators(TransitionSet.java:476)
       at androidx.transition.TransitionSet.createAnimators(TransitionSet.java:476)
       at androidx.transition.Transition.playTransition(Transition.java:1934)
       at androidx.transition.TransitionManager$MultiListener.onPreDraw(TransitionManager.java:300)
       at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1102)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3311)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2201)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9000)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:996)
       at android.view.Choreographer.doCallbacks(Choreographer.java:794)
       at android.view.Choreographer.doFrame(Choreographer.java:729)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:981)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:7948)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
flasher297 commented 3 months ago

I've raised an internal ticket to investigate this crash. We'll return as soon as we have any feedback.

pengdev commented 3 months ago

@SamYStudiO could you clarify the environment? Did you use compose in your app?

Levidamales commented 3 months ago

@pengdev I faced the same problem and I am using compose in my app. Do you have any suggestions?

MatheusAraujoPro commented 3 months ago

Hello Guis, i've the same problem, but with navigation throught Deep Link navigation!

pengdev commented 3 months ago

Hey @Levidamales @MatheusAraujoPro please update to the latest compose extension release, we have disabled the lifecycle plugin in the latest compose extension release, now all the lifecycle is handled within the compose extension and the above problematic code path wouldn't be executed.

Levidamales commented 3 months ago

I updated the compose extension version, but still have another case of the issue. Do you think they can be of the same reason?

This happens whenever I try to navigate after screen rotation:


java.lang.IllegalStateException: State must be at least CREATED to move to DESTROYED, but was INITIALIZED in component NavBackStackEntry(2d8f0727-c13b-4635-ac94-f279608c3cfc) destination=Destination(0x67884f5a) route=Editor
    at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.jvm.kt:131)
    at androidx.lifecycle.LifecycleRegistry.setCurrentState(LifecycleRegistry.jvm.kt:107)
    at androidx.navigation.NavBackStackEntry.updateState(NavBackStackEntry.kt:186)
    at androidx.navigation.NavBackStackEntry.setMaxLifecycle(NavBackStackEntry.kt:159)
    at androidx.navigation.NavController.updateBackStackLifecycle$navigation_runtime_release(NavController.kt:1100)
    at androidx.navigation.NavController.dispatchOnDestinationChanged(NavController.kt:996)
    at androidx.navigation.NavController.navigate(NavController.kt:1882)
    at androidx.navigation.NavController.navigate(NavController.kt:1817)
    at androidx.navigation.NavController.navigate(NavController.kt:2225)
    at androidx.navigation.NavController.navigate$default(NavController.kt:2220)
    at ...
pengdev commented 3 months ago

@Levidamales from the stack trace, I didn't see anything mapbox-specific code path. There might be some other issues in your code relates to NavBackStackEntry.

SamYStudiO commented 2 months ago

@SamYStudiO could you clarify the environment? Did you use compose in your app?

@pengdev I'm not using compose and this issue happens a lot in my production app

This started to appear without any change to mapbox version but a change from lifecycle library from 2.8.2 to 2.8.3... this info may help figure it out

image

SamYStudiO commented 2 months ago

@pengdev Can this be reopened or should i create new?

Galkin-Palkin commented 2 months ago

@SamYStudiO I posted an answer to StackOverflow. It's about Jetpack Compose, but you may find something useful for you: https://stackoverflow.com/questions/78927851/jetpack-compose-navigation-crashes-app-after-orientation-change

pengdev commented 2 months ago

@pengdev Can this be reopened or should i create new?

@SamYStudiO please create new ticket with detailed information, would be good if you have a minimum reproduce example.

SamYStudiO commented 2 months ago

@Galkin-Palkin I'm not using compose @pengdev i'll make another ticket, problem is i can't reproduce it but as shown from firebase it happens a lot in production