Skip to content

Commit 40e2a7d

Browse files
authored
Gate performance screenshots toggle to Android only (#227)
Gate screenshots toggle to android only
1 parent 1f05fd8 commit 40e2a7d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,14 @@ 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+
);
715723
model.addEventListener(
716724
SDK.ReactNativeApplicationModel.Events.TRACE_REQUESTED, () => this.rnPrepareForTraceCapturedInBackground());
717725
},
@@ -1192,6 +1200,17 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
11921200
if (!isNode && (Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES) || !isReactNative)) {
11931201
this.showScreenshotsToolbarCheckbox =
11941202
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);
11951214
this.panelToolbar.appendToolbarItem(this.showScreenshotsToolbarCheckbox);
11961215
}
11971216

0 commit comments

Comments
 (0)