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
1 change: 0 additions & 1 deletion front_end/core/rn_experiments/experimentsImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,4 @@ Instance.register({
name: RNExperimentName.ENABLE_TIMELINE_FRAMES,
title: 'Enable performance frames track',
unstable: true,
enabledByDefault: () => globalThis.enableTimelineFrames ?? false,
});
20 changes: 19 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 frame timings in the Performance panel.
*/
reloadRequiredForTimelineFramesMessage:
'Frame timings and screenshots are now available in the Performance panel. Please reload to enable.',
/**
* @description Detail message shown when a feature is disabled due to multiple React Native hosts.
*/
Expand Down Expand Up @@ -75,7 +81,7 @@ 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} = event.data;
const {unstable_isProfilingBuild, unstable_networkInspectionEnabled, unstable_frameRecordingEnabled} = event.data;

if (unstable_isProfilingBuild) {
FuseboxWindowTitleManager.instance().setSuffix('[PROFILING]');
Expand All @@ -87,6 +93,10 @@ export class FuseboxFeatureObserver implements
if (!unstable_networkInspectionEnabled && !Root.Runtime.conditions.reactNativeExpoNetworkPanel()) {
this.#hideNetworkPanel();
}

if (unstable_frameRecordingEnabled) {
void this.#ensureTimelineFramesEnabled();
}
}

#handleSystemStateChanged(
Expand Down Expand Up @@ -132,6 +142,14 @@ export class FuseboxFeatureObserver implements
});
}

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

#disableSingleHostOnlyFeatures(): void {
if (this.#singleHostFeaturesDisabled) {
return;
Expand Down
5 changes: 5 additions & 0 deletions front_end/generated/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export namespace ReactNativeApplication {
* Enables the Network Panel.
*/
unstable_networkInspectionEnabled?: boolean;
/**
* Whether Frame Timings and screenshots are supported in performance
* traces.
*/
unstable_frameRecordingEnabled?: boolean;
}

/**
Expand Down
19 changes: 0 additions & 19 deletions front_end/panels/timeline/TimelinePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,14 +712,6 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
SDK.ReactNativeApplicationModel.ReactNativeApplicationModel,
{
modelAdded: (model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel) => {
model.addEventListener(
SDK.ReactNativeApplicationModel.Events.METADATA_UPDATED,
(event: Common.EventTarget.EventTargetEvent<Protocol.ReactNativeApplication.MetadataUpdatedEvent>) => {
if (event.data.platform === 'android') {
this.showScreenshotsToolbarCheckbox?.setVisible(true);
}
}
);
model.addEventListener(
SDK.ReactNativeApplicationModel.Events.TRACE_REQUESTED, () => this.rnPrepareForTraceCapturedInBackground());
},
Expand Down Expand Up @@ -1200,17 +1192,6 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
if (!isNode && (Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES) || !isReactNative)) {
this.showScreenshotsToolbarCheckbox =
this.createSettingCheckbox(this.showScreenshotsSetting, i18nString(UIStrings.captureScreenshots));

let showScreenshotsToggle = false;

const reactNativeApplicationModel = SDK.TargetManager.TargetManager.instance().primaryPageTarget()?.model(SDK.ReactNativeApplicationModel.ReactNativeApplicationModel);
if (reactNativeApplicationModel !== null && reactNativeApplicationModel !== undefined) {
showScreenshotsToggle = reactNativeApplicationModel.metadataCached?.platform === 'android';
}

// Only show this toggle if we are on android, to address a possible race condition with the platform metadata,
// this is also checked again on SDK.ReactNativeApplicationModel.Events.METADATA_UPDATED
this.showScreenshotsToolbarCheckbox.setVisible(showScreenshotsToggle);
this.panelToolbar.appendToolbarItem(this.showScreenshotsToolbarCheckbox);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
"description": "Enables the Network Panel.",
"optional": true,
"type": "boolean"
},
{
"name": "unstable_frameRecordingEnabled",
"description": "Whether Frame Timings and screenshots are supported in performance traces.",
"optional": true,
"type": "boolean"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ experimental domain ReactNativeApplication
optional boolean unstable_isProfilingBuild
# Enables the Network Panel.
optional boolean unstable_networkInspectionEnabled
# Whether Frame Timings and screenshots are supported in performance traces.
optional boolean unstable_frameRecordingEnabled

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