Status Update
Comments
ni...@minetilbud.dk <ni...@minetilbud.dk> #2
Branch: androidx-main
commit 3765621e2b049eaec4f249a7d39ee8d9dde848a8
Author: Clara Fok <clarafok@google.com>
Date: Mon Jun 12 13:43:01 2023
Fix zIndex in NavHost
Currently zIndex is based on currentBackStack size, which causes zIndex ordering issues such as zIndex decreasing instead of increasing while navigating forward with pop. Now zIndex increment/decrement is based on direction of navigaton (forward/backward).
Test: manual test
Bug: 285153947
Change-Id: Ib1c3a329755b2cbec3d28568d03d73e5aa9b9128
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
ni...@sveasolar.com <ni...@sveasolar.com> #3
Fixed internally and will be available in navigation-compose 2.7.0-beta02
th...@c0x12c.com <th...@c0x12c.com> #4
Branch: androidx-main
commit 62f4fb24bcfb6c77684dad3a33d4a70b22fdf5aa
Author: Clara Fok <clarafok@google.com>
Date: Wed Jun 14 13:15:57 2023
Add screenshot test for NavHost zIndex
Test: ./gradlew navigation:navigation-compose:cC
Bug: 285153947
Change-Id: Id810649107018fcc480cc26a33171a2dded5bdb0
M navigation/navigation-compose/build.gradle
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
da...@gallatinapps.com <da...@gallatinapps.com> #5
Seeing this pop up again for us on some Samsung Galaxy S24 running Android 14.
navigation-compose 2.8.5
Fatal Exception: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 1
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.util.Objects.checkIndex(Objects.java:359)
at java.util.ArrayList.get(ArrayList.java:434)
at androidx.navigation.compose.NavHostKt$NavHost$28$1.invokeSuspend(NavHost.kt:620)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:9063)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
la...@gmail.com <la...@gmail.com> #6
I am using navigation-compose = "2.8.6"
and the same error is thrown.
The majority of devices affected are:
- samsung dm3q
- samsung a52q
- realme REE2ADL1
- samsung b2q
Exception java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 1
at jdk.internal.util.Preconditions.outOfBounds (Preconditions.java:64)
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex (Preconditions.java:70)
at jdk.internal.util.Preconditions.checkIndex (Preconditions.java:266)
at java.util.Objects.checkIndex (Objects.java:359)
at java.util.ArrayList.get (ArrayList.java:434)
at androidx.navigation.compose.NavHostKt$NavHost$28$1.invokeSuspend (NavHost.kt:620)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:104)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch (AndroidUiDispatcher.android.kt:79)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch (AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run (AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback (Handler.java:958)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:230)
at android.os.Looper.loop (Looper.java:319)
at android.app.ActivityThread.main (ActivityThread.java:9063)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:588)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
gl...@gmail.com <gl...@gmail.com> #7
Same issue:
Exception java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 1
at jdk.internal.util.Preconditions.outOfBounds (Preconditions.java:64)
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex (Preconditions.java:70)
at jdk.internal.util.Preconditions.checkIndex (Preconditions.java:266)
at java.util.Objects.checkIndex (Objects.java:359)
at java.util.ArrayList.get (ArrayList.java:434)
at androidx.navigation.compose.NavHostKt$NavHost$28$1.invokeSuspend (NavHost.kt:620)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:100)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch (AndroidUiDispatcher.android.kt:81)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch (AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run (AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback (Handler.java:958)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:230)
at android.os.Looper.loop (Looper.java:319)
at android.app.ActivityThread.main (ActivityThread.java:9063)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:588)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
jm...@gmail.com <jm...@gmail.com> #8
I experience the same issue when calling popBackStack(), but not every time. There is no clear pattern to when the javaIndexOutOfBoundsException: Index -1 out of bounds for length 1
java error occurs. Sometimes it happens after one attempt, but other times it takes up to 20 attempts.
In version 2.8.7 of the library, the exception is simply caught and ignored? That doesn’t seem like a proper solution to me.
ma...@marcardar.com <ma...@marcardar.com> #9
My workaround for this is to use android:enableOnBackInvokedCallback="@bool/atLeastSdk35"
in the manifest (for how to declare atLeastSdk35
see:
Since predictive back is only enabled by default for Android 15+ devices, this is an acceptable workaround for me. The only downside being that Android 14 devices opted in to predictive back, won't actually get predictive back enabled for the app, but that beats crashing.
ce...@joinautopilot.com <ce...@joinautopilot.com> #10
BackHandler(
onBack = onBackPressed
)
basically the will override the predicted back gesture (Currently that is the issue)
al...@gmail.com <al...@gmail.com> #11
Seems like this feature is more trouble than it's worth
ka...@gmail.com <ka...@gmail.com> #12
Navigation library used: 2.8.0-alpha10
The crash happens when popBackStack() is called. it happens randomly though. However one way to reproduce this a bit more consistently, was to double tap on the software back (navigation toolbar) button quickly.
Description
Component used: androidx.navigation:navigation-compose
Version used: 2.8.5
Devices/Android versions reproduced on:
So far, we're only seeing this on Android 14. Devices affected (so far) are:
Even after getting the fixes for 340202286 and 375343407 , we're still seeing index-out-of-bounds crashes related to Predictive Back in navigation-compose. The stack trace is as follows:
The offending line is androidx/navigation/compose/NavHost.kt:620 :
We have not yet looked into reproducing this over the weekend, but the ways of reproducing the previous issues do not seem to work, as we tried that after navigation-compose 2.8.5 was released.