Skip to content

Commit 3f189fe

Browse files
committed
Formalise ENABLE_TIMELINE_FRAMES experiment (#242)
1 parent ff7f376 commit 3f189fe

File tree

9 files changed

+43
-3
lines changed

9 files changed

+43
-3
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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);

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)