diff --git a/front_end/core/host/RNPerfMetrics.ts b/front_end/core/host/RNPerfMetrics.ts index 117428464e3..dcc3660988f 100644 --- a/front_end/core/host/RNPerfMetrics.ts +++ b/front_end/core/host/RNPerfMetrics.ts @@ -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 { @@ -70,4 +89,17 @@ export function registerPerfMetricsGlobalPostMessageHandler(): void { }); } -export type ReactNativeChromeDevToolsEvent = {}; +type CommonEventFields = Readonly<{ + timestamp: DOMHighResTimeStamp, + launchId: string | void | null, +}>; + +export type DebuggerLaunchedEvent = Readonly; + +export type DebuggerReadyEvent = Readonly; + +export type ReactNativeChromeDevToolsEvent = DebuggerLaunchedEvent|DebuggerReadyEvent; diff --git a/front_end/entrypoints/rn_inspector/rn_inspector.ts b/front_end/entrypoints/rn_inspector/rn_inspector.ts index 164baf4090f..6af2630b826 100644 --- a/front_end/entrypoints/rn_inspector/rn_inspector.ts +++ b/front_end/entrypoints/rn_inspector/rn_inspector.ts @@ -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(