Skip to content

Commit 71b172b

Browse files
committed
report first steady ping after initial resources loaded
1 parent 06d7de0 commit 71b172b

2 files changed

Lines changed: 30 additions & 14 deletions

File tree

front_end/core/host/RNPerfMetrics.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class RNPerfMetrics {
2929
#telemetryInfo: Object = {};
3030
// map of panel location to panel name
3131
#currentPanels = new Map<PanelLocation, string>();
32+
#initialBundlesLoadedInfo: null|{count: number} = null;
3233

3334
isEnabled(): boolean {
3435
return globalThis.enableReactNativePerfMetrics === true;
@@ -187,12 +188,7 @@ class RNPerfMetrics {
187188
}
188189

189190
allInitialDeveloperResourcesLoadingFinished(count: number): void {
190-
this.sendEvent({
191-
eventName: 'DeveloperResource.AllInitialLoadingFinished',
192-
params: {
193-
count,
194-
},
195-
});
191+
this.#initialBundlesLoadedInfo = {count};
196192
}
197193

198194
fuseboxSetClientMetadataStarted(): void {
@@ -215,10 +211,22 @@ class RNPerfMetrics {
215211
}
216212
}
217213

218-
firstSteadyPing(): void {
214+
tryReportingSteadyPing(): boolean {
215+
if (this.#initialBundlesLoadedInfo === null) {
216+
return false;
217+
}
218+
219+
// const [navigationEntry] = performance.getEntriesByType('navigation');
220+
// eslint-disable-next-line
221+
console.info('Startup time is %s', performance.now());
222+
219223
this.sendEvent({
220-
eventName: 'FirstSteadyPing',
224+
eventName: 'FirstSteadyPingAfterInitialResourcesLoaded',
225+
params: {
226+
bundleCount: this.#initialBundlesLoadedInfo.count,
227+
}
221228
});
229+
return true;
222230
}
223231

224232
heapSnapshotStarted(): void {
@@ -511,8 +519,11 @@ export type StackTraceFrameUrlResolutionFailed = Readonly<{
511519
}>,
512520
}>;
513521

514-
export type FirstSteadyPing = Readonly<{
515-
eventName: 'FirstSteadyPing',
522+
export type FirstSteadyPingAfterInitialResourcesLoaded = Readonly<{
523+
eventName: 'FirstSteadyPingAfterInitialResourcesLoaded',
524+
params: Readonly<{
525+
bundleCount: number,
526+
}>,
516527
}>;
517528

518529
export type ReactNativeChromeDevToolsEvent =
@@ -521,6 +532,6 @@ export type ReactNativeChromeDevToolsEvent =
521532
DeveloperResourceLoadingFinishedEvent|AllInitialDeveloperResourcesLoadingFinished|FuseboxSetClientMetadataStartedEvent|
522533
FuseboxSetClientMetadataFinishedEvent|MemoryPanelActionStartedEvent|MemoryPanelActionFinishedEvent|
523534
PanelShownEvent|PanelClosedEvent|StackTraceSymbolicationSucceeded|StackTraceSymbolicationFailed|
524-
StackTraceFrameUrlResolutionSucceeded|StackTraceFrameUrlResolutionFailed|FirstSteadyPing;
535+
StackTraceFrameUrlResolutionSucceeded|StackTraceFrameUrlResolutionFailed|FirstSteadyPingAfterInitialResourcesLoaded;
525536

526537
export type DecoratedReactNativeChromeDevToolsEvent = CommonEventFields&ReactNativeChromeDevToolsEvent;

front_end/entrypoints/inspector_main/InspectorMain.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,15 @@ export class InspectorMainImpl implements Common.Runnable.Runnable {
7777
this.#consecutiveLowPing++;
7878
}
7979

80+
let reportedSteadyPing = false;
8081
if (this.#consecutiveLowPing > 1) {
81-
Host.rnPerfMetrics.firstSteadyPing();
82-
} else {
83-
setTimeout(() => void this.#measureMainConnectionPing(debuggerModel), COOLDOWN_BETWEEN_PINGS);
82+
reportedSteadyPing = Host.rnPerfMetrics.tryReportingSteadyPing();
83+
}
84+
85+
if (!reportedSteadyPing) {
86+
setTimeout(() => {
87+
void this.#measureMainConnectionPing(debuggerModel);
88+
}, COOLDOWN_BETWEEN_PINGS);
8489
}
8590
}
8691

0 commit comments

Comments
 (0)