Skip to content

Commit dab7fd9

Browse files
committed
track when all startup resources are loaded
1 parent cb0bab7 commit dab7fd9

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

front_end/core/host/RNPerfMetrics.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ class RNPerfMetrics {
186186
});
187187
}
188188

189+
developerResourcesStartupLoadingFinishedEvent(count: number): void {
190+
this.sendEvent({
191+
eventName: 'DeveloperResources.StartupLoadingFinished',
192+
params: {
193+
count,
194+
},
195+
});
196+
}
197+
189198
fuseboxSetClientMetadataStarted(): void {
190199
this.sendEvent({eventName: 'FuseboxSetClientMetadataStarted'});
191200
}
@@ -437,6 +446,13 @@ export type DeveloperResourceLoadingFinishedEvent = Readonly<{
437446
}>,
438447
}>;
439448

449+
export type DeveloperResourcesStartupLoadingFinishedEvent = Readonly<{
450+
eventName: 'DeveloperResources.StartupLoadingFinished',
451+
params: Readonly<{
452+
count: number,
453+
}>,
454+
}>;
455+
440456
export type FuseboxSetClientMetadataStartedEvent = Readonly<{
441457
eventName: 'FuseboxSetClientMetadataStarted',
442458
}>;
@@ -525,10 +541,10 @@ export type ManualBreakpointSetSucceeded = Readonly<{
525541

526542
export type ReactNativeChromeDevToolsEvent =
527543
EntrypointLoadingStartedEvent|EntrypointLoadingFinishedEvent|DebuggerReadyEvent|BrowserVisibilityChangeEvent|
528-
BrowserErrorEvent|RemoteDebuggingTerminatedEvent|DeveloperResourceLoadingStartedEvent|
529-
DeveloperResourceLoadingFinishedEvent|FuseboxSetClientMetadataStartedEvent|FuseboxSetClientMetadataFinishedEvent|
530-
MemoryPanelActionStartedEvent|MemoryPanelActionFinishedEvent|PanelShownEvent|PanelClosedEvent|
531-
StackTraceSymbolicationSucceeded|StackTraceSymbolicationFailed|StackTraceFrameUrlResolutionSucceeded|
532-
StackTraceFrameUrlResolutionFailed|ManualBreakpointSetSucceeded|StackTraceFrameClicked;
544+
BrowserErrorEvent|RemoteDebuggingTerminatedEvent|DeveloperResourceLoadingStartedEvent|StackTraceFrameClicked|
545+
DeveloperResourceLoadingFinishedEvent|DeveloperResourcesStartupLoadingFinishedEvent|FuseboxSetClientMetadataStartedEvent|
546+
FuseboxSetClientMetadataFinishedEvent|MemoryPanelActionStartedEvent|MemoryPanelActionFinishedEvent|
547+
PanelShownEvent|PanelClosedEvent|StackTraceSymbolicationSucceeded|StackTraceSymbolicationFailed|
548+
StackTraceFrameUrlResolutionSucceeded|StackTraceFrameUrlResolutionFailed|ManualBreakpointSetSucceeded;
533549

534550
export type DecoratedReactNativeChromeDevToolsEvent = CommonEventFields&ReactNativeChromeDevToolsEvent;

front_end/core/sdk/PageResourceLoader.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ interface LoadQueueEntry {
8282
*/
8383
export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
8484
#currentlyLoading = 0;
85+
#reportedStartupResourcesLoaded = false;
8586
#currentlyLoadingPerTarget = new Map<Protocol.Target.TargetID|'main', number>();
8687
readonly #maxConcurrentLoads: number;
8788
#pageResources = new Map<string, PageResource>();
@@ -279,6 +280,10 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
279280
} finally {
280281
pageResource.duration = performance.now() - startTime;
281282
this.releaseLoadSlot(initiator.target);
283+
if (!this.#reportedStartupResourcesLoaded && this.#currentlyLoading === 0) {
284+
Host.rnPerfMetrics.startupDeveloperResourcesLoadingFinished(this.getNumberOfResources().resources);
285+
this.#reportedStartupResourcesLoaded = true;
286+
}
282287
this.dispatchEventToListeners(Events.UPDATE);
283288
}
284289
}
@@ -354,6 +359,7 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
354359
}
355360
Host.rnPerfMetrics.developerResourceLoadingFinished(
356361
parsedURL, Host.UserMetrics.DeveloperResourceLoaded.FALLBACK_AFTER_FAILURE, result);
362+
357363
return result;
358364
}
359365

0 commit comments

Comments
 (0)