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

Call __makeNative on children before __getNativeTag #46524

Closed
wants to merge 1 commit into from

Conversation

rozele
Copy link
Contributor

@rozele rozele commented Sep 16, 2024

Summary:
There's an interesting behavior in Animated where we effectively perform an O(N + M) traversal of the Animated graph, calling __makeNative on each "input", which in turn tends to call __makeNative on each "output" (so we revisit the current node M times when calling __makeNative on the M inputs). In practice, the behavior is still O(N), because M is small and finite (most Animated nodes have 1 or 2 inputs).

All that said, some platforms (e.g., react-native-windows) rely on this revisiting behavior, where on the first visit, we recurse the node to its inputs, and on the subsequent visit, we update the _platformConfig value without recursion (see #32736 for the original change adding platformConfig).

A recent change to AnimatedWithChildren (#46286) eagerly invokes __getNativeTag on AnimatedWithChildren in the initial recursion step, which forces materialization of the NativeAnimated node before it's _platformConfig is set.

There is certainly some refactoring that needs to be done to improve all this, but for now, this change reverts to delay the call to __getNativeTag until after at least one __makeNative occurs on an input.

Differential Revision: D62768179

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

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

Summary:
Pull Request resolved: facebook#46524

There's an interesting behavior in Animated where we effectively perform an O(N + M) traversal of the Animated graph, calling `__makeNative` on each "input", which in turn tends to call `__makeNative` on each "output" (so we revisit the current node M times when calling `__makeNative` on the M inputs). In practice, the behavior is still O(N), because M is small and finite (most Animated nodes have 1 or 2 inputs).

All that said, some platforms (e.g., react-native-windows) rely on this revisiting behavior, where on the first visit, we recurse the node to its inputs, and on the subsequent visit, we update the `_platformConfig` value without recursion (see facebook#32736 for the original change adding platformConfig).

A recent change to AnimatedWithChildren (facebook#46286) eagerly invokes `__getNativeTag` on AnimatedWithChildren in the initial recursion step, which forces materialization of the NativeAnimated node *before* it's `_platformConfig` is set.

There is certainly some refactoring that needs to be done to improve all this, but for now, this change reverts to delay the call to `__getNativeTag` until after at least one `__makeNative` occurs on an input.

## Changelog

[General][Fixed]: Order of operations related to platformConfig propagation in NativeAnimated

Reviewed By: yungsters

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

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in a64183b.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @rozele in a64183b

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