Fixed
Status Update
Comments
lp...@google.com <lp...@google.com> #2
Please provide a minimal sample project that reproduces this issue.
lp...@google.com <lp...@google.com> #3
Sure, I created a minimal sample app for you:
Just click "Next Fragment" multiple times, then press the back button or perform the back gesture multiple times in quick succession.
Note: I tested this on a Pixel 8 with Android 14. Also, I have the predictive back animations enabled in the developer options.
ma...@gmail.com <ma...@gmail.com> #4
Just FYI: Still happens on fragment library version 1.7.1
.
jb...@google.com <jb...@google.com> #5
Still crashing with fragment 1.8.0
. I have updated my example github repo with all latest libraries.
ma...@gmail.com <ma...@gmail.com> #6
Still crashing with fragment 1.8.1
. Example GitHub Repo was updated again.
Description
PreferenceFragmentCompat sets this adapter (PreferenceGroupAdapter), which implicitly registers an observer. PreferenceFragmentCompat never sets the adapter to null when the view is destroyed, so the observer keeps references to the RecyclerView and doesn't get gc'ed.
I've worked around this by explicitly setting the adapter to null in an override of onDestroyView, but since my component doesn't explicitly have ownership of the list handling, I'd argue that PreferenceFragmentCompat should do this cleanup.
It would be solved by setting the RecyclerView adapter to null in the fragment's onDestroyView.
Here's a memory dump.