@@ -20,6 +20,8 @@ import {
20
20
import type { Target } from './Target.js' ;
21
21
import { TargetManager } from './TargetManager.js' ;
22
22
23
+ const RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN = 3000 ;
24
+
23
25
const UIStrings = {
24
26
/**
25
27
*@description Error message for canceled source map loads
@@ -82,6 +84,8 @@ interface LoadQueueEntry {
82
84
*/
83
85
export class PageResourceLoader extends Common . ObjectWrapper . ObjectWrapper < EventTypes > {
84
86
#currentlyLoading = 0 ;
87
+ #rndtStartupResourcesLoadedReported = false ;
88
+ #rndtStartupResourcesLoadedTimeout: number | undefined = undefined ;
85
89
#currentlyLoadingPerTarget = new Map < Protocol . Target . TargetID | 'main' , number > ( ) ;
86
90
readonly #maxConcurrentLoads: number ;
87
91
#pageResources = new Map < string , PageResource > ( ) ;
@@ -261,6 +265,23 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
261
265
await this . acquireLoadSlot ( initiator . target ) ;
262
266
const resultPromise = this . dispatchLoad ( url , initiator ) ;
263
267
const result = await resultPromise ;
268
+
269
+ if ( ! this . #rndtStartupResourcesLoadedReported) {
270
+ // If, after initial load, no new resources are scheduled for
271
+ // RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN,
272
+ // we consider all startup resources to be loaded + settled.
273
+ window . clearTimeout ( this . #rndtStartupResourcesLoadedTimeout) ;
274
+ this . #rndtStartupResourcesLoadedTimeout = window . setTimeout ( ( ) => {
275
+ if ( ! this . #rndtStartupResourcesLoadedReported && this . #currentlyLoading === 0 ) {
276
+ Host . rnPerfMetrics . developerResourcesStartupLoadingFinishedEvent (
277
+ this . getNumberOfResources ( ) . resources /* numResources */ ,
278
+ performance . now ( ) - RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN /* timeSinceLaunch */ ,
279
+ ) ;
280
+ this . #rndtStartupResourcesLoadedReported = true ;
281
+ }
282
+ } , RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN ) ;
283
+ }
284
+
264
285
pageResource . errorMessage = result . errorDescription . message ;
265
286
pageResource . success = result . success ;
266
287
if ( result . success ) {
@@ -354,6 +375,7 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
354
375
}
355
376
Host . rnPerfMetrics . developerResourceLoadingFinished (
356
377
parsedURL , Host . UserMetrics . DeveloperResourceLoaded . FALLBACK_AFTER_FAILURE , result ) ;
378
+
357
379
return result ;
358
380
}
359
381
0 commit comments