Skip to content

Commit d45c041

Browse files
Jiawei Lüfacebook-github-bot
authored andcommitted
Revert D73922341: Report PerformanceResourceTiming events
Differential Revision: D73922341 Original commit changeset: bcfc03c3d8a9 Original Phabricator Diff: D73922341 fbshipit-source-id: 3898ae763332b79f5a37fc91abb70be53c299655
1 parent e00028f commit d45c041

10 files changed

Lines changed: 21 additions & 183 deletions

File tree

packages/react-native/ReactCommon/jsinspector-modern/network/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ target_include_directories(jsinspector_network PUBLIC ${REACT_COMMON_DIR})
2424
target_link_libraries(jsinspector_network
2525
folly_runtime
2626
jsinspector_cdp
27-
react_performance_timeline
28-
react_timing)
27+
)

packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.cpp

Lines changed: 8 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <folly/dynamic.h>
1616
#include <jsinspector-modern/cdp/CdpJson.h>
1717
#endif
18-
#include <react/featureflags/ReactNativeFeatureFlags.h>
19-
#include <react/performance/timeline/PerformanceEntryReporter.h>
2018

2119
#ifdef REACT_NATIVE_DEBUGGER_ENABLED
2220
#include <chrono>
@@ -29,7 +27,7 @@ namespace facebook::react::jsinspector_modern {
2927
namespace {
3028

3129
/**
32-
* Get the current Unix timestamp in seconds (µs precision, CDP format).
30+
* Get the current Unix timestamp in seconds (µs precision).
3331
*/
3432
double getCurrentUnixTimestampSeconds() {
3533
auto now = std::chrono::system_clock::now().time_since_epoch();
@@ -76,23 +74,7 @@ void NetworkReporter::reportRequestStart(
7674
const std::string& requestId,
7775
const RequestInfo& requestInfo,
7876
int encodedDataLength,
79-
const std::optional<ResponseInfo>& redirectResponse) {
80-
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
81-
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
82-
83-
// All builds: Annotate PerformanceResourceTiming metadata
84-
{
85-
std::lock_guard<std::mutex> lock(perfTimingsMutex_);
86-
perfTimingsBuffer_.emplace(
87-
requestId,
88-
ResourceTimingData{
89-
.url = requestInfo.url,
90-
.fetchStart = now,
91-
.requestStart = now,
92-
});
93-
}
94-
}
95-
77+
const std::optional<ResponseInfo>& redirectResponse) const {
9678
#ifdef REACT_NATIVE_DEBUGGER_ENABLED
9779
// Debug build: CDP event handling
9880
if (!isDebuggingEnabledNoSync()) {
@@ -125,20 +107,8 @@ void NetworkReporter::reportRequestStart(
125107
#endif
126108
}
127109

128-
void NetworkReporter::reportConnectionTiming(const std::string& requestId) {
129-
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
130-
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
131-
132-
// All builds: Annotate PerformanceResourceTiming metadata
133-
{
134-
std::lock_guard<std::mutex> lock(perfTimingsMutex_);
135-
auto it = perfTimingsBuffer_.find(requestId);
136-
if (it != perfTimingsBuffer_.end()) {
137-
it->second.connectStart = now;
138-
}
139-
}
140-
}
141-
110+
void NetworkReporter::reportConnectionTiming(
111+
const std::string& /*requestId*/) const {
142112
#ifdef REACT_NATIVE_DEBUGGER_ENABLED
143113
// Debug build: CDP event handling
144114
if (!isDebuggingEnabledNoSync()) {
@@ -166,21 +136,7 @@ void NetworkReporter::reportRequestFailed(
166136
void NetworkReporter::reportResponseStart(
167137
const std::string& requestId,
168138
const ResponseInfo& responseInfo,
169-
int encodedDataLength) {
170-
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
171-
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
172-
173-
// All builds: Annotate PerformanceResourceTiming metadata
174-
{
175-
std::lock_guard<std::mutex> lock(perfTimingsMutex_);
176-
auto it = perfTimingsBuffer_.find(requestId);
177-
if (it != perfTimingsBuffer_.end()) {
178-
it->second.responseStart = now;
179-
it->second.responseStatus = responseInfo.statusCode;
180-
}
181-
}
182-
}
183-
139+
int encodedDataLength) const {
184140
#ifdef REACT_NATIVE_DEBUGGER_ENABLED
185141
// Debug build: CDP event handling
186142
if (!isDebuggingEnabledNoSync()) {
@@ -203,21 +159,8 @@ void NetworkReporter::reportResponseStart(
203159
#endif
204160
}
205161

206-
void NetworkReporter::reportDataReceived(const std::string& requestId) {
207-
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
208-
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
209-
210-
// All builds: Annotate PerformanceResourceTiming metadata
211-
{
212-
std::lock_guard<std::mutex> lock(perfTimingsMutex_);
213-
auto it = perfTimingsBuffer_.find(requestId);
214-
if (it != perfTimingsBuffer_.end()) {
215-
it->second.connectEnd = now;
216-
it->second.responseStart = now;
217-
}
218-
}
219-
}
220-
162+
void NetworkReporter::reportDataReceived(
163+
const std::string& /*requestId*/) const {
221164
#ifdef REACT_NATIVE_DEBUGGER_ENABLED
222165
// Debug build: CDP event handling
223166
if (!isDebuggingEnabledNoSync()) {
@@ -231,30 +174,7 @@ void NetworkReporter::reportDataReceived(const std::string& requestId) {
231174

232175
void NetworkReporter::reportResponseEnd(
233176
const std::string& requestId,
234-
int encodedDataLength) {
235-
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
236-
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
237-
238-
// All builds: Report PerformanceResourceTiming event
239-
{
240-
std::lock_guard<std::mutex> lock(perfTimingsMutex_);
241-
auto it = perfTimingsBuffer_.find(requestId);
242-
if (it != perfTimingsBuffer_.end()) {
243-
auto& eventData = it->second;
244-
PerformanceEntryReporter::getInstance()->reportResourceTiming(
245-
eventData.url,
246-
eventData.fetchStart,
247-
eventData.requestStart,
248-
eventData.connectStart.value_or(now),
249-
eventData.connectEnd.value_or(now),
250-
eventData.responseStart.value_or(now),
251-
now,
252-
eventData.responseStatus);
253-
perfTimingsBuffer_.erase(requestId);
254-
}
255-
}
256-
}
257-
177+
int encodedDataLength) const {
258178
#ifdef REACT_NATIVE_DEBUGGER_ENABLED
259179
// Debug build: CDP event handling
260180
if (!isDebuggingEnabledNoSync()) {

packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.h

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99

1010
#include "NetworkTypes.h"
1111

12-
#include <react/timing/primitives.h>
13-
1412
#include <atomic>
1513
#include <functional>
16-
#include <mutex>
1714
#include <string>
1815

1916
namespace facebook::react::jsinspector_modern {
@@ -25,24 +22,6 @@ namespace facebook::react::jsinspector_modern {
2522
*/
2623
using FrontendChannel = std::function<void(std::string_view messageJson)>;
2724

28-
/**
29-
* Container for static network event metadata aligning with the
30-
* `PerformanceResourceTiming` interface.
31-
*
32-
* This is a lightweight type stored in `perfTimingsBuffer_` and used for
33-
* reporting complete events to the Web Performance subsystem. Not used for CDP
34-
* reporting.
35-
*/
36-
struct ResourceTimingData {
37-
std::string url;
38-
DOMHighResTimeStamp fetchStart;
39-
DOMHighResTimeStamp requestStart;
40-
std::optional<DOMHighResTimeStamp> connectStart;
41-
std::optional<DOMHighResTimeStamp> connectEnd;
42-
std::optional<DOMHighResTimeStamp> responseStart;
43-
std::optional<int> responseStatus;
44-
};
45-
4625
/**
4726
* [Experimental] An interface for reporting network events to the modern
4827
* debugger server and Web Performance APIs.
@@ -88,7 +67,7 @@ class NetworkReporter {
8867
const std::string& requestId,
8968
const RequestInfo& requestInfo,
9069
int encodedDataLength,
91-
const std::optional<ResponseInfo>& redirectResponse);
70+
const std::optional<ResponseInfo>& redirectResponse) const;
9271

9372
/**
9473
* Report detailed timing info, such as DNS lookup, when a request has
@@ -100,7 +79,7 @@ class NetworkReporter {
10079
*
10180
* https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-connectstart
10281
*/
103-
void reportConnectionTiming(const std::string& requestId);
82+
void reportConnectionTiming(const std::string& requestId) const;
10483

10584
/**
10685
* Report when a network request has failed.
@@ -121,14 +100,14 @@ class NetworkReporter {
121100
void reportResponseStart(
122101
const std::string& requestId,
123102
const ResponseInfo& responseInfo,
124-
int encodedDataLength);
103+
int encodedDataLength) const;
125104

126105
/**
127106
* Report when additional chunks of the response body have been received.
128107
*
129108
* Corresponds to `Network.dataReceived` in CDP.
130109
*/
131-
void reportDataReceived(const std::string& requestId);
110+
void reportDataReceived(const std::string& requestId) const;
132111

133112
/**
134113
* Report when a network request is complete and we are no longer receiving
@@ -139,7 +118,8 @@ class NetworkReporter {
139118
*
140119
* https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-responseend
141120
*/
142-
void reportResponseEnd(const std::string& requestId, int encodedDataLength);
121+
void reportResponseEnd(const std::string& requestId, int encodedDataLength)
122+
const;
143123

144124
private:
145125
FrontendChannel frontendChannel_;
@@ -154,9 +134,6 @@ class NetworkReporter {
154134
inline bool isDebuggingEnabledNoSync() const {
155135
return debuggingEnabled_.load(std::memory_order_relaxed);
156136
}
157-
158-
std::unordered_map<std::string, ResourceTimingData> perfTimingsBuffer_{};
159-
std::mutex perfTimingsMutex_;
160137
};
161138

162139
} // namespace facebook::react::jsinspector_modern

packages/react-native/ReactCommon/jsinspector-modern/network/React-jsinspectornetwork.podspec

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ Pod::Spec.new do |s|
4747
end
4848

4949
add_dependency(s, "React-jsinspectorcdp", :framework_name => 'jsinspector_moderncdp')
50-
add_dependency(s, "React-featureflags")
51-
s.dependency "React-performancetimeline"
52-
s.dependency "React-timing"
5350

5451
add_rn_third_party_dependencies(s)
5552
end

packages/react-native/ReactCommon/react/performance/timeline/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ target_include_directories(react_performance_timeline PUBLIC ${REACT_COMMON_DIR}
1818
target_link_libraries(react_performance_timeline
1919
jsinspector_tracing
2020
reactperflogger
21-
react_featureflags
2221
react_timing)

packages/react-native/ReactCommon/react/performance/timeline/PerformanceEntry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ struct PerformanceResourceTiming : AbstractPerformanceEntry {
5757
static constexpr PerformanceEntryType entryType =
5858
PerformanceEntryType::RESOURCE;
5959
/** Aligns with `startTime`. */
60-
DOMHighResTimeStamp fetchStart;
61-
DOMHighResTimeStamp requestStart;
60+
std::optional<DOMHighResTimeStamp> fetchStart;
61+
std::optional<DOMHighResTimeStamp> requestStart;
6262
std::optional<DOMHighResTimeStamp> connectStart;
6363
std::optional<DOMHighResTimeStamp> connectEnd;
6464
std::optional<DOMHighResTimeStamp> responseStart;

packages/react-native/ReactCommon/react/performance/timeline/PerformanceEntryReporter.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ std::vector<PerformanceEntryType> getSupportedEntryTypesInternal() {
3030
PerformanceEntryType::LONGTASK,
3131
};
3232

33-
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
34-
supportedEntryTypes.emplace_back(PerformanceEntryType::RESOURCE);
35-
}
36-
3733
return supportedEntryTypes;
3834
}
3935

@@ -293,37 +289,6 @@ void PerformanceEntryReporter::reportLongTask(
293289
observerRegistry_->queuePerformanceEntry(entry);
294290
}
295291

296-
PerformanceResourceTiming PerformanceEntryReporter::reportResourceTiming(
297-
const std::string& url,
298-
DOMHighResTimeStamp fetchStart,
299-
DOMHighResTimeStamp requestStart,
300-
std::optional<DOMHighResTimeStamp> connectStart,
301-
std::optional<DOMHighResTimeStamp> connectEnd,
302-
DOMHighResTimeStamp responseStart,
303-
DOMHighResTimeStamp responseEnd,
304-
const std::optional<int>& responseStatus) {
305-
const auto entry = PerformanceResourceTiming{
306-
{.name = url, .startTime = fetchStart},
307-
fetchStart,
308-
requestStart,
309-
connectStart,
310-
connectEnd,
311-
responseStart,
312-
responseEnd,
313-
responseStatus,
314-
};
315-
316-
// Add to buffers & notify observers
317-
{
318-
std::unique_lock lock(buffersMutex_);
319-
resourceTimingBuffer_.add(entry);
320-
}
321-
322-
observerRegistry_->queuePerformanceEntry(entry);
323-
324-
return entry;
325-
}
326-
327292
void PerformanceEntryReporter::traceMark(const PerformanceMark& entry) const {
328293
auto& performanceTracer =
329294
jsinspector_modern::PerformanceTracer::getInstance();

packages/react-native/ReactCommon/react/performance/timeline/PerformanceEntryReporter.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@
2121

2222
namespace facebook::react {
2323

24-
// Aligned with maxBufferSize implemented by browsers
25-
// https://w3c.github.io/timing-entrytypes-registry/#registry
2624
constexpr size_t EVENT_BUFFER_SIZE = 150;
2725
constexpr size_t LONG_TASK_BUFFER_SIZE = 200;
28-
constexpr size_t RESOURCE_TIMING_BUFFER_SIZE = 250;
2926

3027
constexpr DOMHighResTimeStamp LONG_TASK_DURATION_THRESHOLD_MS = 50.0;
3128

@@ -104,26 +101,15 @@ class PerformanceEntryReporter {
104101

105102
void reportLongTask(double startTime, double duration);
106103

107-
PerformanceResourceTiming reportResourceTiming(
108-
const std::string& url,
109-
DOMHighResTimeStamp fetchStart,
110-
DOMHighResTimeStamp requestStart,
111-
std::optional<DOMHighResTimeStamp> connectStart,
112-
std::optional<DOMHighResTimeStamp> connectEnd,
113-
DOMHighResTimeStamp responseStart,
114-
DOMHighResTimeStamp responseEnd,
115-
const std::optional<int>& responseStatus);
116-
117104
private:
118105
std::unique_ptr<PerformanceObserverRegistry> observerRegistry_;
119106

120107
mutable std::shared_mutex buffersMutex_;
121108
PerformanceEntryCircularBuffer eventBuffer_{EVENT_BUFFER_SIZE};
122109
PerformanceEntryCircularBuffer longTaskBuffer_{LONG_TASK_BUFFER_SIZE};
123-
PerformanceEntryCircularBuffer resourceTimingBuffer_{
124-
RESOURCE_TIMING_BUFFER_SIZE};
125110
PerformanceEntryKeyedBuffer markBuffer_;
126111
PerformanceEntryKeyedBuffer measureBuffer_;
112+
PerformanceEntryKeyedBuffer resourceBuffer_;
127113

128114
std::unordered_map<std::string, uint32_t> eventCounts_;
129115

@@ -143,7 +129,7 @@ class PerformanceEntryReporter {
143129
case PerformanceEntryType::LONGTASK:
144130
return longTaskBuffer_;
145131
case PerformanceEntryType::RESOURCE:
146-
return resourceTimingBuffer_;
132+
return resourceBuffer_;
147133
case PerformanceEntryType::_NEXT:
148134
throw std::logic_error("Cannot get buffer for _NEXT entry type");
149135
}
@@ -161,7 +147,7 @@ class PerformanceEntryReporter {
161147
case PerformanceEntryType::LONGTASK:
162148
return longTaskBuffer_;
163149
case PerformanceEntryType::RESOURCE:
164-
return resourceTimingBuffer_;
150+
return resourceBuffer_;
165151
case PerformanceEntryType::_NEXT:
166152
throw std::logic_error("Cannot get buffer for _NEXT entry type");
167153
}

packages/react-native/src/private/webapis/performance/internals/RawPerformanceEntry.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ export function rawToPerformanceEntryType(
7777
return 'event';
7878
case RawPerformanceEntryTypeValues.LONGTASK:
7979
return 'longtask';
80-
case RawPerformanceEntryTypeValues.RESOURCE:
81-
return 'resource';
8280
default:
8381
throw new TypeError(
8482
`rawToPerformanceEntryType: unexpected performance entry type received: ${type}`,

0 commit comments

Comments
 (0)