Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jb...@google.com <jb...@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
se...@gmail.com <se...@gmail.com> #3
yea i'll take it.
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.
jb...@google.com <jb...@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()
}
}
ge...@gmail.com <ge...@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
Component used: Activity
Version used: 1.2.0-alpha08
Devices/Android versions reproduced on: Pixel 2 XL Android 10
I've received several crash reports with the following stacktrace:
It looks like the issue was starting to happen after these changes:
The default start number of request codes is set to 0x00010000, but in onRestoreInstanceState the value is set to the key map size:
This line should probably look like this:
mNextRc.set(0x00010000 + numKeys);
This issue is a copy of https://issuetracker.google.com/issues/157584993 . I've decided to create a new issue in androidx activity component since there is a little chance that anyone will look at the old issue which is closed without a proper fix.