Fewer calls to direct manipulation callback (#52296)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52296

## Changelog:

[Internal] [Changed] - Fewer calls to direct manipulation callback

`NativeAnimatedNodesManager::onRender` is supposed to run each frame for c++ animation, from the callstack sample trace, the vast majority of time is spent on `updateNodes` (run update on all AnimatedNodes) and `commitProps` (where either Fabric ShadowTree commit or direct manipulation is called). Change in this PR is supposed to reduce time spent in `commitProps`

{F1979788964}

Reviewed By: sammy-SC

Differential Revision: D77380842

fbshipit-source-id: 2f25ca1fba4171a7b3e485298738379d0daff3ad
This commit is contained in:
Zeya Peng
2025-06-26 14:17:27 -07:00
committed by Facebook GitHub Bot
parent ffd6e5537d
commit 793023a4e2
@@ -743,6 +743,9 @@ void NativeAnimatedNodesManager::schedulePropsCommit(
(layoutStyleUpdated || forceFabricCommit ||
directManipulationCallback_ == nullptr)) {
mergeObjects(updateViewProps_[viewTag], props);
// Must call direct manipulation to set final values on components.
mergeObjects(updateViewPropsDirect_[viewTag], props);
} else if (directManipulationCallback_ != nullptr) {
mergeObjects(updateViewPropsDirect_[viewTag], props);
}
@@ -811,12 +814,6 @@ bool NativeAnimatedNodesManager::commitProps() {
if (fabricCommitCallback_ != nullptr) {
if (!updateViewProps_.empty()) {
// Must call direct manipulation to set final values on components.
if (directManipulationCallback_ != nullptr) {
for (const auto& [viewTag, props] : updateViewProps_) {
directManipulationCallback_(viewTag, folly::dynamic(props));
}
}
fabricCommitCallback_(updateViewProps_);
updateViewProps_.clear();
}