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
ev...@gmail.com <ev...@gmail.com> #3
yea i'll take it.
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()
}
}
ev...@gmail.com <ev...@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.0.0
Devices/Android versions reproduced on:Emulator 8.0, Pixel 2 XL 9.x
So basically for reproduce you need simple flow:
1. Graph with Fragment with arguments with default values as default destination
2. Main Activity launcher which hosts the graph
3. in Activity.onCreate() start listen for destination changes:
navController.addOnDestinationChangedListener { controller, destination, arguments -> }
4. When activity first creates onDestinationChanged() gets called but arguments is null.
Fragment will receive those default arguments tho.
This happens only if fragment is startDestination. If we navigate to this fragment otherwise (clicks, menus) with NavController.navigate() default arguments will be at place.