Fixed
Status Update
Comments
tf...@gmail.com <tf...@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
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #3
yea i'll take it.
il...@google.com <il...@google.com>
ja...@gmail.com <ja...@gmail.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: Fragment
Version used: 1.3.0-alpha08
Devices/Android versions reproduced on: Pixel 4 / Android 10
Sample project:https://github.com/tfcporciuncula/broken-transition
Fragment blinking issue video:https://github.com/tfcporciuncula/broken-transition/blob/master/videos/red%20blink.mp4 (you might need to go frame by frame in the video to see the blinking)
Back issue video:https://github.com/tfcporciuncula/broken-transition/blob/master/videos/back%20regular.mp4 ( and here's a video with the regular behavior for this )
I have very simple slide transitions defined by myself ( exactly like these ones ) and I noticed they got a bit broken after I updated everything to the latest version. I decided to call
FragmentManager.enableNewStateManager(false)
to check if the issues were related to the new state manager, and indeed the issues were gone after that.The first issue I noticed was that the fragment I'm transitioning to blinks in the very beginning of the transition. I managed to reproduce it in the very simple example I'm linking here, but for some reason the issue seems to happen more frequently on my actual app and not that often in the sample, even though it still happen fairly often. It feels like it's a single frame blink, so it's a little hard to see but it's definitely noticeable when it happens.
There's a second issue I noticed while testing this with a super slow transition duration: when I tap back during the transition from the blue fragment to the red fragment, I end up in a blank screen. If I have the
enableNewStateManager(false)
call, it simply moves to the end of the transition and transitions back from the blue fragment to the red, certainly a better behavior.