Fixed
Status Update
Comments
ma...@google.com <ma...@google.com>
ma...@google.com <ma...@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...@google.com <ma...@google.com>
ma...@google.com <ma...@google.com> #3
yea i'll take it.
ma...@google.com <ma...@google.com>
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.
an...@sigma.software <an...@sigma.software> #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()
}
}
pr...@google.com <pr...@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: 1.2.4 and 1.3.0-alpha05
Devices/Android versions reproduced on: Emulator Pixel 6 API 33
This issue occurs in my project with single flavor dimension, as well as in Now in Android -
To reproduce: execute tasks "generate<Flavor>ReleaseBaselineProfile assemble<Flavor>Release" together.
It also reproduces if you execute single task "assemble<Flavor>Release" with automaticGenerationDuringBuild = true
Error log (from Now in Android):
* What went wrong:
A problem was found with the configuration of task ':app:copyDemoReleaseBaselineProfileIntoSrc' (type 'MergeBaselineProfileTask').
- Gradle detected a problem with the following location: '.../nowinandroid/app/src/demoRelease/generated/baselineProfiles'.
Reason: Task ':app:mergeDemoReleaseStartupProfile' uses this output of task ':app:copyDemoReleaseBaselineProfileIntoSrc' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':app:copyDemoReleaseBaselineProfileIntoSrc' as an input of ':app:mergeDemoReleaseStartupProfile'.
2. Declare an explicit dependency on ':app:copyDemoReleaseBaselineProfileIntoSrc' from ':app:mergeDemoReleaseStartupProfile' using Task#dependsOn.
3. Declare an explicit dependency on ':app:copyDemoReleaseBaselineProfileIntoSrc' from ':app:mergeDemoReleaseStartupProfile' using Task#mustRunAfter.