@@ -20,6 +20,8 @@ import {
2020import  type  { Target }  from  './Target.js' ; 
2121import  { TargetManager }  from  './TargetManager.js' ; 
2222
23+ const  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+   #startupResourcesLoadedReported =  false ; 
88+   #startupResourcesLoadedTimeout: 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,22 @@ 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 . #startupResourcesLoadedReported)  { 
363+       // if no new resource was set to be loaded for a certain time 
364+       // we consider all startup resources to be loaded 
365+       window . clearTimeout ( this . #startupResourcesLoadedTimeout) ; 
366+       this . #startupResourcesLoadedTimeout =  window . setTimeout ( ( )  =>  { 
367+         if  ( ! this . #startupResourcesLoadedReported &&  this . #currentlyLoading ===  0 )  { 
368+           Host . rnPerfMetrics . developerResourcesStartupLoadingFinishedEvent ( 
369+             this . getNumberOfResources ( ) . resources  /* numResources */ , 
370+             performance . now ( )  -  STARTUP_RESOURCES_LOADED_COOLDOWN  /* timeSinceLaunch */ , 
371+           ) ; 
372+           this . #startupResourcesLoadedReported =  true ; 
373+         } 
374+       } ,  STARTUP_RESOURCES_LOADED_COOLDOWN ) ; 
375+     } 
376+ 
357377    return  result ; 
358378  } 
359379
0 commit comments