Skip to content

Commit

Permalink
Resolve Paper leak on Android
Browse files Browse the repository at this point in the history
Summary:
On Android Paper UIManager, when calling `ReactRootView.unmountReactApplication`, the ReactRootView tag is unset [here](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L926), before the round trip unmount operation to JS makes it's way back to a `dropView` call on `NativeViewHierarchyManager`.

In practice, this means that legacy architecture apps that unmount surfaces via `ReactRootView.unmountReactApplication` leak references to Views, and the "finalization" step (`onDropViewInstance`) is not universally called.

This fixes the issue on Paper by temporarily resetting the `ReactRootView` tag before calling `dropView`.

## Changelog

[Android][Fixed] Fix issue where `onDropViewInstance` cleanup was not being handled after `ReactRootView.unmountReactApplication`

Differential Revision: D64054042
  • Loading branch information
rozele authored and facebook-github-bot committed Oct 8, 2024
1 parent d54c25f commit 5bfa425
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,14 @@ public synchronized void removeRootView(int rootViewTag) {
"View with tag " + rootViewTag + " is not registered as a root view");
}
View rootView = mTagsToViews.get(rootViewTag);
Boolean wasRootTagUnset = rootView.getId() == View.NO_ID;
if (wasRootTagUnset) {
rootView.setId(rootViewTag);
}
dropView(rootView);
if (wasRootTagUnset) {
rootView.setId(View.NO_ID);
}
mRootTags.delete(rootViewTag);
}

Expand Down

0 comments on commit 5bfa425

Please sign in to comment.