Fixed
Status Update
Comments
di...@gmail.com <di...@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
jb...@google.com <jb...@google.com>
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.
na...@google.com <na...@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
Version used: 2.7.2 , 2.7.3
Devices/Android versions reproduced on: Emulator Android 13, Emulator Android 14
Very simple scenario for demo purposes:
1. MainFragment navigates to BottomSheetDialogueFragment(implemented as dialogue in nav_graph)
2. BottomSheetDialogueFragment navigates to DialogFragment
3. DialogFragment dismisses back to BottomSheetDialogueFragment
This will result in the lifecycle of BottomSheetDialogueFragment NavBackStackEntry to not go through any lifecycle changes ( i.e 'ON_RESUME` / `ON_START`) after `ON_PAUSE` even though it is now the top destination on the stack.
I've attached a small sample project with these 3 fragments