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
6 changes: 6 additions & 0 deletions front_end/core/sdk/ReactNativeApplicationModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ export class ReactNativeApplicationModel extends SDKModel<EventTypes> implements
this.metadataCached = metadata;
this.dispatchEventToListeners(Events.METADATA_UPDATED, metadata);
}

traceRequested(): void {
this.dispatchEventToListeners(Events.TRACE_REQUESTED);
}
}

export const enum Events {
METADATA_UPDATED = 'MetadataUpdated',
TRACE_REQUESTED = 'TraceRequested',
}

export interface EventTypes {
[Events.METADATA_UPDATED]: Protocol.ReactNativeApplication.MetadataUpdatedEvent;
[Events.TRACE_REQUESTED]: void;
}
1 change: 1 addition & 0 deletions front_end/generated/InspectorBackendCommands.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions front_end/generated/protocol-mapping.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export namespace ProtocolMapping {
* device, application, and debugger integration.
*/
'ReactNativeApplication.metadataUpdated': [Protocol.ReactNativeApplication.MetadataUpdatedEvent];
/**
* Fired when React Native requests Chrome DevTools to prepare for displaying the captured Trace.
*/
'ReactNativeApplication.traceRequested': [];
/**
* The loadComplete event mirrors the load complete event sent by the browser to assistive
* technology when the web page has finished loading.
Expand Down
5 changes: 5 additions & 0 deletions front_end/generated/protocol-proxy-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ declare namespace ProtocolProxyApi {
*/
metadataUpdated(params: Protocol.ReactNativeApplication.MetadataUpdatedEvent): void;

/**
* Fired when React Native requests Chrome DevTools to prepare for displaying the captured Trace.
*/
traceRequested(): void;

}

export interface AccessibilityApi {
Expand Down
5 changes: 5 additions & 0 deletions front_end/models/trace/TracingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export class TracingManager extends SDK.SDKModel.SDKModel<void> {
this.#finishing = true;
void this.#tracingAgent.invoke_end();
}

rnPrepareForTraceCapturedInBackground(client: TracingManagerClient): void {
this.#activeClient = client;
this.#finishing = true;
}
}

export interface TracingManagerClient {
Expand Down
12 changes: 12 additions & 0 deletions front_end/panels/timeline/TimelineController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ export class TimelineController implements Trace.TracingManager.TracingManagerCl
await LiveMetrics.LiveMetrics.instance().enable();
}

async rnPrepareForTraceCapturedInBackground(): Promise<void> {
await LiveMetrics.LiveMetrics.instance().disable();

if (this.tracingManager) {
this.tracingManager.rnPrepareForTraceCapturedInBackground(this);
}

this.client.loadingStarted();
await this.allSourcesFinished();
await LiveMetrics.LiveMetrics.instance().enable();
}

private async fetchFieldData(): Promise<CrUXManager.PageResult[]|null> {
const cruxManager = CrUXManager.CrUXManager.instance();
if (!cruxManager.isEnabled() || !navigator.onLine) {
Expand Down
38 changes: 38 additions & 0 deletions front_end/panels/timeline/TimelinePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,19 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
this.#showLandingPage();
this.updateTimelineControls();

if (isReactNative) {
SDK.TargetManager.TargetManager.instance().observeModels(
SDK.ReactNativeApplicationModel.ReactNativeApplicationModel,
{
modelAdded: (model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel) => {
model.addEventListener(
SDK.ReactNativeApplicationModel.Events.TRACE_REQUESTED, () => this.rnPrepareForTraceCapturedInBackground());
},
modelRemoved: (_model: SDK.ReactNativeApplicationModel.ReactNativeApplicationModel) => {},
},
);
}

SDK.TargetManager.TargetManager.instance().addEventListener(
SDK.TargetManager.Events.SUSPEND_STATE_CHANGED, this.onSuspendStateChanged, this);
const profilerModels = SDK.TargetManager.TargetManager.instance().models(SDK.CPUProfilerModel.CPUProfilerModel);
Expand Down Expand Up @@ -731,6 +744,31 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
});
}

private async rnPrepareForTraceCapturedInBackground(): Promise<void> {
this.setUIControlsEnabled(false);

if (this.statusPane) {
this.statusPane.finish();
this.statusPane.updateStatus(i18nString(UIStrings.stoppingTimeline));
this.statusPane.updateProgressBar(i18nString(UIStrings.received), 0);
}
this.setState(State.STOP_PENDING);

const rootTarget = SDK.TargetManager.TargetManager.instance().rootTarget();
if (!rootTarget) {
throw new Error('Could not load root target.');
}
const primaryPageTarget = SDK.TargetManager.TargetManager.instance().primaryPageTarget();
if (!primaryPageTarget) {
throw new Error('Could not load primary page target.');
}

this.controller = new TimelineController(rootTarget, primaryPageTarget, this);
await this.controller.rnPrepareForTraceCapturedInBackground();

this.setUIControlsEnabled(true);
}

#setActiveInsight(insight: TimelineComponents.Sidebar.ActiveInsight|null): void {
// When an insight is selected, ensure that the 3P checkbox is disabled
// to avoid dimming interference.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
"type": "boolean"
}
]
},
{
"name": "traceRequested",
"description": "Fired when React Native requests Chrome DevTools to prepare for displaying the captured Trace."
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ experimental domain ReactNativeApplication
optional boolean unstable_isProfilingBuild
# Enables the Network Panel.
optional boolean unstable_networkInspectionEnabled

# Fired when React Native requests Chrome DevTools to prepare for displaying the captured Trace.
event traceRequested
Loading