Fixed
Status Update
Comments
jb...@google.com <jb...@google.com>
do...@google.com <do...@google.com> #2
We'll wait for your sample app.
cl...@google.com <cl...@google.com> #3
Seems like that this happens because in NavHost.kt, a last() function is called without handling the situation where this could be null
cl...@google.com <cl...@google.com> #5
Issue is happening to me as well after library update when I switch between tabs quickly
ap...@google.com <ap...@google.com> #7
I made a sample project, which covers this bug: https://github.com/Milchschlumpf/NavigationComposeBug
I can reproduce this bug with the Emulator and my physical devices. Just click very quickly between two items in the bottom nav bar until the app crashes.
I can reproduce this bug with the Emulator and my physical devices. Just click very quickly between two items in the bottom nav bar until the app crashes.
cl...@google.com <cl...@google.com> #8
I could also reproduce the bug with your own sample: https://github.com/android/compose-samples/tree/main/Jetsnack
Just update the dependency to androidx.navigation:navigation-compose:2.5.0-rc01 and do the same procedure I described in my previous comment.
Just update the dependency to androidx.navigation:navigation-compose:2.5.0-rc01 and do the same procedure I described in my previous comment.
pr...@google.com <pr...@google.com> #9
Project: platform/frameworks/support
Branch: androidx-main
commit 95d95a4c54474fc973eebd775ff953f1a2f54c4a
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Jun 08 14:06:02 2022
Fix crash in NavHost when fast switching between destinations
There is a currently an error when combining Crossfade with
visibleEntries and fast switching between bottom nav items, where when
going from item 1, to item 2, and back to item 1` before the transition
completes.
Crossfade currently disposes whenever the lastEntry changes, in this
case the old item 1 is not equal to the new item 1` and this causes the
visibleEntries which included item 2 to be disposed when the old item 1
to item 2 transition completes, but the item 2 to item 1` transition is
still going and when that attempts to retrieve item 2, it fails cause it
has already been marked as complete.
We need to make it so that visibleEntries are only marked as complete
when crossfade is being disposed.
RelNote: "Fixed a crash caused by fast switching between bottom
destinations when using the Navigation Compose `NavHost`."
Test: tested in sample app
Bug: 234054916
Change-Id: I3979acdda0b6715fcf96bb1948ad6f5e6ba87388
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
https://android-review.googlesource.com/2120138
Branch: androidx-main
commit 95d95a4c54474fc973eebd775ff953f1a2f54c4a
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Jun 08 14:06:02 2022
Fix crash in NavHost when fast switching between destinations
There is a currently an error when combining Crossfade with
visibleEntries and fast switching between bottom nav items, where when
going from item 1, to item 2, and back to item 1` before the transition
completes.
Crossfade currently disposes whenever the lastEntry changes, in this
case the old item 1 is not equal to the new item 1` and this causes the
visibleEntries which included item 2 to be disposed when the old item 1
to item 2 transition completes, but the item 2 to item 1` transition is
still going and when that attempts to retrieve item 2, it fails cause it
has already been marked as complete.
We need to make it so that visibleEntries are only marked as complete
when crossfade is being disposed.
RelNote: "Fixed a crash caused by fast switching between bottom
destinations when using the Navigation Compose `NavHost`."
Test: tested in sample app
Bug: 234054916
Change-Id: I3979acdda0b6715fcf96bb1948ad6f5e6ba87388
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
Description
Version used: 2.8.0-alpha08
If passing an empty string as an safe argument the destination does not exists
@Serializable
object LoginSelector
@Serializable
data class RegisterUser(val email: String)
NavHost(
navController = navController,
startDestination = LoginSelector,
modifier = modifier
) {
composable<LoginSelector> {
Button(onClick = {
navController.navigate(RegisterUser("foo")) // Works!
}) {
Text(text = "Login1")
}
Button(onClick = {
navController.navigate(RegisterUser("")) // Doesn't work. Destination does not exists
}) {
Text(text = "Login2")
}
Button(onClick = {
navController.navigate(RegisterUser(null)) // works if making email nullable
}) {
Text(text = "Login3")
}
}
composable<RegisterUser> { backStackEntry ->
val emailLogin: RegisterUser = backStackEntry.toRoute()
Text(text =emailLogin.email)
}
}