Fixed
Status Update
Comments
jb...@google.com <jb...@google.com>
cl...@google.com <cl...@google.com> #2
Repro sample
@Composable
private fun DemoNavHost() {
val controller = rememberNavController()
NavHost(
navController = controller,
startDestination = "mainRoute",
modifier = Modifier.fillMaxSize()
) {
composable("mainRoute") {
Surface() {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
Button(
onClick = {
controller.navigate("demoDialog")
}
) {
Text(text = "show dialog")
}
}
}
}
dialog("demoDialog") {
val context = LocalContext.current
val lifecycle = LocalLifecycleOwner.current
Surface() {
Column() {
Text(text = "I'm demo dialog")
Button(onClick = controller::popBackStack) {
Text(text = "close")
}
}
}
}
}
}
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 5d32c2c4de3b440237a31e1d59d95e99b0aa23b0
Author: Clara Fok <clarafok@google.com>
Date: Tue Oct 10 17:57:25 2023
Fix popped Dialogs not marked complete
When navigating and popping Dialogs in quick succession, the popped dialogs may not have gone through composition. This means the listeners that are usually attached upon composition are not attached to these popped dialogs. As such, the popped dialogs remain in transition and get leaked into NavController.visibleEntries.
Now we make sure to mark all popped dialogs as complete when the incoming Dialog is composed.
Test: ./gradlew navigation:navigation-compose:cC
Bug: 287969970
Relnote: "Dialogs that were navigated to and dismissed in quick succession will no longer leak into the list of NavController.visibleEntries"
Change-Id: I67586735d33659e524ca7b2e4ae44b2df3494f3e
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/DialogNavigatorTest.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/DialogHost.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/DialogNavigator.kt
https://android-review.googlesource.com/2783727
Branch: androidx-main
commit 5d32c2c4de3b440237a31e1d59d95e99b0aa23b0
Author: Clara Fok <clarafok@google.com>
Date: Tue Oct 10 17:57:25 2023
Fix popped Dialogs not marked complete
When navigating and popping Dialogs in quick succession, the popped dialogs may not have gone through composition. This means the listeners that are usually attached upon composition are not attached to these popped dialogs. As such, the popped dialogs remain in transition and get leaked into NavController.visibleEntries.
Now we make sure to mark all popped dialogs as complete when the incoming Dialog is composed.
Test: ./gradlew navigation:navigation-compose:cC
Bug: 287969970
Relnote: "Dialogs that were navigated to and dismissed in quick succession will no longer leak into the list of NavController.visibleEntries"
Change-Id: I67586735d33659e524ca7b2e4ae44b2df3494f3e
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/DialogNavigatorTest.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/DialogHost.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/DialogNavigator.kt
cl...@google.com <cl...@google.com> #4
Fixed internally and will be available in navigation 2.7.5
.
na...@google.com <na...@google.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-compose:2.7.5
na...@google.com <na...@google.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-compose:2.8.0-alpha01
Description
Component used: Navigation
Version used: 2.7.0-beta01
Devices/Android versions reproduced on: any
Operating procedure:
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.