Fixed
Status Update
Comments
mg...@google.com <mg...@google.com>
dr...@gmail.com <dr...@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
mg...@google.com <mg...@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.
pr...@google.com <pr...@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()
}
}
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
Component used: lifecycle-viewmodel
Version used: 2.8
Summary: the migration of ViewModelProvider to KMP seemingly reverted a 2 year old fix to an issue that had to do with desugaring for compileOnly dependencies in a library project.
Lifecycle 2.5.0 alpha accidentally broke backward compatibility, this was quickly fixed in Lifecycle 2.5.0-rc02, see this issue for context: https://issuetracker.google.com/issues/230454566
The fix was here:https://android-review.googlesource.com/c/platform/frameworks/support/+/2108693
The recent migration of ViewModelProvider.Factory to KMP seems to have reverted the fix:https://android-review.googlesource.com/c/platform/frameworks/support/+/2966765
As a result, the original runtime crash has surfaced again in lifecycle-viewmodel 2.8, as reported here:https://github.com/square/leakcanary/issues/2677
Someone created a repro at the time, you could probably reuse that to repro after updating the dependencies:https://github.com/dougnazar/leak_viewmodel