Digging through FragmentRouter.java and I think commit() has a lifecycle bug:
private void commit(...) {
mainThread.post(() -> {
...
transaction.commit();
next.onResume(); // this line
menuFrame.setVisibility(View.VISIBLE);
});
}
FragmentTransaction.commit() is asynchronous, it just schedules the transaction for the FragmentManager to process on its next pass, it doesn't run inline. So calling next.onResume() right after commit() fires onResume manually before the fragment even has a view yet, and then later the FragmentManager runs the real lifecycle (onCreateView, onViewCreated, and its own onResume), so onResume ends up firing a second time for real.
Found this because SessionPanel.onResume() already has a comment warning about a very similar bug from re-registering listeners in onResume (duplicate rows, double toggles). I think this router level double call could be quietly reintroducing that same class of bug for every screen, not just SessionPanel, it's just less obvious because most fragments guard their onResume logic with null checks on views or adapters that don't exist yet on that first manual call.
Seems worth just deleting that manual next.onResume() call and letting the FragmentManager drive the lifecycle on its own.
File: android/src/com/focus/kingdom/ui/controller/FragmentRouter.java, commit(), around line 164-178.
Digging through FragmentRouter.java and I think
commit()has a lifecycle bug:FragmentTransaction.commit()is asynchronous, it just schedules the transaction for the FragmentManager to process on its next pass, it doesn't run inline. So callingnext.onResume()right aftercommit()fires onResume manually before the fragment even has a view yet, and then later the FragmentManager runs the real lifecycle (onCreateView, onViewCreated, and its own onResume), so onResume ends up firing a second time for real.Found this because SessionPanel.onResume() already has a comment warning about a very similar bug from re-registering listeners in onResume (duplicate rows, double toggles). I think this router level double call could be quietly reintroducing that same class of bug for every screen, not just SessionPanel, it's just less obvious because most fragments guard their onResume logic with null checks on views or adapters that don't exist yet on that first manual call.
Seems worth just deleting that manual
next.onResume()call and letting the FragmentManager drive the lifecycle on its own.File:
android/src/com/focus/kingdom/ui/controller/FragmentRouter.java,commit(), around line 164-178.