Skip to content

Commit aabc972

Browse files
zeyapfacebook-github-bot
authored andcommitted
Add trace markers in ViewTransitionModule (facebook#56997)
Summary: ## Changelog: [Internal] [Changed] - Add trace markers in ViewTransitionModule Reviewed By: rubennorte Differential Revision: D105214325
1 parent 56fb40f commit aabc972

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

packages/react-native/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "ViewTransitionModule.h"
99

10+
#include <cxxreact/TraceSection.h>
1011
#include <glog/logging.h>
1112
#include <react/renderer/components/root/RootShadowNode.h>
1213
#include <react/renderer/core/LayoutableShadowNode.h>
@@ -72,6 +73,7 @@ void ViewTransitionModule::applyViewTransitionName(
7273
const ShadowNode& shadowNode,
7374
const std::string& name,
7475
const std::string& /*className*/) {
76+
TraceSection s("ViewTransitionModule::applyViewTransitionName", "name", name);
7577
auto tag = shadowNode.getTag();
7678
auto surfaceId = shadowNode.getSurfaceId();
7779

@@ -109,6 +111,10 @@ void ViewTransitionModule::applyViewTransitionName(
109111
if (uiManager_ != nullptr) {
110112
auto* delegate = uiManager_->getDelegate();
111113
if (delegate != nullptr) {
114+
TraceSection snapshotSection(
115+
"ViewTransitionModule::applyViewTransitionName - uiManagerDidCaptureViewSnapshot",
116+
"name",
117+
name);
112118
delegate->uiManagerDidCaptureViewSnapshot(tag, surfaceId);
113119
}
114120
}
@@ -119,6 +125,11 @@ void ViewTransitionModule::applyViewTransitionName(
119125
auto& pseudoElementsBySourceTag = it->second;
120126
auto innerIt = pseudoElementsBySourceTag.find(tag);
121127

128+
TraceSection clonePseudoElementSection(
129+
"ViewTransitionModule::applyViewTransitionName - maybeClonePseudoElement",
130+
"name",
131+
name);
132+
122133
if (innerIt != pseudoElementsBySourceTag.end()) {
123134
// Only clone the pseudo-element if the layout metrics changed
124135
// since it was last created/refreshed (e.g. due to scrolling or
@@ -166,6 +177,8 @@ void ViewTransitionModule::applyViewTransitionName(
166177
void ViewTransitionModule::createViewTransitionInstance(
167178
const std::string& name,
168179
Tag pseudoElementTag) {
180+
TraceSection s(
181+
"ViewTransitionModule::createViewTransitionInstance", "name", name);
169182
if (uiManager_ == nullptr) {
170183
return;
171184
}
@@ -220,6 +233,7 @@ RootShadowNode::Unshared ViewTransitionModule::shadowTreeWillCommit(
220233
if (oldPseudoElementNodes_.empty()) {
221234
return newRootShadowNode;
222235
}
236+
TraceSection s("ViewTransitionModule::shadowTreeWillCommit");
223237

224238
auto surfaceId = shadowTree.getSurfaceId();
225239

@@ -333,6 +347,8 @@ void ViewTransitionModule::restoreViewTransitionName(
333347
}
334348

335349
void ViewTransitionModule::applySnapshotsOnPseudoElementShadowNodes() {
350+
TraceSection s(
351+
"ViewTransitionModule::applySnapshotsOnPseudoElementShadowNodes");
336352
if (oldPseudoElementNodes_.empty() || uiManager_ == nullptr) {
337353
return;
338354
}
@@ -353,6 +369,7 @@ void ViewTransitionModule::applySnapshotsOnPseudoElementShadowNodes() {
353369

354370
LayoutMetrics ViewTransitionModule::captureLayoutMetricsFromRoot(
355371
const ShadowNode& shadowNode) {
372+
TraceSection s("ViewTransitionModule::captureLayoutMetricsFromRoot");
356373
if (uiManager_ == nullptr) {
357374
return EmptyLayoutMetrics;
358375
}
@@ -399,6 +416,12 @@ void ViewTransitionModule::startViewTransition(
399416
// Mark transition as started
400417
transitionStarted_ = true;
401418
activeTransitionId_ = ++transitionIdCounter_;
419+
420+
TraceSection s(
421+
"ViewTransitionModule::startViewTransition",
422+
"transitionId",
423+
activeTransitionId_);
424+
402425
pendingAnimationIds_.clear();
403426
onCompleteCallback_ = onCompleteCallback;
404427

@@ -456,6 +479,10 @@ void ViewTransitionModule::suspendOnActiveViewTransition() {
456479
}
457480

458481
void ViewTransitionModule::startViewTransitionEnd() {
482+
TraceSection s(
483+
"ViewTransitionModule::startViewTransitionEnd",
484+
"transitionId",
485+
activeTransitionId_);
459486
auto finishedId = activeTransitionId_;
460487

461488
// Only clear layout and registry entries belonging to the finished

0 commit comments

Comments
 (0)