Fixed
Status Update
Comments
jb...@google.com <jb...@google.com>
cl...@google.com <cl...@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
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()
}
}
na...@google.com <na...@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
Component used: Navigation
Version used: 2.7.0-beta01
Devices/Android versions reproduced on: any
Operating procedure:
When the tester frequently clicks the button, the button event is to display a Dialog, Dialog is set to be destroyed by external click, so Dialog is always displayed and destroyed
Interesting thing, because it may be too fast, causing DialogHost to not notice that Dialog appears and disappears, but it has actually joined NavController#_visibleEntries
But because NavHost#DialogHost did not process DisposableEffect, it will not execute dialogNavigator#onTransitionComplete, so it will not be removed from NavController#_visibleEntries, and a NavBackStackEntry leak occurs
The reason may be that the pop-up window appears and disappears within one frame.