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
34 changes: 33 additions & 1 deletion front_end/core/host/RNPerfMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ class RNPerfMetrics {
this.#launchId = launchId;
}

entryPointLoadingStarted(): void {
this.sendEvent({
eventName: 'Entrypoint.LoadingStarted',
timestamp: getPerfTimestamp(),
launchId: this.#launchId,
});
}

debuggerReadyToPause(): void {
this.sendEvent({
eventName: 'Debugger.IsReadyToPause',
timestamp: getPerfTimestamp(),
launchId: this.#launchId,
});
}
}

function getPerfTimestamp(): DOMHighResTimeStamp {
return performance.timeOrigin + performance.now();
}

export function registerPerfMetricsGlobalPostMessageHandler(): void {
Expand All @@ -70,4 +89,17 @@ export function registerPerfMetricsGlobalPostMessageHandler(): void {
});
}

export type ReactNativeChromeDevToolsEvent = {};
type CommonEventFields = Readonly<{
timestamp: DOMHighResTimeStamp,
launchId: string | void | null,
}>;

export type DebuggerLaunchedEvent = Readonly<CommonEventFields&{
eventName: 'Entrypoint.LoadingStarted',
}>;

export type DebuggerReadyEvent = Readonly<CommonEventFields&{
eventName: 'Debugger.IsReadyToPause',
}>;

export type ReactNativeChromeDevToolsEvent = DebuggerLaunchedEvent|DebuggerReadyEvent;
8 changes: 8 additions & 0 deletions front_end/entrypoints/rn_inspector/rn_inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ import type * as Sources from '../../panels/sources/sources.js';
Host.RNPerfMetrics.registerPerfMetricsGlobalPostMessageHandler();

Host.rnPerfMetrics.setLaunchId(Root.Runtime.Runtime.queryParam('launchId'));
Host.rnPerfMetrics.entryPointLoadingStarted();

SDK.TargetManager.TargetManager.instance().addModelListener(
SDK.DebuggerModel.DebuggerModel,
SDK.DebuggerModel.Events.DebuggerIsReadyToPause,
() => Host.rnPerfMetrics.debuggerReadyToPause(),
);

// Legacy JavaScript Profiler - we support this until Hermes can support the
// modern Performance panel.
Root.Runtime.experiments.register(
Expand Down