Skip to content

Commit eeb9d1e

Browse files
coadofacebook-github-bot
authored andcommitted
Stop framework headers from exposing private performance APIs (#58011)
Summary: Move private performance includes out of framework-facing scheduler headers and into their implementation files. Store the conditional CDP reporters behind unique pointers so their declarations can remain private implementation details. Changelog: [Internal] Reviewed By: javache Differential Revision: D116621742
1 parent 26f7074 commit eeb9d1e

5 files changed

Lines changed: 19 additions & 9 deletions

File tree

packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <ReactCommon/RuntimeExecutor.h>
1111
#include <jsi/hermes-interfaces.h>
12-
#include <react/performance/timeline/PerformanceEntryReporter.h>
1312
#include <react/renderer/consistency/ShadowTreeRevisionConsistencyManager.h>
1413
#include <react/renderer/runtimescheduler/SchedulerPriorityUtils.h>
1514
#include <react/renderer/runtimescheduler/Task.h>
@@ -20,6 +19,8 @@
2019

2120
namespace facebook::react {
2221

22+
class PerformanceEntryReporter;
23+
2324
using RuntimeSchedulerRenderingUpdate = std::function<void()>;
2425
using SurfaceId = int32_t;
2526

packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <cxxreact/TraceSection.h>
1212
#include <jsinspector-modern/tracing/EventLoopReporter.h>
1313
#include <react/featureflags/ReactNativeFeatureFlags.h>
14+
#include <react/performance/timeline/PerformanceEntryReporter.h>
1415
#include <react/renderer/consistency/ScopedShadowTreeRevisionLock.h>
1516
#include <react/timing/primitives.h>
1617
#include <react/utils/OnScopeExit.h>

packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
#include <cxxreact/TraceSection.h>
1414
#include <react/debug/react_native_assert.h>
1515
#include <react/featureflags/ReactNativeFeatureFlags.h>
16+
#include <react/performance/cdpmetrics/CdpMetricsReporter.h>
17+
#include <react/performance/cdpmetrics/CdpPerfIssuesReporter.h>
18+
#include <react/performance/timeline/PerformanceEntryReporter.h>
1619
#include <react/renderer/animationbackend/AnimationBackend.h>
1720
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
1821
#include <react/renderer/core/EventQueueProcessor.h>
1922
#include <react/renderer/core/LayoutContext.h>
2023
#include <react/renderer/mounting/MountingOverrideDelegate.h>
2124
#include <react/renderer/mounting/ShadowViewMutation.h>
25+
#include <react/renderer/observers/events/EventPerformanceLogger.h>
2226
#include <react/renderer/runtimescheduler/RuntimeScheduler.h>
2327
#include <react/renderer/uimanager/LayoutEventEmitter.h>
2428
#include <react/renderer/uimanager/UIManager.h>
@@ -44,12 +48,14 @@ Scheduler::Scheduler(
4448

4549
if (ReactNativeFeatureFlags::enableBridgelessArchitecture() &&
4650
ReactNativeFeatureFlags::cdpInteractionMetricsEnabled()) {
47-
cdpMetricsReporter_.emplace(CdpMetricsReporter{runtimeExecutor_});
51+
cdpMetricsReporter_ =
52+
std::make_unique<CdpMetricsReporter>(runtimeExecutor_);
4853
performanceEntryReporter_->addEventListener(&*cdpMetricsReporter_);
4954
}
5055

5156
if (ReactNativeFeatureFlags::perfIssuesEnabled()) {
52-
cdpPerfIssuesReporter_.emplace(CdpPerfIssuesReporter{runtimeExecutor_});
57+
cdpPerfIssuesReporter_ =
58+
std::make_unique<CdpPerfIssuesReporter>(runtimeExecutor_);
5359
performanceEntryReporter_->addEventListener(&*cdpPerfIssuesReporter_);
5460
}
5561

packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@
1212
#include <vector>
1313

1414
#include <ReactCommon/RuntimeExecutor.h>
15-
#include <react/performance/cdpmetrics/CdpMetricsReporter.h>
16-
#include <react/performance/cdpmetrics/CdpPerfIssuesReporter.h>
17-
#include <react/performance/timeline/PerformanceEntryReporter.h>
1815
#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
1916
#include <react/renderer/core/ComponentDescriptor.h>
2017
#include <react/renderer/core/EventEmitter.h>
2118
#include <react/renderer/core/EventListener.h>
2219
#include <react/renderer/core/LayoutConstraints.h>
2320
#include <react/renderer/mounting/MountingOverrideDelegate.h>
24-
#include <react/renderer/observers/events/EventPerformanceLogger.h>
2521
#include <react/renderer/scheduler/InspectorData.h>
2622
#include <react/renderer/scheduler/SchedulerDelegate.h>
2723
#include <react/renderer/scheduler/SchedulerToolbox.h>
@@ -34,6 +30,11 @@
3430

3531
namespace facebook::react {
3632

33+
class CdpMetricsReporter;
34+
class CdpPerfIssuesReporter;
35+
class EventPerformanceLogger;
36+
class PerformanceEntryReporter;
37+
3738
/*
3839
* Scheduler coordinates Shadow Tree updates and event flows.
3940
*/
@@ -145,8 +146,8 @@ class Scheduler final : public UIManagerDelegate {
145146
std::shared_ptr<std::optional<const EventDispatcher>> eventDispatcher_;
146147

147148
std::shared_ptr<PerformanceEntryReporter> performanceEntryReporter_;
148-
std::optional<CdpMetricsReporter> cdpMetricsReporter_;
149-
std::optional<CdpPerfIssuesReporter> cdpPerfIssuesReporter_;
149+
std::unique_ptr<CdpMetricsReporter> cdpMetricsReporter_;
150+
std::unique_ptr<CdpPerfIssuesReporter> cdpPerfIssuesReporter_;
150151
std::shared_ptr<EventPerformanceLogger> eventPerformanceLogger_;
151152

152153
/**

packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <jsi/instrumentation.h>
1919
#include <jsinspector-modern/HostTarget.h>
2020
#include <react/featureflags/ReactNativeFeatureFlags.h>
21+
#include <react/performance/timeline/PerformanceEntryReporter.h>
2122
#include <react/renderer/runtimescheduler/RuntimeSchedulerBinding.h>
2223
#include <react/runtime/JSRuntimeBindings.h>
2324
#include <react/timing/primitives.h>

0 commit comments

Comments
 (0)