Skip to content

refactor: hide console and memory panels / views for profiling builds #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
31 changes: 21 additions & 10 deletions front_end/entrypoints/rn_fusebox/FuseboxExperimentsObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,28 @@ export default class FuseboxFeatureObserver implements
}

#hideUnsupportedFeaturesForProfilingBuilds(): void {
UI.ViewManager.ViewManager.instance()
.resolveLocation(UI.ViewManager.ViewLocationValues.PANEL)
.then(location => {
UI.InspectorView.InspectorView.instance().closeDrawer();

const viewManager = UI.ViewManager.ViewManager.instance();
const panelLocationPromise = viewManager.resolveLocation(UI.ViewManager.ViewLocationValues.PANEL);
const drawerLocationPromise = viewManager.resolveLocation(UI.ViewManager.ViewLocationValues.DRAWER_VIEW);
void Promise.all([panelLocationPromise, drawerLocationPromise])
.then(([panelLocation, drawerLocation]) => {
UI.ViewManager.getRegisteredViewExtensions().forEach(view => {
switch (view.viewId()) {
case 'sources':
case 'network':
case 'react-devtools-components':
case 'react-devtools-profiler':
location?.removeView(view);
break;
if (view.location() === UI.ViewManager.ViewLocationValues.DRAWER_VIEW) {
drawerLocation?.removeView(view);
} else {
switch (view.viewId()) {
case 'console':
case 'heap-profiler':
case 'live-heap-profile':
case 'sources':
case 'network':
case 'react-devtools-components':
case 'react-devtools-profiler':
panelLocation?.removeView(view);
break;
}
}
});
});
Expand Down
11 changes: 9 additions & 2 deletions front_end/panels/rn_welcome/RNWelcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class RNWelcomeImpl extends UI.Widget.VBox implements
private readonly options: RNWelcomeOptions;

#reactNativeVersion: string|undefined;
#isProfilingBuild: boolean = false;

static instance(options: RNWelcomeOptions): RNWelcomeImpl {
if (!rnWelcomeImplInstance) {
Expand All @@ -81,14 +82,19 @@ export class RNWelcomeImpl extends UI.Widget.VBox implements
super.wasShown();
this.registerCSSFiles([rnWelcomeStyles]);
this.render();
UI.InspectorView.InspectorView.instance().showDrawer({focus: true, hasTargetDrawer: false});

if (!this.#isProfilingBuild) {
UI.InspectorView.InspectorView.instance().showDrawer({focus: true, hasTargetDrawer: false});
}
}

modelAdded(model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel): void {
model.ensureEnabled();
model.addEventListener(
SDK.ReactNativeApplicationModel.Events.MetadataUpdated, this.#handleMetadataUpdated, this);

this.#reactNativeVersion = model.metadataCached?.reactNativeVersion;
this.#isProfilingBuild = model.metadataCached?.unstable_isProfilingBuild || false;
}

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

if (this.isShowing()) {
this.render();
Expand Down Expand Up @@ -136,7 +143,7 @@ export class RNWelcomeImpl extends UI.Widget.VBox implements
).toString();

const launchId = Root.Runtime.Runtime.queryParam('launchId');

render(html`
<div class="rn-welcome-panel">
<header class="rn-welcome-hero">
Expand Down
Loading