Fixed
Status Update
Comments
my...@gmail.com <my...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 66494e2d6810347e6a3b41ec3f2665e598f108f0
Author: Ian Lake <ilake@google.com>
Date: Thu Apr 14 00:14:24 2022
Ensure that SavedStateHandle restores upon initial creation
runOnNextRecreation() only runs on the next time
the lifecycle reaches CREATED, not the first time.
By using a LifecycleObserver directly, we ensure that
each Lifecycle move causes a performRestore() to
consistently happen.
Test: existing tests pass, sample app works
BUG: 228865698
Relnote: "Fixed an issue where nesting one `NavHost` within
another `NavHost` in a non-primary bottom navigation tab
would lead to an `IllegalStateException` when using
multiple back stacks."
Change-Id: I11bd5173f035ae1da7922b4142fcedc0f3b54ff6
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandleSupport.kt
https://android-review.googlesource.com/2064518
Branch: androidx-main
commit 66494e2d6810347e6a3b41ec3f2665e598f108f0
Author: Ian Lake <ilake@google.com>
Date: Thu Apr 14 00:14:24 2022
Ensure that SavedStateHandle restores upon initial creation
runOnNextRecreation() only runs on the next time
the lifecycle reaches CREATED, not the first time.
By using a LifecycleObserver directly, we ensure that
each Lifecycle move causes a performRestore() to
consistently happen.
Test: existing tests pass, sample app works
BUG: 228865698
Relnote: "Fixed an issue where nesting one `NavHost` within
another `NavHost` in a non-primary bottom navigation tab
would lead to an `IllegalStateException` when using
multiple back stacks."
Change-Id: I11bd5173f035ae1da7922b4142fcedc0f3b54ff6
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandleSupport.kt
se...@google.com <se...@google.com>
jb...@google.com <jb...@google.com> #3
Thanks for quick fix! Works well with latest snapshot.
my...@gmail.com <my...@gmail.com> #4
Thanks for confirming! The fix will be in the next release of Lifecycle (2.5.0-beta01).
jb...@google.com <jb...@google.com> #5
2.4.1 also has same issue
using jetpack compose / bottom navigation with NavHost
Fatal Exception: java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:192)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:106)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:69)
using jetpack compose / bottom navigation with NavHost
Fatal Exception: java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:192)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:106)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:69)
my...@gmail.com <my...@gmail.com> #6
I am seeing a high occurance rate with 2.5.0-beta01 as well.
jb...@google.com <jb...@google.com> #7
Re remember
around getBackStackEntry
needs to be updated.
ap...@google.com <ap...@google.com> #8
Hi, I recently came across this crash in my current project and I discovered that it happens when a Textfield was tapped and in focus, then the app was backgrounded. This would occur with all of the Textfields in the app.
We are using Compose version: 1.2.0-rc03
and jetpack lifecycle version: 2.4.1
Fatal Exception: java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:192)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:106)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:69)
We are using Compose version: 1.2.0-rc03
and jetpack lifecycle version: 2.4.1
Fatal Exception: java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:192)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:106)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:69)
jb...@google.com <jb...@google.com> #9
Please file a new bug with a minimal sample project that reproduces your error.
my...@gmail.com <my...@gmail.com> #10
Okay, we will get a sample project up soon. One thing I forgot to mention in the initial comment is that this crash occurs when we use backQueue.clear() to clear the back stack. We were able to come up with a solution/workaround by using popUpTo() as a way to clear the back stack, and after implementing that solution we saw no crashes when backgrounding the app while a textfield was in focus.
b9...@gmail.com <b9...@gmail.com> #11
Re backQueue
is not part of the public API surface and never has been. Calling anything on that is always, always, always the wrong thing to do.
jb...@google.com <jb...@google.com> #12
Any updates? This issue is persistent for almost 6 months and its getting crazier.
Description
Component & version used:
Devices/Android versions reproduced on: N/A
Source code:https://github.com/Mygod/VPNHotspot/commit/cc14f607ef48bba755350e68bef68c0f256377fd
Circle CI build:https://app.circleci.com/pipelines/github/Mygod/VPNHotspot/92/workflows/6676d5ec-59eb-4353-845a-4a398c53d90f/jobs/459/steps (should be accessible with any account)
Relevant part of compiler output: