@@ -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