Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Artifact used : "androidx.compose.ui:ui:$compose_version" "androidx.compose.material:material:$compose_version" "androidx.compose.ui:ui-tooling-preview:$compose_version" 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' "androidx.navigation:navigation-compose:2.4.0-alpha09" 'androidx.activity:activity-compose:1.3.1' Version used: compose_version = "1.1.0-alpha04"
Lifecycle issue with Compose and Navigation
Context
Following the sample code, we insert a lifecycle observer :
into a BottomNavigation destination.
Issue
Pressing the same destination twice, or switching rapidly between two destinations will cause the following logs:
meaning the lifecycle is stopped. The issue is we are currently on the screen using the lifecycle, the lifecycle should come back to ON_START then ON_RESUME, but it is never triggered again.
Real use case
A real use case with this issue is using a mapView ( from Crane ) :
It means that with the same behavior, a MapView on a Bottom destination will stop working after pressing the destination twice or going/coming quickly between destinations, as
mapView.onStop()
will be called butmapView.onStart()
won't (hence the mapview is frozen and never "wake up").The only solution is for the user to go to another destination, wait for a second, and come back to the previous destination.
Gif