Skip to content

Commit 571dc30

Browse files
authored
Formalise ENABLE_TIMELINE_FRAMES experiment (#242)
1 parent 8edd9be commit 571dc30

File tree

6 files changed

+32
-21
lines changed

6 files changed

+32
-21
lines changed

front_end/core/rn_experiments/experimentsImpl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,4 @@ Instance.register({
189189
name: RNExperimentName.ENABLE_TIMELINE_FRAMES,
190190
title: 'Enable performance frames track',
191191
unstable: true,
192-
enabledByDefault: () => globalThis.enableTimelineFrames ?? false,
193192
});

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/TimelinePanel.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -712,14 +712,6 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
712712
SDK.ReactNativeApplicationModel.ReactNativeApplicationModel,
713713
{
714714
modelAdded: (model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel) => {
715-
model.addEventListener(
716-
SDK.ReactNativeApplicationModel.Events.METADATA_UPDATED,
717-
(event: Common.EventTarget.EventTargetEvent<Protocol.ReactNativeApplication.MetadataUpdatedEvent>) => {
718-
if (event.data.platform === 'android') {
719-
this.showScreenshotsToolbarCheckbox?.setVisible(true);
720-
}
721-
}
722-
);
723715
model.addEventListener(
724716
SDK.ReactNativeApplicationModel.Events.TRACE_REQUESTED, () => this.rnPrepareForTraceCapturedInBackground());
725717
},
@@ -1200,17 +1192,6 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
12001192
if (!isNode && (Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES) || !isReactNative)) {
12011193
this.showScreenshotsToolbarCheckbox =
12021194
this.createSettingCheckbox(this.showScreenshotsSetting, i18nString(UIStrings.captureScreenshots));
1203-
1204-
let showScreenshotsToggle = false;
1205-
1206-
const reactNativeApplicationModel = SDK.TargetManager.TargetManager.instance().primaryPageTarget()?.model(SDK.ReactNativeApplicationModel.ReactNativeApplicationModel);
1207-
if (reactNativeApplicationModel !== null && reactNativeApplicationModel !== undefined) {
1208-
showScreenshotsToggle = reactNativeApplicationModel.metadataCached?.platform === 'android';
1209-
}
1210-
1211-
// Only show this toggle if we are on android, to address a possible race condition with the platform metadata,
1212-
// this is also checked again on SDK.ReactNativeApplicationModel.Events.METADATA_UPDATED
1213-
this.showScreenshotsToolbarCheckbox.setVisible(showScreenshotsToggle);
12141195
this.panelToolbar.appendToolbarItem(this.showScreenshotsToolbarCheckbox);
12151196
}
12161197

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)