@@ -20,6 +20,8 @@ import {
2020import type { Target } from './Target.js' ;
2121import { TargetManager } from './TargetManager.js' ;
2222
23+ const RN_DT_STARTUP_RESOURCES_LOADED_COOLDOWN = 3000 ;
24+
2325const UIStrings = {
2426 /**
2527 *@description Error message for canceled source map loads
@@ -82,6 +84,8 @@ interface LoadQueueEntry {
8284 */
8385export class PageResourceLoader extends Common . ObjectWrapper . ObjectWrapper < EventTypes > {
8486 #currentlyLoading = 0 ;
87+ #rndtStartupResourcesLoadedReported = false ;
88+ #rndtStartupResourcesLoadedTimeout: number | undefined = undefined ;
8589 #currentlyLoadingPerTarget = new Map < Protocol . Target . TargetID | 'main' , number > ( ) ;
8690 readonly #maxConcurrentLoads: number ;
8791 #pageResources = new Map < string , PageResource > ( ) ;
@@ -261,6 +265,23 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
261265 await this . acquireLoadSlot ( initiator . target ) ;
262266 const resultPromise = this . dispatchLoad ( url , initiator ) ;
263267 const result = await resultPromise ;
268+
269+ if ( ! this . #rndtStartupResourcesLoadedReported) {
270+ // if no new resources were scheduled for loading for
271+ // RN_DT_STARTUP_RESOURCES_LOADED_COOLDOWN amount of time, for the first time,
272+ // we consider all startup resources to be loaded
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 ( ) - RN_DT_STARTUP_RESOURCES_LOADED_COOLDOWN /* timeSinceLaunch */ ,
279+ ) ;
280+ this . #rndtStartupResourcesLoadedReported = true ;
281+ }
282+ } , RN_DT_STARTUP_RESOURCES_LOADED_COOLDOWN ) ;
283+ }
284+
264285 pageResource . errorMessage = result . errorDescription . message ;
265286 pageResource . success = result . success ;
266287 if ( result . success ) {
@@ -354,6 +375,7 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
354375 }
355376 Host . rnPerfMetrics . developerResourceLoadingFinished (
356377 parsedURL , Host . UserMetrics . DeveloperResourceLoaded . FALLBACK_AFTER_FAILURE , result ) ;
378+
357379 return result ;
358380 }
359381
0 commit comments