Fixed
Status Update
Comments
ix...@gmail.com <ix...@gmail.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
jb...@google.com <jb...@google.com> #4
This has been fixed internally and will be available in the Fragment 1.3.0-rc02
release.
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