Skip to content

Commit 6e12856

Browse files
huntiehoxyq
andauthored
[0.83] Backport performance debugging improvements (#248)
Co-authored-by: Ruslan Lesiutin <28902667+hoxyq@users.noreply.github.com>
1 parent 7d3b734 commit 6e12856

File tree

9 files changed

+61
-19
lines changed

9 files changed

+61
-19
lines changed

front_end/core/rn_experiments/experimentsImpl.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,9 @@ Instance.register({
184184
unstable: false,
185185
enabledByDefault: ({ isReactNativeEntryPoint }) => isReactNativeEntryPoint,
186186
});
187+
188+
Instance.register({
189+
name: RNExperimentName.ENABLE_TIMELINE_FRAMES,
190+
title: 'Enable performance frames track',
191+
unstable: true,
192+
});

front_end/core/root/Runtime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export const experiments = new ExperimentsSupport();
305305
export enum RNExperimentName {
306306
REACT_NATIVE_SPECIFIC_UI = 'react-native-specific-ui',
307307
JS_HEAP_PROFILER_ENABLE = 'js-heap-profiler-enable',
308+
ENABLE_TIMELINE_FRAMES = 'enable-timeline-frames',
308309
}
309310

310311
export enum ConditionName {
@@ -339,6 +340,7 @@ export const enum ExperimentName {
339340
JS_HEAP_PROFILER_ENABLE = RNExperimentName.JS_HEAP_PROFILER_ENABLE,
340341
REACT_NATIVE_SPECIFIC_UI = RNExperimentName.REACT_NATIVE_SPECIFIC_UI,
341342
NOT_REACT_NATIVE_SPECIFIC_UI = '!' + RNExperimentName.REACT_NATIVE_SPECIFIC_UI,
343+
ENABLE_TIMELINE_FRAMES = RNExperimentName.ENABLE_TIMELINE_FRAMES,
342344
}
343345

344346
export enum GenAiEnterprisePolicyValue {

front_end/entrypoints/rn_fusebox/FuseboxFeatureObserver.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ const UIStrings = {
2929
* @description Title shown when a feature is unavailable due to multiple React Native hosts.
3030
*/
3131
multiHostFeatureUnavailableTitle: 'Feature is unavailable',
32+
/**
33+
* @description Message for the "settings changed" banner shown when a reload
34+
* is required for frame timings in the Performance panel.
35+
*/
36+
reloadRequiredForTimelineFramesMessage:
37+
'Frame timings and screenshots are now available in the Performance panel. Please reload to enable.',
3238
/**
3339
* @description Detail message shown when a feature is disabled due to multiple React Native hosts.
3440
*/
@@ -75,7 +81,7 @@ export class FuseboxFeatureObserver implements
7581
#handleMetadataUpdated(
7682
event: Common.EventTarget.EventTargetEvent<Protocol.ReactNativeApplication.MetadataUpdatedEvent>): void {
7783
// eslint-disable-next-line @typescript-eslint/naming-convention
78-
const {unstable_isProfilingBuild, unstable_networkInspectionEnabled} = event.data;
84+
const {unstable_isProfilingBuild, unstable_networkInspectionEnabled, unstable_frameRecordingEnabled} = event.data;
7985

8086
if (unstable_isProfilingBuild) {
8187
FuseboxWindowTitleManager.instance().setSuffix('[PROFILING]');
@@ -87,6 +93,10 @@ export class FuseboxFeatureObserver implements
8793
if (!unstable_networkInspectionEnabled && !Root.Runtime.conditions.reactNativeExpoNetworkPanel()) {
8894
this.#hideNetworkPanel();
8995
}
96+
97+
if (unstable_frameRecordingEnabled) {
98+
void this.#ensureTimelineFramesEnabled();
99+
}
90100
}
91101

92102
#handleSystemStateChanged(
@@ -132,6 +142,14 @@ export class FuseboxFeatureObserver implements
132142
});
133143
}
134144

145+
async #ensureTimelineFramesEnabled(): Promise<void> {
146+
if (!Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES)) {
147+
Root.Runtime.experiments.setEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES, true);
148+
UI.InspectorView?.InspectorView?.instance()?.displayReloadRequiredWarning(
149+
i18nString(UIStrings.reloadRequiredForTimelineFramesMessage));
150+
}
151+
}
152+
135153
#disableSingleHostOnlyFeatures(): void {
136154
if (this.#singleHostFeaturesDisabled) {
137155
return;

front_end/generated/protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ export namespace ReactNativeApplication {
6161
* Enables the Network Panel.
6262
*/
6363
unstable_networkInspectionEnabled?: boolean;
64+
/**
65+
* Whether Frame Timings and screenshots are supported in performance
66+
* traces.
67+
*/
68+
unstable_frameRecordingEnabled?: boolean;
6469
}
6570

6671
/**

front_end/panels/timeline/TimelineFlameChartDataProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
615615
// In CPU Profiles the trace data will not have frames nor
616616
// screenshots, so we can keep this call as it will be a no-op in
617617
// these cases.
618-
if (!this.isReactNative) {
618+
if (Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES) || !this.isReactNative) {
619619
this.#appendFramesAndScreenshotsTrack();
620620
}
621621

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
573573
this.panelToolbar.wrappable = true;
574574
this.panelRightToolbar = timelineToolbarContainer.createChild('devtools-toolbar');
575575
this.panelRightToolbar.role = 'presentation';
576-
if (!isNode && !isReactNative) {
576+
if (!isNode) {
577577
this.createSettingsPane();
578578
this.updateShowSettingsToolbarButton();
579579
}
@@ -1189,7 +1189,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
11891189

11901190
// View
11911191
this.panelToolbar.appendSeparator();
1192-
if (!isNode && !isReactNative) {
1192+
if (!isNode && (Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES) || !isReactNative)) {
11931193
this.showScreenshotsToolbarCheckbox =
11941194
this.createSettingCheckbox(this.showScreenshotsSetting, i18nString(UIStrings.captureScreenshots));
11951195
this.panelToolbar.appendToolbarItem(this.showScreenshotsToolbarCheckbox);
@@ -1225,7 +1225,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
12251225
}
12261226

12271227
// Settings
1228-
if (!isNode && !isReactNative) {
1228+
if (!isNode) {
12291229
this.panelRightToolbar.appendSeparator();
12301230
this.panelRightToolbar.appendToolbarItem(this.showSettingsPaneButton);
12311231
}
@@ -1334,22 +1334,24 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
13341334
this.disableCaptureJSProfileSetting.title(), this.disableCaptureJSProfileSetting,
13351335
i18nString(UIStrings.disablesJavascriptSampling)));
13361336

1337-
const cpuThrottlingPane = this.settingsPane.createChild('div');
1338-
cpuThrottlingPane.append(i18nString(UIStrings.cpu));
1339-
this.cpuThrottlingSelect = MobileThrottling.ThrottlingManager.throttlingManager().createCPUThrottlingSelector();
1340-
cpuThrottlingPane.append(this.cpuThrottlingSelect.control.element);
1337+
if (!isReactNative) {
1338+
const cpuThrottlingPane = this.settingsPane.createChild('div');
1339+
cpuThrottlingPane.append(i18nString(UIStrings.cpu));
1340+
this.cpuThrottlingSelect = MobileThrottling.ThrottlingManager.throttlingManager().createCPUThrottlingSelector();
1341+
cpuThrottlingPane.append(this.cpuThrottlingSelect.control.element);
13411342

1342-
this.settingsPane.append(UI.SettingsUI.createSettingCheckbox(
1343-
this.captureLayersAndPicturesSetting.title(), this.captureLayersAndPicturesSetting,
1344-
i18nString(UIStrings.capturesAdvancedPaint)));
1343+
this.settingsPane.append(UI.SettingsUI.createSettingCheckbox(
1344+
this.captureLayersAndPicturesSetting.title(), this.captureLayersAndPicturesSetting,
1345+
i18nString(UIStrings.capturesAdvancedPaint)));
13451346

1346-
const networkThrottlingPane = this.settingsPane.createChild('div');
1347-
networkThrottlingPane.append(i18nString(UIStrings.network));
1348-
networkThrottlingPane.append(this.createNetworkConditionsSelectToolbarItem().element);
1347+
const networkThrottlingPane = this.settingsPane.createChild('div');
1348+
networkThrottlingPane.append(i18nString(UIStrings.network));
1349+
networkThrottlingPane.append(this.createNetworkConditionsSelectToolbarItem().element);
13491350

1350-
this.settingsPane.append(UI.SettingsUI.createSettingCheckbox(
1351-
this.captureSelectorStatsSetting.title(), this.captureSelectorStatsSetting,
1352-
i18nString(UIStrings.capturesSelectorStats)));
1351+
this.settingsPane.append(UI.SettingsUI.createSettingCheckbox(
1352+
this.captureSelectorStatsSetting.title(), this.captureSelectorStatsSetting,
1353+
i18nString(UIStrings.capturesSelectorStats)));
1354+
}
13531355

13541356
const thirdPartyCheckbox =
13551357
this.createSettingCheckbox(this.#thirdPartyTracksSetting, i18nString(UIStrings.showDataAddedByExtensions));
@@ -1618,7 +1620,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
16181620
}
16191621

16201622
private updateSettingsPaneVisibility(): void {
1621-
if (isNode || isReactNative) {
1623+
if (isNode) {
16221624
return;
16231625
}
16241626
if (this.showSettingsPaneSetting.get()) {

front_end/testing/EnvironmentHelpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ const REGISTERED_EXPERIMENTS = [
130130
Root.Runtime.ExperimentName.TIMELINE_ALTERNATIVE_NAVIGATION,
131131
Root.Runtime.ExperimentName.REACT_NATIVE_SPECIFIC_UI,
132132
Root.Runtime.ExperimentName.NOT_REACT_NATIVE_SPECIFIC_UI,
133+
Root.Runtime.ExperimentName.ENABLE_TIMELINE_FRAMES,
133134
];
134135

135136
export async function initializeGlobalVars({reset = true} = {}) {

third_party/blink/public/devtools_protocol/browser_protocol.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
"description": "Enables the Network Panel.",
7070
"optional": true,
7171
"type": "boolean"
72+
},
73+
{
74+
"name": "unstable_frameRecordingEnabled",
75+
"description": "Whether Frame Timings and screenshots are supported in performance traces.",
76+
"optional": true,
77+
"type": "boolean"
7278
}
7379
]
7480
},

third_party/blink/public/devtools_protocol/react_native_domains.pdl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ experimental domain ReactNativeApplication
3030
optional boolean unstable_isProfilingBuild
3131
# Enables the Network Panel.
3232
optional boolean unstable_networkInspectionEnabled
33+
# Whether Frame Timings and screenshots are supported in performance traces.
34+
optional boolean unstable_frameRecordingEnabled
3335

3436
# Emitted when assertions about the debugger backend have changed.
3537
event systemStateChanged

0 commit comments

Comments
 (0)