Fixed
Status Update
Comments
ix...@gmail.com <ix...@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.
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.
Description
Component used: Fragment
Version used: 1.3.0-rc01
Devices/Android versions reproduced on: Samsuns S10e/Android 10, Google Pixel 4XL/Android 11
Reproducing: Attached a sample app, look at
MainActivity
/MainActivityViewModel
/FirstFragment
.Description of the issue:
I have stumbled upon a Fragment lifecycle issue where under certain conditions the
Fragment#onResume()
method does not get called. Conditions of reproducing:ChangeBounds
in my example),Activity#onCreate()
as a result of aLiveData
emission.It feels like some race condition, but is surprisingly stable at reproducing (pretty much at 100%, I only failed to reproduce it once on a fresh install) at different devices.
In the logs:
Any of the following actions fix the issue:
StateFlow
instead ofLiveData
in Activity (for initiating a Fragment transaction),Once one of these workarounds has been applied, logs are like this:
or