Skip to content

Commit 16ada9d

Browse files
JoshuaGrossfacebook-github-bot
authored andcommitted
Fix MountingCoordinator stub view tree printer
Summary: On Android/when printing to logcat, output is truncated to a certain max length; outputting a massive string as a single log item will cause some of it to be truncated. In the case of the mutations list and shadow node description, most of it is truncated. Easy fix: split into lines and log each line. This isn't necessary on iOS but works fine. I also removed the conditional and changed to an assert. Most of the time when we're using this block of code, it's because we want to see all mutations; and unless we reintroduce a bug into the core, the assert is never hit and so (before this change) the conditional would never be true and we'd never see this output. It's more generally useful to be able to see this output if the `RN_SHADOW_TREE_INTROSPECTION` macro is defined. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D19378929 fbshipit-source-id: 2f5dffeef7608823ac1ba092090d8c2ab5e965e1
1 parent 442dd26 commit 16ada9d

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

ReactCommon/fabric/mounting/MountingCoordinator.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#ifdef RN_SHADOW_TREE_INTROSPECTION
1111
#include <glog/logging.h>
12+
#include <sstream>
1213
#endif
1314

1415
#include <condition_variable>
@@ -89,20 +90,27 @@ better::optional<MountingTransaction> MountingCoordinator::pullTransaction()
8990
stubViewTree_.mutate(mutations);
9091
auto stubViewTree =
9192
stubViewTreeFromShadowNode(lastRevision_->getRootShadowNode());
92-
if (stubViewTree_ != stubViewTree) {
93-
LOG(ERROR) << "Old tree:"
94-
<< "\n"
95-
<< baseRevision_.getRootShadowNode().getDebugDescription()
96-
<< "\n";
97-
LOG(ERROR) << "New tree:"
98-
<< "\n"
99-
<< lastRevision_->getRootShadowNode().getDebugDescription()
100-
<< "\n";
101-
LOG(ERROR) << "Mutations:"
102-
<< "\n"
103-
<< getDebugDescription(mutations, {});
104-
assert(false);
93+
94+
std::string line;
95+
96+
std::stringstream ssOldTree(
97+
baseRevision_.getRootShadowNode().getDebugDescription());
98+
while (std::getline(ssOldTree, line, '\n')) {
99+
LOG(ERROR) << "Old tree:" << line;
100+
}
101+
102+
std::stringstream ssNewTree(
103+
lastRevision_->getRootShadowNode().getDebugDescription());
104+
while (std::getline(ssNewTree, line, '\n')) {
105+
LOG(ERROR) << "New tree:" << line;
105106
}
107+
108+
std::stringstream ssMutations(getDebugDescription(mutations, {}));
109+
while (std::getline(ssMutations, line, '\n')) {
110+
LOG(ERROR) << "Mutations:" << line;
111+
}
112+
113+
assert(stubViewTree_ == stubViewTree);
106114
#endif
107115

108116
baseRevision_ = std::move(*lastRevision_);

0 commit comments

Comments
 (0)