Fixed
Status Update
Comments
su...@google.com <su...@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
ma...@gmail.com <ma...@gmail.com> #3
yea i'll take it.
su...@google.com <su...@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.
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()
}
}
ko...@gmail.com <ko...@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)
ra...@google.com <ra...@google.com> #7
yea sorry immediate does not fix it.
I actually have a WIP fix for it:
https://android-review.googlesource.com/c/platform/frameworks/support/+/1112186
if your case is the one i found (emitting same LiveData multiple times, as shown in #5) you can work around it by adding a dummy transformation.
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData.map {it })
emitSource(subLiveData.map {it} )
}
I actually have a WIP fix for it:
if your case is the one i found (emitting same LiveData multiple times, as shown in #5) you can work around it by adding a dummy transformation.
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData.map {it })
emitSource(subLiveData.map {it} )
}
Description
Version used: 2.0.1
Devices/Android versions reproduced on: 25
I have a work "queue" defined by some string(`uniqueWorkName`) where I schedule different types of workers with netowrk constraints using `enqueueUniqueWork` and `ExistingPolicy.APPEND`.
Some of the workers may get cancelled before they run(no internet and user canceled the request during this thime). After I cancel ANY worker in the "queue", I am no longer able to submit any work there since everything after this gets marked CANCELED immideately on enqueuing.
Judgingby the code in `EnqueueRunnable.enqueueWorkWithPrerequisites` it is intended behaviour, but it shouldn't be. Why is CANCELING(not FAIL'ing) some of the work in the unique chain of work cancels the rest of them? It should only do so on FAILED jobs!