Skip to content

Conversation

@rozele
Copy link
Contributor

@rozele rozele commented Dec 10, 2021

Summary:
The ability to pass an additional property bag to further configure NativeAnimated is useful for a few reasons, e.g., experimentation with multiple implementations of the NativeAnimated module.

The specific use case this solves is on react-native-windows, where there are two underlying animation graph options, one "optimized" animation graph that uses UI.Composition, and another similar to the approach to iOS and Android that uses a frame rendering callback.

The platform configuration can be supplied to the animation node when useNativeDriver is set to true, and we pass the platform configuration object to the connected AnimatedValue and all it's children.

Changelog:
[General][Added] - Option to supply platformConfig to NativeAnimated

Differential Revision: D32988285

@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 fb-exported labels Dec 10, 2021
@facebook-github-bot
Copy link
Contributor

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

@react-native-bot react-native-bot added the Type: Enhancement A new feature or enhancement of an existing feature. label Dec 10, 2021
@facebook-github-bot
Copy link
Contributor

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

1 similar comment
@facebook-github-bot
Copy link
Contributor

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

@analysis-bot
Copy link

analysis-bot commented Dec 14, 2021

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 5fa3807
Branch: main

@analysis-bot
Copy link

analysis-bot commented Dec 14, 2021

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,291,192 +334
android hermes armeabi-v7a 7,628,538 +327
android hermes x86 8,764,390 +332
android hermes x86_64 8,701,266 +340
android jsc arm64-v8a 9,678,350 +115
android jsc armeabi-v7a 8,672,393 +127
android jsc x86 9,637,053 +117
android jsc x86_64 10,231,523 +117

Base commit: 5fa3807
Branch: main

@facebook-github-bot
Copy link
Contributor

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

Summary:
Pull Request resolved: #32736

The ability to pass an additional property bag to further configure NativeAnimated is useful for a few reasons, e.g., experimentation with multiple implementations of the NativeAnimated module.

The specific use case this solves is on react-native-windows, where there are two underlying animation graph options, one "optimized" animation graph that uses UI.Composition, and another similar to the approach to iOS and Android that uses a frame rendering callback.

The platform configuration can be supplied to the animation node when `useNativeDriver` is set to `true`, and we pass the platform configuration object to the connected AnimatedValue and all it's children.

Changelog:
[General][Added] - Option to supply `platformConfig` to NativeAnimated

Reviewed By: yungsters

Differential Revision: D32988285

fbshipit-source-id: 9aa885e158bad4858237a804ccf8b556790d0e15
@facebook-github-bot
Copy link
Contributor

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

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @rozele in 4a227ce.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jan 20, 2022
rozele added a commit to rozele/react-native-macos that referenced this pull request 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 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.

Differential Revision: D62768179
rozele added a commit to rozele/react-native-macos that referenced this pull request Sep 16, 2024
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 pushed a commit that referenced this pull request Sep 16, 2024
Summary:
Pull Request resolved: #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 #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.

## Changelog

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

Reviewed By: yungsters

Differential Revision: D62768179

fbshipit-source-id: ca9d911503e0630bc3a1309b21f9686aa77ac8b9
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 Type: Enhancement A new feature or enhancement of an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants