Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jb...@google.com <jb...@google.com>
cl...@google.com <cl...@google.com> #2
Yigit, do you have time to fix it?
reemission of the same liveData is racy
reemission of the same liveData is racy
ap...@google.com <ap...@google.com> #3
yea i'll take it.
cl...@google.com <cl...@google.com> #4
Thanks for the detailed analysis. This may not be an issue anymore since we've started using Main.immediate there but I' not sure; I'll try to create a test case.
pr...@google.com <pr...@google.com> #5
just emitting same live data reproduces the issue.
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
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.