Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions front_end/core/host/RNPerfMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ class RNPerfMetrics {
});
}

developerResourcesStartupLoadingFinishedEvent(numResources: number, timeSinceLaunch: DOMHighResTimeStamp): void {
this.sendEvent({
eventName: 'DeveloperResources.StartupLoadingFinished',
params: {
numResources,
timeSinceLaunch,
},
});
}

fuseboxSetClientMetadataStarted(): void {
this.sendEvent({eventName: 'FuseboxSetClientMetadataStarted'});
}
Expand Down Expand Up @@ -435,6 +445,14 @@ export type DeveloperResourceLoadingFinishedEvent = Readonly<{
}>,
}>;

export type DeveloperResourcesStartupLoadingFinishedEvent = Readonly<{
eventName: 'DeveloperResources.StartupLoadingFinished',
params: Readonly<{
numResources: number,
timeSinceLaunch: DOMHighResTimeStamp,
}>,
}>;

export type FuseboxSetClientMetadataStartedEvent = Readonly<{
eventName: 'FuseboxSetClientMetadataStarted',
}>;
Expand Down Expand Up @@ -523,10 +541,10 @@ export type ManualBreakpointSetSucceeded = Readonly<{

export type ReactNativeChromeDevToolsEvent =
EntrypointLoadingStartedEvent|EntrypointLoadingFinishedEvent|DebuggerReadyEvent|BrowserVisibilityChangeEvent|
BrowserErrorEvent|RemoteDebuggingTerminatedEvent|DeveloperResourceLoadingStartedEvent|
DeveloperResourceLoadingFinishedEvent|FuseboxSetClientMetadataStartedEvent|FuseboxSetClientMetadataFinishedEvent|
MemoryPanelActionStartedEvent|MemoryPanelActionFinishedEvent|PanelShownEvent|PanelClosedEvent|
StackTraceSymbolicationSucceeded|StackTraceSymbolicationFailed|StackTraceFrameUrlResolutionSucceeded|
BrowserErrorEvent|RemoteDebuggingTerminatedEvent|DeveloperResourcesStartupLoadingFinishedEvent|
DeveloperResourceLoadingStartedEvent|DeveloperResourceLoadingFinishedEvent|FuseboxSetClientMetadataStartedEvent|
FuseboxSetClientMetadataFinishedEvent|MemoryPanelActionStartedEvent|MemoryPanelActionFinishedEvent|PanelShownEvent|
PanelClosedEvent|StackTraceSymbolicationSucceeded|StackTraceSymbolicationFailed|StackTraceFrameUrlResolutionSucceeded|
StackTraceFrameUrlResolutionFailed|ManualBreakpointSetSucceeded|StackTraceFrameClicked;

export type DecoratedReactNativeChromeDevToolsEvent = CommonEventFields&ReactNativeChromeDevToolsEvent;
22 changes: 22 additions & 0 deletions front_end/core/sdk/PageResourceLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
import type {Target} from './Target.js';
import {TargetManager} from './TargetManager.js';

const RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN = 3000;

const UIStrings = {
/**
*@description Error message for canceled source map loads
Expand Down Expand Up @@ -82,6 +84,8 @@ interface LoadQueueEntry {
*/
export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
#currentlyLoading = 0;
#rndtStartupResourcesLoadedReported = false;
#rndtStartupResourcesLoadedTimeout: number|undefined = undefined;
#currentlyLoadingPerTarget = new Map<Protocol.Target.TargetID|'main', number>();
readonly #maxConcurrentLoads: number;
#pageResources = new Map<string, PageResource>();
Expand Down Expand Up @@ -261,6 +265,23 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
await this.acquireLoadSlot(initiator.target);
const resultPromise = this.dispatchLoad(url, initiator);
const result = await resultPromise;

if (!this.#rndtStartupResourcesLoadedReported) {
// If, after initial load, no new resources are scheduled for
// RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN,
// we consider all startup resources to be loaded + settled.
window.clearTimeout(this.#rndtStartupResourcesLoadedTimeout);
this.#rndtStartupResourcesLoadedTimeout = window.setTimeout(() => {
if (!this.#rndtStartupResourcesLoadedReported && this.#currentlyLoading === 0) {
Host.rnPerfMetrics.developerResourcesStartupLoadingFinishedEvent(
this.getNumberOfResources().resources /* numResources */,
performance.now() - RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN /* timeSinceLaunch */,
);
this.#rndtStartupResourcesLoadedReported = true;
}
}, RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN);
}

pageResource.errorMessage = result.errorDescription.message;
pageResource.success = result.success;
if (result.success) {
Expand Down Expand Up @@ -354,6 +375,7 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
}
Host.rnPerfMetrics.developerResourceLoadingFinished(
parsedURL, Host.UserMetrics.DeveloperResourceLoaded.FALLBACK_AFTER_FAILURE, result);

return result;
}

Expand Down
Loading