Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions front_end/core/rn_experiments/experimentsImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,9 @@ Instance.register({
title: 'Enable performance frames track',
unstable: true,
});

Instance.register({
name: RNExperimentName.ENABLE_NETWORK_THROTTLING,
title: 'Enable network throttling (Network panel)',
unstable: true,
});
2 changes: 2 additions & 0 deletions front_end/core/root/Runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ export enum RNExperimentName {
REACT_NATIVE_SPECIFIC_UI = 'react-native-specific-ui',
JS_HEAP_PROFILER_ENABLE = 'js-heap-profiler-enable',
ENABLE_TIMELINE_FRAMES = 'enable-timeline-frames',
ENABLE_NETWORK_THROTTLING = 'enable-network-throttling',
}

export enum ConditionName {
Expand Down Expand Up @@ -341,6 +342,7 @@ export const enum ExperimentName {
REACT_NATIVE_SPECIFIC_UI = RNExperimentName.REACT_NATIVE_SPECIFIC_UI,
NOT_REACT_NATIVE_SPECIFIC_UI = '!' + RNExperimentName.REACT_NATIVE_SPECIFIC_UI,
ENABLE_TIMELINE_FRAMES = RNExperimentName.ENABLE_TIMELINE_FRAMES,
ENABLE_NETWORK_THROTTLING = RNExperimentName.ENABLE_NETWORK_THROTTLING,
}

export enum GenAiEnterprisePolicyValue {
Expand Down
21 changes: 20 additions & 1 deletion front_end/entrypoints/rn_fusebox/FuseboxFeatureObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ const UIStrings = {
* @description Title shown when a feature is unavailable due to multiple React Native hosts.
*/
multiHostFeatureUnavailableTitle: 'Feature is unavailable',
/**
* @description Message for the "settings changed" banner shown when a reload
* is required for response throttling in the Network panel.
*/
reloadRequiredForNetworkThrottlingMessage:
'Network throttling is now available in the Network panel. Please reload to enable.',
/**
* @description Message for the "settings changed" banner shown when a reload
* is required for frame timings in the Performance panel.
Expand Down Expand Up @@ -81,7 +87,8 @@ export class FuseboxFeatureObserver implements
#handleMetadataUpdated(
event: Common.EventTarget.EventTargetEvent<Protocol.ReactNativeApplication.MetadataUpdatedEvent>): void {
// eslint-disable-next-line @typescript-eslint/naming-convention
const {unstable_isProfilingBuild, unstable_networkInspectionEnabled, unstable_frameRecordingEnabled} = event.data;
const {unstable_isProfilingBuild, unstable_networkInspectionEnabled, unstable_frameRecordingEnabled, unstable_networkThrottlingEnabled} =
event.data;

if (unstable_isProfilingBuild) {
FuseboxWindowTitleManager.instance().setSuffix('[PROFILING]');
Expand All @@ -97,6 +104,10 @@ export class FuseboxFeatureObserver implements
if (unstable_frameRecordingEnabled) {
void this.#ensureTimelineFramesEnabled();
}

if (unstable_networkThrottlingEnabled) {
void this.#ensureNetworkThrottlingEnabled();
}
}

#handleSystemStateChanged(
Expand Down Expand Up @@ -150,6 +161,14 @@ export class FuseboxFeatureObserver implements
}
}

async #ensureNetworkThrottlingEnabled(): Promise<void> {
if (!Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_NETWORK_THROTTLING)) {
Root.Runtime.experiments.setEnabled(Root.Runtime.RNExperimentName.ENABLE_NETWORK_THROTTLING, true);
UI.InspectorView?.InspectorView?.instance()?.displayReloadRequiredWarning(
i18nString(UIStrings.reloadRequiredForNetworkThrottlingMessage));
}
}

#disableSingleHostOnlyFeatures(): void {
if (this.#singleHostFeaturesDisabled) {
return;
Expand Down
2 changes: 1 addition & 1 deletion front_end/generated/InspectorBackendCommands.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions front_end/generated/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ export namespace ReactNativeApplication {
*/
unstable_networkInspectionEnabled?: boolean;
/**
* Whether Frame Timings and screenshots are supported in performance
* traces.
* Whether Frame Timings and screenshots are supported in performance traces.
*/
unstable_frameRecordingEnabled?: boolean;
/**
* Whether network throttling is supported in the Network panel.
*/
unstable_networkThrottlingEnabled?: boolean;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions front_end/panels/network/NetworkPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ export class NetworkPanel extends UI.Panel.Panel implements
void UI.ViewManager.ViewManager.instance().showView('network.config');
}, this);
this.panelToolbar.appendToolbarItem(networkConditionsButton);
} else if (Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_NETWORK_THROTTLING)) {
// [RN] Expose the network throttling selector when enabled by the backend.
this.panelToolbar.appendSeparator();
this.panelToolbar.appendToolbarItem(this.throttlingSelect);
}

this.rightToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.progressBarContainer));
Expand Down
1 change: 1 addition & 0 deletions front_end/testing/EnvironmentHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const REGISTERED_EXPERIMENTS = [
Root.Runtime.ExperimentName.REACT_NATIVE_SPECIFIC_UI,
Root.Runtime.ExperimentName.NOT_REACT_NATIVE_SPECIFIC_UI,
Root.Runtime.ExperimentName.ENABLE_TIMELINE_FRAMES,
Root.Runtime.ExperimentName.ENABLE_NETWORK_THROTTLING,
];

export async function initializeGlobalVars({reset = true} = {}) {
Expand Down
10 changes: 8 additions & 2 deletions third_party/blink/public/devtools_protocol/browser_protocol.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
"description": "Whether Frame Timings and screenshots are supported in performance traces.",
"optional": true,
"type": "boolean"
},
{
"name": "unstable_networkThrottlingEnabled",
"description": "Whether network throttling is supported in the Network panel.",
"optional": true,
"type": "boolean"
}
]
},
Expand All @@ -84,7 +90,7 @@
"parameters": [
{
"name": "isSingleHost",
"description": "Whether the application has a single React Native host. If an app or\nframework intantiates multiple hosts, some debugger features will not\n behave safely and should be dynamically disabled.",
"description": "Whether the application has a single React Native host. If an app or\nframework intantiates multiple hosts, some debugger features will not\nbehave safely and should be dynamically disabled.",
"type": "boolean"
}
]
Expand Down Expand Up @@ -32044,4 +32050,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ experimental domain ReactNativeApplication
optional boolean unstable_networkInspectionEnabled
# Whether Frame Timings and screenshots are supported in performance traces.
optional boolean unstable_frameRecordingEnabled
# Whether network throttling is supported in the Network panel.
optional boolean unstable_networkThrottlingEnabled

# Emitted when assertions about the debugger backend have changed.
event systemStateChanged
Expand Down
Loading