Status Update
Comments
il...@google.com <il...@google.com>
al...@gmail.com <al...@gmail.com> #2
Could you please provide a minimal sample that reproduces this issue?
cl...@google.com <cl...@google.com>
ap...@google.com <ap...@google.com> #3
Yes, of course
@Composable
private fun DemoNavHost() {
val controller = rememberNavController()
NavHost(
navController = controller,
startDestination = "mainRoute",
modifier = Modifier.fillMaxSize()
) {
composable("mainRoute") {
Surface() {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Button(
onClick = {
controller.navigate("demoDialog")
controller.navigate("demoDialog") // Simulate a quick click by the user
}
) {
Text(text = "show dialog")
}
}
}
}
dialog("demoDialog") {
val context = LocalContext.current
val lifecycle = LocalLifecycleOwner.current
Surface() {
Column() {
Text(text = "I'm demo dialog")
Button(
onClick = {
Toast
.makeText(
context,
"${lifecycle.lifecycle.currentState}",
Toast.LENGTH_SHORT
)
.show()
}
) {
Text(text = "check lifecycle")
}
Button(onClick = controller::popBackStack) {
Text(text = "close")
}
}
}
}
}
}
Steps:
Step 1: Click the show dialog
button on mainRoute
Step 2: Because 2 pop-up windows pop up, we close the top one
Step 3: Click the check lifecycle
button on the pop-up window, you can see STARTED
instead of RESUMED
I have also checked the cause, which is consistent with the description in my question.
cl...@google.com <cl...@google.com> #4
In fact, I found another problem. When the tester frequently clicks the button, the button event is to display a Dialog
, Dialog
is set to be destroyed by external click, so Dialog
is always displayed and destroyed
Interesting thing, because it may be too fast, causing DialogHost
to not notice that Dialog
appears and disappears, but it has actually joined NavController#_visibleEntries
But because NavHost#DialogHost
did not process DisposableEffect
, it will not execute dialogNavigator#onTransitionComplete
, so it will not be removed from NavController#_visibleEntries
, and a NavBackStackEntry
leak occurs
The reason may be that the pop-up window appears and disappears within one frame
na...@google.com <na...@google.com> #5
Hi, can you please file a separate bug for the issue you see in
On initial bug - when multiple dialogs are open at the same time and the top one is dismissed, the second dialog in backstack is marked as transitioning to hold it in STARTED state until the top dialog has completed transitioning. But the second dialog was not marked as complete when composed so it stays in STARTED state instead of moving to expected RESUMED state.
Description
Component used: Navigation
Version used: androidx.navigation:navigation-compose:2.7.0-rc01 (same issue occurs with 2.6.0)
Devices/Android versions reproduced on: Pixel 6 / Android 13
Calling
NavController.navigate() { launchSingleTop = true }
when using two nested navigations graphs that both contain a node with the same nested route crashes with this stack trace:I have attached a sample project, here's the interesting part of it: