File tree Expand file tree Collapse file tree
packages/react-native/ReactCommon/jsinspector-modern Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,10 @@ void HostTargetTraceRecording::start() {
2929 hostTracingAgent_ == nullptr &&
3030 " Tracing Agent for the HostTarget was already initialized." );
3131
32- state_ = tracing::TraceRecordingState{.startTime = HighResTimeStamp::now ()};
32+ state_ = tracing::TraceRecordingState{
33+ .mode = tracingMode_,
34+ .startTime = HighResTimeStamp::now (),
35+ };
3336 hostTracingAgent_ = hostTarget_.createTracingAgent (*state_);
3437}
3538
Original file line number Diff line number Diff line change 1515
1616namespace facebook ::react::jsinspector_modern {
1717
18+ namespace {
19+
20+ // The size of the timeline for the trace recording that happened in the
21+ // background.
22+ constexpr HighResDuration kBackgroundTracePerformanceTracerWindowSize =
23+ HighResDuration::fromMilliseconds (20000 );
24+
25+ } // namespace
26+
1827InstanceAgent::InstanceAgent (
1928 FrontendChannel frontendChannel,
2029 InstanceTarget& target,
@@ -160,7 +169,12 @@ void InstanceAgent::maybeSendPendingConsoleMessages() {
160169
161170InstanceTracingAgent::InstanceTracingAgent (tracing::TraceRecordingState& state)
162171 : tracing::TargetTracingAgent(state) {
163- tracing::PerformanceTracer::getInstance ().startTracing ();
172+ auto & performanceTracer = tracing::PerformanceTracer::getInstance ();
173+ if (state.mode == tracing::Mode::Background) {
174+ performanceTracer.startTracing (kBackgroundTracePerformanceTracerWindowSize );
175+ } else {
176+ performanceTracer.startTracing ();
177+ }
164178}
165179
166180InstanceTracingAgent::~InstanceTracingAgent () {
Original file line number Diff line number Diff line change @@ -134,14 +134,18 @@ RuntimeTracingAgent::RuntimeTracingAgent(
134134 tracing::TraceRecordingState& state,
135135 RuntimeTargetController& targetController)
136136 : tracing::TargetTracingAgent(state), targetController_(targetController) {
137- targetController_.enableSamplingProfiler ();
137+ if (state.mode == tracing::Mode::CDP ) {
138+ targetController_.enableSamplingProfiler ();
139+ }
138140}
139141
140142RuntimeTracingAgent::~RuntimeTracingAgent () {
141- targetController_.disableSamplingProfiler ();
142- auto profile = targetController_.collectSamplingProfile ();
143+ if (state_.mode == tracing::Mode::CDP ) {
144+ targetController_.disableSamplingProfiler ();
145+ auto profile = targetController_.collectSamplingProfile ();
143146
144- state_.runtimeSamplingProfiles .emplace_back (std::move (profile));
147+ state_.runtimeSamplingProfiles .emplace_back (std::move (profile));
148+ }
145149}
146150
147151} // namespace facebook::react::jsinspector_modern
Original file line number Diff line number Diff line change 99
1010#include " InstanceTracingProfile.h"
1111#include " RuntimeSamplingProfile.h"
12+ #include " TracingMode.h"
1213
1314#include < oscompat/OSCompat.h>
1415#include < react/timing/primitives.h>
1819namespace facebook ::react::jsinspector_modern::tracing {
1920
2021struct TraceRecordingState {
22+ // The mode of this Trace Recording.
23+ tracing::Mode mode;
24+
2125 // The ID of the OS-level process that this Trace Recording is associated
2226 // with.
2327 ProcessId processId = oscompat::getCurrentProcessId();
You can’t perform that action at this time.
0 commit comments