@@ -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 > ( ) ; 
@@ -354,6 +358,23 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
354358    } 
355359    Host . rnPerfMetrics . developerResourceLoadingFinished ( 
356360        parsedURL ,  Host . UserMetrics . DeveloperResourceLoaded . FALLBACK_AFTER_FAILURE ,  result ) ; 
361+ 
362+     if  ( ! this . #rndtStartupResourcesLoadedReported)  { 
363+       // if no new resources were scheduled for loading for 
364+       // RN_DT_STARTUP_RESOURCES_LOADED_COOLDOWN amount of time, for the first time, 
365+       // we consider all startup resources to be loaded 
366+       window . clearTimeout ( this . #rndtStartupResourcesLoadedTimeout) ; 
367+       this . #rndtStartupResourcesLoadedTimeout =  window . setTimeout ( ( )  =>  { 
368+         if  ( ! this . #rndtStartupResourcesLoadedReported &&  this . #currentlyLoading ===  0 )  { 
369+           Host . rnPerfMetrics . developerResourcesStartupLoadingFinishedEvent ( 
370+             this . getNumberOfResources ( ) . resources  /* numResources */ , 
371+             performance . now ( )  -  RN_DT_STARTUP_RESOURCES_LOADED_COOLDOWN  /* timeSinceLaunch */ , 
372+           ) ; 
373+           this . #rndtStartupResourcesLoadedReported =  true ; 
374+         } 
375+       } ,  RN_DT_STARTUP_RESOURCES_LOADED_COOLDOWN ) ; 
376+     } 
377+ 
357378    return  result ; 
358379  } 
359380
0 commit comments