Fixed
Status Update
Comments
fl...@gmail.com <fl...@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
fl...@gmail.com <fl...@gmail.com> #3
yea i'll take it.
il...@google.com <il...@google.com>
il...@google.com <il...@google.com>
ap...@google.com <ap...@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.
il...@google.com <il...@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
this is the first time I file a bug, so I don't really know how to do that properly.
I noticed that if I create a fragment instance in an activity, add it to the container, remove it with the FragmentTransaction's remove method (which destroys the fragment instance) and then later use the same fragment variable in the activity to add it back to the container (which calls onCreate again), no LifecycleObserver can be added in the fragment's onCreate method, because the fragment is still in DESTROYED state.