Fixed
Status Update
Comments
il...@google.com <il...@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
mg...@gtempaccount.com <mg...@gtempaccount.com> #3
yea i'll take it.
il...@google.com <il...@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()
}
}
il...@google.com <il...@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.2.0-alpha05
Devices/Android versions reproduced on:
Device: Google Pixel 2 XL
Android version: 10
Android Security Patch level: September 5, 2019
Google Play System Update: 2019/09
Kernel version: 4.4.177-g83bee1dc48e8
Build Number: QP1A.190711.019
If this is a bug in the library, we would appreciate if you could attach:
Sample app:
Here is a link to a sample app that reproduces the issue, to trigger the issue just run the app it will happen immediately
NOTE: Some how the issue doesn't appear to be happening in some emulated device (Pixel 2 XL API 28)
This is the error that prints out:
java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.lifecycle.ReportFragment.setProcessListener(androidx.lifecycle.ReportFragment$ActivityInitializationListener)' on a null object reference
when super.onCreate get's called
at com.example.sampleproject.MainActivity.onCreate(MainActivity.kt:9)