Skip to content

Commit 77d3df8

Browse files
Bartlomiej Bloniarzmeta-codesync[bot]
authored andcommitted
Avoid moving RawProps during animation backend commit when retries are possible (#56465)
Summary: Pull Request resolved: #56465 The `cloneProps` function in `AnimationBackend.cpp` was using `std::move(*animatedProps.rawProps)` inside a `shadowTree.commit()` transaction lambda. Since commits can be retried (when `currentRevision_.number != oldRevision.number`), the moved-from `RawProps` would be in an unspecified state on the second attempt, leading to incorrect or undefined behavior. When `enableFabricCommitBranching` is enabled, commit retries are not a concern, so moving is safe. When disabled, we now copy via `RawProps(*animatedProps.rawProps)` instead. This is the only dangerous move in the animation backend commit path. The `AnimationBackendCommitHook` already copies correctly (`RawProps(*snapshot->rawProps)`), and `AnimatedPropsRegistry::getMap()` is safe because moved pending data persists in the `map` member across retries. Changelog: [General][Fixed] - Fix potential data corruption in animation backend when ShadowTree commits are retried by copying RawProps instead of moving them Reviewed By: zeyap Differential Revision: D101161363 fbshipit-source-id: 43b9277f37563098c8ba878777d7a3099bdf1373
1 parent 4a6c933 commit 77d3df8

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

packages/react-native/ReactCommon/react/renderer/animationbackend/AnimationBackend.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ static inline Props::Shared cloneProps(
2424
shadowNode.getSurfaceId(), *shadowNode.getContextContainer()};
2525
Props::Shared newProps;
2626
if (animatedProps.rawProps) {
27-
newProps = shadowNode.getComponentDescriptor().cloneProps(
28-
propsParserContext,
29-
shadowNode.getProps(),
30-
std::move(*animatedProps.rawProps));
27+
if (ReactNativeFeatureFlags::enableFabricCommitBranching()) {
28+
newProps = shadowNode.getComponentDescriptor().cloneProps(
29+
propsParserContext,
30+
shadowNode.getProps(),
31+
std::move(*animatedProps.rawProps));
32+
} else {
33+
newProps = shadowNode.getComponentDescriptor().cloneProps(
34+
propsParserContext,
35+
shadowNode.getProps(),
36+
RawProps(*animatedProps.rawProps));
37+
}
3138
} else {
3239
newProps = shadowNode.getComponentDescriptor().cloneProps(
3340
propsParserContext, shadowNode.getProps(), {});

0 commit comments

Comments
 (0)