Skip to content

Commit 3e9c11c

Browse files
committed
add debugger launch events
1 parent c4a0fa0 commit 3e9c11c

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

front_end/core/host/RNPerfMetrics.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ class RNPerfMetrics {
5757
this.#launchId = launchId;
5858
}
5959

60+
entryPointLoadingStarted(): void {
61+
this.sendEvent({
62+
eventName: 'Entrypoint.LoadingStarted',
63+
timestamp: getPerfTimestamp(),
64+
launchId: this.#launchId,
65+
});
66+
}
67+
68+
debuggerReadyToPause(): void {
69+
this.sendEvent({
70+
eventName: 'Debugger.IsReadyToPause',
71+
timestamp: getPerfTimestamp(),
72+
launchId: this.#launchId,
73+
});
74+
}
75+
}
76+
77+
function getPerfTimestamp(): DOMHighResTimeStamp {
78+
return performance.timeOrigin + performance.now();
6079
}
6180

6281
export function registerPerfMetricsGlobalPostMessageHandler(): void {
@@ -70,4 +89,17 @@ export function registerPerfMetricsGlobalPostMessageHandler(): void {
7089
});
7190
}
7291

73-
export type ReactNativeChromeDevToolsEvent = {};
92+
type CommonEventFields = Readonly<{
93+
timestamp: DOMHighResTimeStamp,
94+
launchId: string | void | null,
95+
}>;
96+
97+
export type DebuggerLaunchedEvent = Readonly<CommonEventFields&{
98+
eventName: 'Entrypoint.LoadingStarted',
99+
}>;
100+
101+
export type DebuggerReadyEvent = Readonly<CommonEventFields&{
102+
eventName: 'Debugger.IsReadyToPause',
103+
}>;
104+
105+
export type ReactNativeChromeDevToolsEvent = DebuggerLaunchedEvent|DebuggerReadyEvent;

front_end/entrypoints/rn_inspector/rn_inspector.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ import type * as InspectorBackend from '../../core/protocol_client/InspectorBack
2323
Host.RNPerfMetrics.registerPerfMetricsGlobalPostMessageHandler();
2424

2525
Host.rnPerfMetrics.setLaunchId(Root.Runtime.Runtime.queryParam('launchId'));
26+
Host.rnPerfMetrics.entryPointLoadingStarted();
27+
28+
SDK.TargetManager.TargetManager.instance().addModelListener(
29+
SDK.DebuggerModel.DebuggerModel,
30+
SDK.DebuggerModel.Events.DebuggerIsReadyToPause,
31+
() => Host.rnPerfMetrics.debuggerReadyToPause(),
32+
);
33+
2634
// Legacy JavaScript Profiler - we support this until Hermes can support the
2735
// modern Performance panel.
2836
Root.Runtime.experiments.register(

0 commit comments

Comments
 (0)