Fixed
Status Update
Comments
jg...@google.com <jg...@google.com>
ap...@google.com <ap...@google.com> #2
Found the issue, ugh
Noticed that when I do the following:
transaction.addToBackStack(null)
When adding a Fragment with ViewPager2, the above issue occurs, although, idk if it's becaugh of gcFragments() anymore.
As soon as I un-comment that line, the issue disappears.
Noticed that when I do the following:
transaction.addToBackStack(null)
When adding a Fragment with ViewPager2, the above issue occurs, although, idk if it's becaugh of gcFragments() anymore.
As soon as I un-comment that line, the issue disappears.
jg...@google.com <jg...@google.com> #3
Is the Sample application, to reproduce, move back really fast between page 2 -> 1 and vice versa (they are bottom buttons) a couple times.
Wait a couple seconds and page 1 (the black page) should turn white meaning the Fragment has been removed.
As soon as you comment line 40 on MainActivity, and attempt again, the error does not persist
jg...@google.com <jg...@google.com> #4
Woops, sorry, If you guys had the previous ViewPagerCrash test app, I forgot to push (was exhasuted after debugging) I pushed one more time for the latest reproducible code
Description
FragmentMaxLifecycleEnforcer method's updateFragmentMaxLifecycle doesn't guarantee current item will be paused before new one will be resumed.
for (int ix = 0; ix < mFragments.size(); ix++) {
long itemId = mFragments.keyAt(ix);
Fragment fragment = mFragments.valueAt(ix);
if (!fragment.isAdded()) {
continue;
}
transaction.setMaxLifecycle(fragment, itemId == mPrimaryItemId ? RESUMED : STARTED);
fragment.setMenuVisibility(itemId == mPrimaryItemId);
}
Implamentation depends on key order and doesn't enforce current item's lifecycle before new one.
So if I have fragment A and B:
- Moving from A to B will pause A and then resume B
- Moving from B to A will resume A and then pause B