Fixed
Status Update
Comments
il...@google.com <il...@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
il...@google.com <il...@google.com>
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #3
yea i'll take it.
il...@google.com <il...@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.
sh...@google.com <sh...@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: Navigation Version used: 2.3.5 Devices/Android versions reproduced on: Irrelevant ;)
Repro steps:
Expected Result: OnDestinationChangedListener receives callback when it is set, and then receives a callback when it causes navigation to B.
Actual Result: OnDestinationChangedListener receives callback when it is set, and then DOES NOT receive a callback when it causes navigation to B.
After the OnDestinationChangedListener is set, this sort of reentrant call works as would be expected, but when getting the callback after having set the OnDestinationChangedListener, it does not.
I think this simply requires swapping
and
in NavController.java. :)