Conversation
kligarski
left a comment
There was a problem hiding this comment.
Looks good.
I might've found another leak:
Screen.Recording.2026-04-13.at.12.58.31.mov
But I guess that it might be unrelated to this PR.
This one might be the result that we have some nested stacks, which screens aren't displayed at this time, but I'll check #3855 because that one might help here. I had a similar case when using JS tabs https://github.com/software-mansion/react-native-screens-labs/issues/1130 but in that one there are 3 paths and the main problem is that these Screen instances are attached in the view hierarchy all the time. To sum up, if that PR with freeing fragmentWrapper is sufficient, I think we may try to proceed in that one, but if in your case, all resources will be deallocated when you'll go back to the 1st screen - this isn't memory leak, rather an issue in our Model (especially in |
9d02d76 to
07f58f5
Compare
07f58f5 to
b02f241
Compare
Description
Detected retention chain:
ScreenStackHeaderConfig.onUpdatecallsactivity.setSupportActionBar(toolbar)on top screen updates.AppCompatDelegateImplstores the resultingToolbarActionBarinmActionBarfor the lifetime of the activity. When a screen is popped (and the new top screen does not install a replacement ActionBar) the staleToolbarActionBaris never released.In
onDestroyViewofScreenStackFragment, call reset SupportActionBar to release it and the fragment. I'm storing a reference toactionBarthat ensures the call is skipped when the incoming screen has already installed its own toolbar inonUpdate.Closes: https://github.com/software-mansion/react-native-screens-labs/issues/1129
Changes
setToolbarsignature to pass a CustomToolbar, which allows for storing the header config - HeaderConfig is nulled by React transaction before FragmentManager sends onDestroy to ScreenStackFragmentBefore & after - visual documentation
before.mov
after.mov
Test plan
Test3867
Checklist