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
cc...@google.com <cc...@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()
}
}
cc...@google.com <cc...@google.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: I can reproduce it in a different versions.
Devices/Android versions reproduced on: Pixel XL
This error is logged in NavDestination.onInflate() when NavHostFragment inflates nav graph. The call stack is:
NavHostFragment.onCreate()
NavController.setGraph()
NavInflater.inflate(int graphResId)
NavInflater.inflate(Resources res, XmlResourceParser parser, AttributeSet attrs, int graphResId)
NavDestination.onInflate()
In NavDestination.onInflate(), if <navigation> doesn’t have an id, we will set mId to 0. Then we pass mId to getDisplayName(). Because mId is 0 now, it will throw a Resources.NotFoundException and log error “Invalid ID 0x00000000”.