Skip to content

Commit 7e19a54

Browse files
authored
refactor: hide console and memory panels / views for profiling builds (#163)
1 parent f5506e6 commit 7e19a54

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

front_end/entrypoints/rn_fusebox/FuseboxExperimentsObserver.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,28 @@ export default class FuseboxFeatureObserver implements
6262
}
6363

6464
#hideUnsupportedFeaturesForProfilingBuilds(): void {
65-
UI.ViewManager.ViewManager.instance()
66-
.resolveLocation(UI.ViewManager.ViewLocationValues.PANEL)
67-
.then(location => {
65+
UI.InspectorView.InspectorView.instance().closeDrawer();
66+
67+
const viewManager = UI.ViewManager.ViewManager.instance();
68+
const panelLocationPromise = viewManager.resolveLocation(UI.ViewManager.ViewLocationValues.PANEL);
69+
const drawerLocationPromise = viewManager.resolveLocation(UI.ViewManager.ViewLocationValues.DRAWER_VIEW);
70+
void Promise.all([panelLocationPromise, drawerLocationPromise])
71+
.then(([panelLocation, drawerLocation]) => {
6872
UI.ViewManager.getRegisteredViewExtensions().forEach(view => {
69-
switch (view.viewId()) {
70-
case 'sources':
71-
case 'network':
72-
case 'react-devtools-components':
73-
case 'react-devtools-profiler':
74-
location?.removeView(view);
75-
break;
73+
if (view.location() === UI.ViewManager.ViewLocationValues.DRAWER_VIEW) {
74+
drawerLocation?.removeView(view);
75+
} else {
76+
switch (view.viewId()) {
77+
case 'console':
78+
case 'heap-profiler':
79+
case 'live-heap-profile':
80+
case 'sources':
81+
case 'network':
82+
case 'react-devtools-components':
83+
case 'react-devtools-profiler':
84+
panelLocation?.removeView(view);
85+
break;
86+
}
7687
}
7788
});
7889
});

front_end/panels/rn_welcome/RNWelcome.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class RNWelcomeImpl extends UI.Widget.VBox implements
6060
private readonly options: RNWelcomeOptions;
6161

6262
#reactNativeVersion: string|undefined;
63+
#isProfilingBuild: boolean = false;
6364

6465
static instance(options: RNWelcomeOptions): RNWelcomeImpl {
6566
if (!rnWelcomeImplInstance) {
@@ -81,14 +82,19 @@ export class RNWelcomeImpl extends UI.Widget.VBox implements
8182
super.wasShown();
8283
this.registerCSSFiles([rnWelcomeStyles]);
8384
this.render();
84-
UI.InspectorView.InspectorView.instance().showDrawer({focus: true, hasTargetDrawer: false});
85+
86+
if (!this.#isProfilingBuild) {
87+
UI.InspectorView.InspectorView.instance().showDrawer({focus: true, hasTargetDrawer: false});
88+
}
8589
}
8690

8791
modelAdded(model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel): void {
8892
model.ensureEnabled();
8993
model.addEventListener(
9094
SDK.ReactNativeApplicationModel.Events.MetadataUpdated, this.#handleMetadataUpdated, this);
95+
9196
this.#reactNativeVersion = model.metadataCached?.reactNativeVersion;
97+
this.#isProfilingBuild = model.metadataCached?.unstable_isProfilingBuild || false;
9298
}
9399

94100
modelRemoved(model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel): void {
@@ -99,6 +105,7 @@ export class RNWelcomeImpl extends UI.Widget.VBox implements
99105
#handleMetadataUpdated(
100106
event: Common.EventTarget.EventTargetEvent<Protocol.ReactNativeApplication.MetadataUpdatedEvent>): void {
101107
this.#reactNativeVersion = event.data.reactNativeVersion;
108+
this.#isProfilingBuild = event.data.unstable_isProfilingBuild || false;
102109

103110
if (this.isShowing()) {
104111
this.render();
@@ -136,7 +143,7 @@ export class RNWelcomeImpl extends UI.Widget.VBox implements
136143
).toString();
137144

138145
const launchId = Root.Runtime.Runtime.queryParam('launchId');
139-
146+
140147
render(html`
141148
<div class="rn-welcome-panel">
142149
<header class="rn-welcome-hero">

0 commit comments

Comments
 (0)