Fixed
Status Update
Comments
mi...@gmail.com <mi...@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
ra...@google.com <ra...@google.com>
ra...@google.com <ra...@google.com> #3
yea i'll take it.
mi...@gmail.com <mi...@gmail.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.
su...@google.com <su...@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()
}
}
Description
Version used: 1.0.0-alpha10
Devices/Android versions reproduced on: Android 4.4 API 19 Emulator
The bug is pretty easy to reproduce:
1. Boot up a brand new emulator (Android 4.4 API 19), and set the time to current time minus one year
2. Now run an app that enqueues a unique periodic work using the api enqueueUniquePeriodicWork
3. Now change the time of the device back to present time
4. Notice the unique periodic work goes into an endless loop. The only way to fix this issue is to enqueue again, using ExistingPeriodicWorkPolicy.REPLACE