Skip to content

Commit 597fe66

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
avoid excessive logs in C++ Animated (#52992)
Summary: Pull Request resolved: #52992 changelog: [internal] do not log on every frame to make logs more readable. The callbacks are only set during construction and there is no value in logging on every commit props. Reviewed By: rshest Differential Revision: D79436988 fbshipit-source-id: 26c6cbadd5ae0efa8575c7f85e4c0d90e2ef6215
1 parent 9c8a4c2 commit 597fe66

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,22 @@ NativeAnimatedNodesManager::NativeAnimatedNodesManager(
7171
: directManipulationCallback_(std::move(directManipulationCallback)),
7272
fabricCommitCallback_(std::move(fabricCommitCallback)),
7373
startOnRenderCallback_(std::move(startOnRenderCallback)),
74-
stopOnRenderCallback_(std::move(stopOnRenderCallback)) {}
74+
stopOnRenderCallback_(std::move(stopOnRenderCallback)) {
75+
if (!fabricCommitCallback_) {
76+
LOG(WARNING)
77+
<< "C++ Animated was setup without commit callback. This may lead to issue where buttons are not tappable when animation is driven by onScroll event.";
78+
}
79+
80+
if (!directManipulationCallback_) {
81+
LOG(WARNING)
82+
<< "C++ Animated was setup without direct manipulation callback. This may lead to suboptimal performance.";
83+
}
84+
85+
if (!directManipulationCallback_ && fabricCommitCallback_) {
86+
LOG(ERROR)
87+
<< "C++ Animated was setup without a way to update UI. Animations will not work.";
88+
}
89+
}
7590

7691
NativeAnimatedNodesManager::~NativeAnimatedNodesManager() noexcept {
7792
stopRenderCallbackIfNeeded();
@@ -876,23 +891,19 @@ bool NativeAnimatedNodesManager::commitProps() {
876891
if (fabricCommitCallback_ != nullptr) {
877892
if (!updateViewProps_.empty()) {
878893
fabricCommitCallback_(updateViewProps_);
879-
updateViewProps_.clear();
880894
}
881-
} else {
882-
LOG(ERROR)
883-
<< "Failed to commit native animation, since Fabric commit callback is not set";
884895
}
885896

897+
updateViewProps_.clear();
898+
886899
if (directManipulationCallback_ != nullptr) {
887900
for (const auto& [viewTag, props] : updateViewPropsDirect_) {
888901
directManipulationCallback_(viewTag, folly::dynamic(props));
889902
}
890-
updateViewPropsDirect_.clear();
891-
} else {
892-
LOG(ERROR)
893-
<< "Failed to commit native animation, since direct manipulation callback is not set";
894903
}
895904

905+
updateViewPropsDirect_.clear();
906+
896907
return containsChange;
897908
}
898909

0 commit comments

Comments
 (0)