Fixed
Status Update
Comments
wi...@gmail.com <wi...@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>
cl...@google.com <cl...@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.
pr...@google.com <pr...@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()
}
}
co...@gmail.com <co...@gmail.com> #6
Comment has been deleted.
Description
Version used: 2.7.7
Devices/Android versions reproduced on: Pixel 3, Pixel 7 Pro
We recently experienced an app crash when switching our NavHost's startDestination. After some investigation, it seems like this is triggered only after having previously navigated between two routes, where the second route is nested inside of a nav graph whose route has the same name as a sibling of the starting route (causing them to have the same ID).
Fortunately, this means the crash can be avoided by avoiding those duplicates, but it was a bit tricky to find the cause of the NullPointerException, and it would be nice if it failed more gracefully than a NullPointerException with the possibility of crashing the app entirely.
I have attached a sample app which reproduces this crash.