Skip to content

Commit a64183b

Browse files
rozelefacebook-github-bot
authored andcommitted
Call __makeNative on children before __getNativeTag (facebook#46524)
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 fbshipit-source-id: ca9d911503e0630bc3a1309b21f9686aa77ac8b9
1 parent 7aeff18 commit a64183b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

packages/react-native/Libraries/Animated/nodes/AnimatedWithChildren.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ export default class AnimatedWithChildren extends AnimatedNode {
2828
const children = this._children;
2929
let length = children.length;
3030
if (length > 0) {
31-
const nativeTag = this.__getNativeTag();
32-
3331
for (let ii = 0; ii < length; ii++) {
3432
const child = children[ii];
3533
child.__makeNative(platformConfig);
36-
connectAnimatedNodes(nativeTag, child.__getNativeTag());
34+
connectAnimatedNodes(this.__getNativeTag(), child.__getNativeTag());
3735
}
3836
}
3937
}

0 commit comments

Comments
 (0)