Skip to content

Animated: Lazily Allocate AnimatedNode Instances#46317

Closed
yungsters wants to merge 5 commits into
facebook:mainfrom
yungsters:export-D62117423
Closed

Animated: Lazily Allocate AnimatedNode Instances#46317
yungsters wants to merge 5 commits into
facebook:mainfrom
yungsters:export-D62117423

Conversation

@yungsters
Copy link
Copy Markdown
Contributor

Summary:
Changes AnimatedProps to avoid allocating AnimatedStyle (and AnimatedTransform, AnimatedObject) unless necessary.

This not only reduces memory and traversal overhead, but it enables us to implement allowlist strategies to prune unnecessary traversals.

Changelog:
[Internal]

Differential Revision: D62117423

@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 Sep 3, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

Summary:
Pull Request resolved: facebook#46312

Refactors `NativeAnimatedHelper` to make it easier to read, reduce runtime overhead, and no longer export `queueOperation` (which was not useable externally anyway).

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D62139993
Summary:
Pull Request resolved: facebook#46286

Optimizes the runtime performance of `Animated` by using memoization to avoid repetitive traversals of `props` (and `style`) values.

Changelog:
[General][Changed] - Improved runtime performance of `Animated`

Reviewed By: javache

Differential Revision: D62037506
Summary:
Currently, `AnimatedNode.prototype.getListeners` creates an array with `Object.keys()` to determine the number of listeners.

This is a relatively hot code path for animation-intensive user interfaces. Although `Object.keys()` is fast, every unnecessary memory allocation is an unnecessary opportunity to create garbage that requires collection.

Using an object as a dictionary performs worst than using a `Map` anyway, so this switches `AnimatedNode` to use a `Map`.

Changelog:
[Internal]

Differential Revision: D62267352
Summary:
Currently, the logic for managing the native subscription in `AnimatedNode` is scattered and difficult to follow. This refactors the code to make the subscription's state easier to understand and harder to break in future refactors.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D62268695
@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

Summary:
Pull Request resolved: facebook#46317

Changes `AnimatedProps` to avoid allocating `AnimatedStyle` (and `AnimatedTransform`, `AnimatedObject`) unless necessary.

This not only reduces memory and traversal overhead, but it enables us to implement allowlist strategies to prune unnecessary traversals.

Changelog:
[General][Changed] - Animated now omits `style` if the supplied value is null, undefined, or not an object. Previously, it would emit an empty `style` object.
[General][Changed] - Animated now resolves `style` to the original prop value if it contains no `AnimatedNode` instances. Previously, it would resolve to a flattened style object.

Reviewed By: javache

Differential Revision: D62117423
@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

yungsters added a commit to yungsters/react-native that referenced this pull request Sep 8, 2024
Summary:
Pull Request resolved: facebook#46317

Changes `AnimatedProps` to avoid allocating `AnimatedStyle` (and `AnimatedTransform`, `AnimatedObject`) unless necessary.

This not only reduces memory and traversal overhead, but it enables us to implement allowlist strategies to prune unnecessary traversals.

Changelog:
[General][Changed] - Animated now omits `style` if the supplied value is null, undefined, or not an object. Previously, it would emit an empty `style` object.
[General][Changed] - Animated now resolves `style` to the original prop value if it contains no `AnimatedNode` instances. Previously, it would resolve to a flattened style object.

Reviewed By: javache

Differential Revision: D62117423
yungsters added a commit to yungsters/react-native that referenced this pull request Sep 8, 2024
Summary:
Pull Request resolved: facebook#46317

Changes `AnimatedProps` to avoid allocating `AnimatedStyle` (and `AnimatedTransform`, `AnimatedObject`) unless necessary.

This not only reduces memory and traversal overhead, but it enables us to implement allowlist strategies to prune unnecessary traversals.

Changelog:
[General][Changed] - Animated now omits `style` if the supplied value is null, undefined, or not an object. Previously, it would emit an empty `style` object.
[General][Changed] - Animated now resolves `style` to the original prop value if it contains no `AnimatedNode` instances. Previously, it would resolve to a flattened style object.

Reviewed By: javache

Differential Revision: D62117423
yungsters added a commit to yungsters/react-native that referenced this pull request Sep 9, 2024
Summary:
Pull Request resolved: facebook#46317

Changes `AnimatedProps` to avoid allocating `AnimatedStyle` (and `AnimatedTransform`, `AnimatedObject`) unless necessary.

This not only reduces memory and traversal overhead, but it enables us to implement allowlist strategies to prune unnecessary traversals.

Changelog:
[General][Changed] - Animated now omits `style` if the supplied value is null, undefined, or not an object. Previously, it would emit an empty `style` object.
[General][Changed] - Animated now resolves `style` to the original prop value if it contains no `AnimatedNode` instances. Previously, it would resolve to a flattened style object.

Reviewed By: javache

Differential Revision: D62117423
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in ca234ba.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Sep 10, 2024
@yungsters yungsters deleted the export-D62117423 branch March 13, 2025 16:09
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.

2 participants