You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(android): stop the FragmentManager driving fragments with a dead entry
A fragment can outlive the BackstackEntry it is bound to. Navigation only
evicts fragments through transaction.replace(containerViewId, ...), so any
fragment whose container no longer matches the frame's current container -
left over from an activity recreation, a frame reset, or an interrupted
navigation - stays added to the FragmentManager. _removeEntry then clears
resolvedPage and drops entry.fragment without telling the FragmentManager,
and the next transaction happily drives that fragment back through
onCreateView.
Every callback on that path either reported the condition with Trace.error
- which routes to the error handler, rethrows, and becomes a fatal
exception across the JNI boundary - or dereferenced the missing page
directly, so the stale fragment took the app down instead of being
discarded.
- _removeEntry: detach the fragment's callbacks and remove it from the
FragmentManager when it is still added, so it can neither be driven
again nor resurrect the torn down page
- findPageForFragment: discard an unclaimed restored fragment instead of
throwing, and widen the entry lookup through _findEntryForTag so
fragments restored from the backstack or the navigation queue are
matched instead of treated as orphans
- onDestroy: report a missing entry without throwing
- onResume: bail out when the entry or page is gone rather than reading
entry.resolvedPage.frame
- onPause/onDestroyView: tolerate a missing frame
0 commit comments