Skip to content

Commit 3a758d4

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Expose network throttling capability to frontend
Summary: Expose the simulated network throttling capability to the React Native DevTools frontend by adding an `unstable_networkThrottlingEnabled` boolean to the `ReactNativeApplication.metadataUpdated` CDP event payload. This mirrors the existing `unstable_networkInspectionEnabled`, `unstable_frameRecordingEnabled` etc fields, letting the frontend gate its throttling UI on whether the backend supports `Network.emulateNetworkConditions`. See also react/react-native-devtools-frontend#279. Changelog: [Internal] Differential Revision: D111725569
1 parent 8886704 commit 3a758d4

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/react-native/ReactCommon/jsinspector-modern/HostTarget.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ namespace {
328328
struct StaticHostTargetMetadata {
329329
std::optional<bool> isProfilingBuild;
330330
std::optional<bool> networkInspectionEnabled;
331+
std::optional<bool> networkThrottlingEnabled;
331332
std::optional<bool> frameRecordingEnabled;
332333
};
333334

@@ -337,6 +338,7 @@ StaticHostTargetMetadata getStaticHostMetadata() {
337338
return {
338339
.isProfilingBuild = inspectorFlags.getIsProfilingBuild(),
339340
.networkInspectionEnabled = true,
341+
.networkThrottlingEnabled = inspectorFlags.getNetworkThrottlingEnabled(),
340342
.frameRecordingEnabled = inspectorFlags.getFrameRecordingEnabled()};
341343
}
342344

@@ -372,6 +374,10 @@ folly::dynamic createHostMetadataPayload(const HostTargetMetadata& metadata) {
372374
result["unstable_networkInspectionEnabled"] =
373375
staticMetadata.networkInspectionEnabled.value();
374376
}
377+
if (staticMetadata.networkThrottlingEnabled) {
378+
result["unstable_networkThrottlingEnabled"] =
379+
staticMetadata.networkThrottlingEnabled.value();
380+
}
375381
if (staticMetadata.frameRecordingEnabled) {
376382
result["unstable_frameRecordingEnabled"] =
377383
staticMetadata.frameRecordingEnabled.value();

‎packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ TYPED_TEST(JsiIntegrationPortableTest, ReactNativeApplicationEnable) {
360360
"integrationName": "JsiIntegrationTest",
361361
"unstable_frameRecordingEnabled": false,
362362
"unstable_isProfilingBuild": false,
363-
"unstable_networkInspectionEnabled": true
363+
"unstable_networkInspectionEnabled": true,
364+
"unstable_networkThrottlingEnabled": false
364365
}
365366
})"));
366367

0 commit comments

Comments
 (0)