Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Paper leak on Android #46896

Closed
wants to merge 1 commit into from
Closed

Conversation

rozele
Copy link
Contributor

@rozele rozele commented Oct 8, 2024

Summary:
On Android Paper UIManager, when calling ReactRootView.unmountReactApplication, the ReactRootView tag is unset here, 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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 8, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D64054042

rozele added a commit to rozele/react-native-macos that referenced this pull request Oct 8, 2024
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 is an attempt to fix the issue by skipping the `clearReactRoot` step on Paper, instead waiting for the round trip `UIManager.removeRootView` call.

## Changelog

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

Differential Revision: D64054042
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D64054042

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 is an attempt to fix the issue by skipping the `clearReactRoot` step on Paper, instead waiting for the round trip `UIManager.removeRootView` call.

## Changelog

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

Differential Revision: D64054042
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D64054042

@rozele
Copy link
Contributor Author

rozele commented Oct 8, 2024

cc @wschurman, since you authored #41678

Would this change cause any problems for ReactInstanceManager. recreateReactContextInBackground?

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Oct 9, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 0449630.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @rozele in 0449630

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants