Fixed
Status Update
Comments
ro...@gmail.com <ro...@gmail.com> #2
Yigit, do you have time to fix it?
reemission of the same liveData is racy
reemission of the same liveData is racy
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #3
yea i'll take it.
jb...@google.com <jb...@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.
ro...@gmail.com <ro...@gmail.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()
}
}
ma...@gmail.com <ma...@gmail.com> #6
With 2.2.0-alpha04 (that use Main.immediate), the issue seems to be still there (I tested it by calling emitSource() twice, like your test case)
Description
Version used: 2.4.0-alpha05
Devices/Android versions reproduced on: Pixel 5, Android 12 beta, and Android 11 emulator
Context here in Slack:
I have a text field in a screen that is part of a navigation graph accessed through a bottom nav. When I type something in the text field, and switch to another tab, and then back again, the text field is empty. I was expecting the state to be saved.
Works in 2.4.0-alpha04 so seems to be a regression.
I have a Github repository with a sample project here, where the last commit reverts to 2.4.0-alpha04. I will zip and attach the broken version to this report. (