Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jb...@google.com <jb...@google.com>
cl...@google.com <cl...@google.com> #2
In 2.8.0-alpha01
both dialog and rememberSavable bugs also applies to the HomeScreen.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit a60261ff67632ef6bbba68cdadaa39a5c51adafd
Author: Clara Fok <clarafok@google.com>
Date: Mon Aug 28 18:35:25 2023
Ensure restored state is not overriden
When Compose activities are destroyed and recreated, upon restoration and new composition, compose may store state as part of rememberSavable calls. If state had already been restored at this point, the store state may override the restored state with empty bundle.
We need to ensure that restoredState is not overriden if it has already been restored.
Test: ./gradlew lifecycle:lifecycle-viewmodel-savedstate:cC
Test: manual test with sample app
Bug: 289436035
Change-Id: I629f952fc3d489cb219a3f19ff2be60d73098e01
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateHandleSupportTest.kt
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/TestComponent.kt
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandleSupport.kt
https://android-review.googlesource.com/2729289
Branch: androidx-main
commit a60261ff67632ef6bbba68cdadaa39a5c51adafd
Author: Clara Fok <clarafok@google.com>
Date: Mon Aug 28 18:35:25 2023
Ensure restored state is not overriden
When Compose activities are destroyed and recreated, upon restoration and new composition, compose may store state as part of rememberSavable calls. If state had already been restored at this point, the store state may override the restored state with empty bundle.
We need to ensure that restoredState is not overriden if it has already been restored.
Test: ./gradlew lifecycle:lifecycle-viewmodel-savedstate:cC
Test: manual test with sample app
Bug: 289436035
Change-Id: I629f952fc3d489cb219a3f19ff2be60d73098e01
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateHandleSupportTest.kt
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/TestComponent.kt
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandleSupport.kt
cl...@google.com <cl...@google.com> #4
Fixed internally and will be available in lifecycle 2.6.2
.
pr...@google.com <pr...@google.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.7.0-alpha02
Description
Component used:
androidx.navigation.compose
Version used:
2.6.0
Devices/Android versions reproduced on: Emulator (Resizable, API 33), but seen of many devices in the wild.
Summary
When using the
dialog
extension method to add a navigation destination. If the content inside has aViewModel
that uses theSavedStateHandle
. When the app is sent to the background, killed by the system, and then restored, theSavedStateHandle
is empty.In addition the use of a
rememberSaveable
in the content of thedialog
doesn't restore its value after process death either.Sample Project
A demo project Available on GitHub with reproduction steps.
Screen recording
Screen recording is attached, in which "Don't Keep Activities" is turned on to simulate the process death.