Fixed
Status Update
Comments
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@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
ap...@google.com <ap...@google.com> #3
yea i'll take it.
jb...@google.com <jb...@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.
il...@google.com <il...@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()
}
}
Description
Component used: Activity Version used: 1.2.0-alpha04 Devices/Android versions reproduced on: Pixel 3 / Android 10
From the "Take photos" docs :
ActivityResultContracts.TakePicture
doesn't perform this check, so if there's no activity that can handle its intent, the app will crash. I'd guess this applies forTakePicturePreview
andTakeVideo
as well.I personally don't see an easy fix for this given the current API, and at the same time I wouldn't like to see the API getting more complicated to accommodate this. I'm currently happy using the simple
ActivityResultContracts.StartActivityForResult
so I can fully control the intent creation plus other relevant things like saving the file path properly so I don't lose it in case of process death.