Fixed
Status Update
Comments
ra...@google.com <ra...@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
ru...@gmail.com <ru...@gmail.com> #3
yea i'll take it.
ra...@google.com <ra...@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.
ap...@google.com <ap...@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()
}
}
an...@google.com <an...@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
Version used: 2.1.0
Devices/Android versions reproduced on: 6.0
We're getting this crash on multiple devices:
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.util.ArrayMap.get(java.lang.Object)' on a null object reference
at android.os.BaseBundle.getString + 928(BaseBundle.java:928)
at androidx.work.impl.background.systemjob.SystemJobService.onStartJob + 104(SystemJobService.java:104)
at android.app.job.JobService$JobHandler.handleMessage + 126(JobService.java:126)
at android.os.Handler.dispatchMessage + 102(Handler.java:102)
at android.os.Looper.loop + 150(Looper.java:150)
at android.app.ActivityThread.main + 5621(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 794(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main + 684(ZygoteInit.java:684)
It's the same cause as the following bug: