Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ma...@gmail.com <ma...@gmail.com> #2
Forgot to paste the exception that was thrown:
No destination with route subGraph is on the NavController's back stack. The current destination is Destination(0xe5901274) route=a
ma...@gmail.com <ma...@gmail.com> #3
This is still happening with navigation-compose 2.4.0-alpha06
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit d7af5243adb70d92a0104005ff353c83933c97ed
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Aug 23 22:03:09 2021
Ensure NavGraph Navigators are destroyed properly
When navigating with transitions, we properly hold destination entries
until the transition completes, but not for NavGraph entries. This is a
particular issue for popping since it results in NavGraph entries will
be moved to DESTROYED before their child destinations.
We need to make NavGraph back stack entries keep the maximum lifecycle
state of all of the entries in the graph. This means that as long as one
entry in the graph is CREATED, the graph itself will be CREATED and only
after all entries have been DESTROYED, will the NavGraph entry also be
destroyed.
RelNote: "Using getBackStackEntry and previousBackStackEntry inside
composable(), in conjuction with remember() will no longer cause an
exception for no destination being on the back stack."
Test: add new test
Bug: 194313238
Change-Id: I75138d24d27dac83b5301507161578ac811454e3
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
https://android-review.googlesource.com/1806636
Branch: androidx-main
commit d7af5243adb70d92a0104005ff353c83933c97ed
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Aug 23 22:03:09 2021
Ensure NavGraph Navigators are destroyed properly
When navigating with transitions, we properly hold destination entries
until the transition completes, but not for NavGraph entries. This is a
particular issue for popping since it results in NavGraph entries will
be moved to DESTROYED before their child destinations.
We need to make NavGraph back stack entries keep the maximum lifecycle
state of all of the entries in the graph. This means that as long as one
entry in the graph is CREATED, the graph itself will be CREATED and only
after all entries have been DESTROYED, will the NavGraph entry also be
destroyed.
RelNote: "Using getBackStackEntry and previousBackStackEntry inside
composable(), in conjuction with remember() will no longer cause an
exception for no destination being on the back stack."
Test: add new test
Bug: 194313238
Change-Id: I75138d24d27dac83b5301507161578ac811454e3
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
jb...@google.com <jb...@google.com> #5
This has been fixed internally and will be available in the Navigation 2.4.0-alpha08
release.
This also includes a lint check to ensure you surround any calls to getBackStackEntry
within composition with a remember
, which you should always be doing anyway, and that is the only way this actually works.
ri...@gmail.com <ri...@gmail.com> #6
I don't understand why and how do we need to surround getBackStackEntry
with a remember
.
Even the docs does not do that
Description
Component used: navigation-compose Version used: 2.4.0-alpha05
Steps to reproduce:
Ref to Slack convo:https://kotlinlang.slack.com/archives/CJLTWPH7S/p1626963158280100?thread_ts=1626960240.270300&cid=CJLTWPH7S
Sample code to reproduce the issue: