Skip to content

Conversation

@yungsters
Copy link
Contributor

Summary:
Currently, IntersectionObserver#observe retains a reference to the ShadowNode of the view that is supplied as an argument, which is used to compute intersection whenever a shadow tree is committed.

However, the shadowNode includes all of child nodes and state at the time that IntersectionObserver#observe is called. This means that an active IntersectionObserverEntry will retain references to memory that would otherwise be deallocated (e.g. if children of the observed view are unmounted after IntersectionObserver#observe is called).

This diff refactors IntersectionObserver to instead retain a reference to the ShadowNodeFamily, which does not retain references to child nodes and still eanbles IntersectionObserver to compute intersections.

Changelog:
[General][Changed] - Fixed IntersectionObserver#observe to avoid retaining memory for unmounted child nodes of an observed view.

Differential Revision: D74130479

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels May 4, 2025
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

yungsters added a commit to yungsters/react-native that referenced this pull request May 6, 2025
…acebook#51089)

Summary:

Currently, `IntersectionObserver#observe` retains a reference to the `ShadowNode` of the view that is supplied as an argument, which is used to compute intersection whenever a shadow tree is committed.

However, the `shadowNode` includes all of child nodes and state at the time that `IntersectionObserver#observe` is called. This means that an active `IntersectionObserverEntry` will retain references to memory that would otherwise be deallocated (e.g. if children of the observed view are unmounted after `IntersectionObserver#observe` is called).

This diff refactors `IntersectionObserver` to instead retain a reference to the `ShadowNodeFamily`, which does not retain references to child nodes and still eanbles `IntersectionObserver` to compute intersections.

Changelog:
[General][Changed] - Fixed `IntersectionObserver#observe` to avoid retaining memory for unmounted child nodes of observed views.

Differential Revision: D74130479
@yungsters yungsters force-pushed the export-D74130479 branch from 92a68aa to 761107c Compare May 6, 2025 00:56
@facebook-github-bot
Copy link
Contributor

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

@yungsters yungsters force-pushed the export-D74130479 branch from 761107c to e21a559 Compare May 6, 2025 19:03
yungsters added a commit to yungsters/react-native that referenced this pull request May 6, 2025
…acebook#51089)

Summary:

Currently, `IntersectionObserver#observe` retains a reference to the `ShadowNode` of the view that is supplied as an argument, which is used to compute intersection whenever a shadow tree is committed.

However, the `shadowNode` includes all of child nodes and state at the time that `IntersectionObserver#observe` is called. This means that an active `IntersectionObserverEntry` will retain references to memory that would otherwise be deallocated (e.g. if children of the observed view are unmounted after `IntersectionObserver#observe` is called).

This diff refactors `IntersectionObserver` to instead retain a reference to the `ShadowNodeFamily`, which does not retain references to child nodes and still eanbles `IntersectionObserver` to compute intersections.

Changelog:
[General][Changed] - Fixed `IntersectionObserver#observe` to avoid retaining memory for unmounted child nodes of observed views.

Differential Revision: D74130479
yungsters added a commit to yungsters/react-native that referenced this pull request May 6, 2025
…acebook#51089)

Summary:

Currently, `IntersectionObserver#observe` retains a reference to the `ShadowNode` of the view that is supplied as an argument, which is used to compute intersection whenever a shadow tree is committed.

However, the `shadowNode` includes all of child nodes and state at the time that `IntersectionObserver#observe` is called. This means that an active `IntersectionObserverEntry` will retain references to memory that would otherwise be deallocated (e.g. if children of the observed view are unmounted after `IntersectionObserver#observe` is called).

This diff refactors `IntersectionObserver` to instead retain a reference to the `ShadowNodeFamily`, which does not retain references to child nodes and still eanbles `IntersectionObserver` to compute intersections.

Changelog:
[General][Changed] - Fixed `IntersectionObserver#observe` to avoid retaining memory for unmounted child nodes of observed views.

Differential Revision: D74130479
@yungsters yungsters force-pushed the export-D74130479 branch from e21a559 to e9bb16d Compare May 6, 2025 19:07
@facebook-github-bot
Copy link
Contributor

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

yungsters added a commit to yungsters/react-native that referenced this pull request May 6, 2025
…acebook#51089)

Summary:
Pull Request resolved: facebook#51089

Currently, `IntersectionObserver#observe` retains a reference to the `ShadowNode` of the view that is supplied as an argument, which is used to compute intersection whenever a shadow tree is committed.

However, the `shadowNode` includes all of child nodes and state at the time that `IntersectionObserver#observe` is called. This means that an active `IntersectionObserverEntry` will retain references to memory that would otherwise be deallocated (e.g. if children of the observed view are unmounted after `IntersectionObserver#observe` is called).

This diff refactors `IntersectionObserver` to instead retain a reference to the `ShadowNodeFamily`, which does not retain references to child nodes and still eanbles `IntersectionObserver` to compute intersections.

Changelog:
[General][Changed] - Fixed `IntersectionObserver#observe` to avoid retaining memory for unmounted child nodes of observed views.

Differential Revision: D74130479
@yungsters yungsters force-pushed the export-D74130479 branch from e9bb16d to 10f6aff Compare May 6, 2025 19:07
…acebook#51089)

Summary:
Pull Request resolved: facebook#51089

Currently, `IntersectionObserver#observe` retains a reference to the `ShadowNode` of the view that is supplied as an argument, which is used to compute intersection whenever a shadow tree is committed.

However, the `shadowNode` includes all of child nodes and state at the time that `IntersectionObserver#observe` is called. This means that an active `IntersectionObserverEntry` will retain references to memory that would otherwise be deallocated (e.g. if children of the observed view are unmounted after `IntersectionObserver#observe` is called).

This diff refactors `IntersectionObserver` to instead retain a reference to the `ShadowNodeFamily`, which does not retain references to child nodes and still eanbles `IntersectionObserver` to compute intersections.

Changelog:
[General][Changed] - Fixed `IntersectionObserver#observe` to avoid retaining memory for unmounted child nodes of observed views.

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

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

@yungsters yungsters force-pushed the export-D74130479 branch from 10f6aff to c6bfab1 Compare May 6, 2025 19:19
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 6, 2025
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in d945c58.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @yungsters in d945c58

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