Skip to content

Commit 7d85522

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Perform AnimationEndSync commits on the React revision (#57493)
Summary: Pull Request resolved: #57493 Changelog: [General][Fixed] Perform AnimationEndSync commits on the React revision ``` AB Merge UI thread -----------*----------*------------ JS thread ---*------------*------------------ React abFlush ``` In this scenario: - AB - Animation Backend update - React - React commit - Merge - Merge commit - abFlush - Animation Backend [flush](https://www.internalfb.com/code/fbsource/[aecb908843884d2fe57e866611a468e47b36518b]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/animationbackend/AnimationBackend.cpp?lines=242-268) 1. React revision captures the currently mounted main revision and applies the update on top of it. The result becomes the new `reactRevision`. 2. Animation Backend performs updates on the mounted tree, and requests a flush 3. The flush runs on the JS thread, clearing the `animatedPropsRegistry` 4. Merge commit runs, mounting the `reactRevision` and effectively dropping the updates. This diff changes the flush to happen on the react revision instead, preventing this from happening. Reviewed By: zeyap Differential Revision: D111219420 fbshipit-source-id: 6494e8347c1cc6d45ad8cb2f7ad88c6ab076b0e3
1 parent a016e94 commit 7d85522

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ CommitStatus ShadowTree::tryCommit(
347347
getShadowTreeCommitSourceName(commitOptions.source));
348348

349349
auto isReactBranch = ReactNativeFeatureFlags::enableFabricCommitBranching() &&
350-
commitOptions.source == CommitSource::React;
350+
(commitOptions.source == CommitSource::React ||
351+
commitOptions.source == CommitSource::AnimationEndSync);
351352

352353
// Commits on the JS branch are never synchronous.
353354
react_native_assert(!isReactBranch || !commitOptions.mountSynchronously);

packages/react-native/ReactCommon/react/renderer/mounting/updateMountedFlag.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ void updateMountedFlag(
3838
// Runtime shadow node references are updated during the React revision
3939
// commits so that JS can access layout data from the merged tree.
4040
bool shouldUpdateRuntimeReference =
41-
(commitSource == ShadowTreeCommitSource::React &&
41+
((commitSource == ShadowTreeCommitSource::React ||
42+
commitSource == ShadowTreeCommitSource::AnimationEndSync) &&
4243
ReactNativeFeatureFlags::updateRuntimeShadowNodeReferencesOnCommit()) ||
4344
(ReactNativeFeatureFlags::
4445
updateRuntimeShadowNodeReferencesOnCommitThread() &&

0 commit comments

Comments
 (0)