Skip to content

Commit e4887b2

Browse files
authored
Merge branch 'main' into users/devanb/frames
2 parents ba292d9 + 7aa57d1 commit e4887b2

37 files changed

Lines changed: 352 additions & 96 deletions

AGENTS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Project Instructions
2+
3+
This codebase is a fork of https://github.com/ChromeDevTools/devtools-frontend.
4+
5+
## Editing Policy
6+
7+
- Make minimal edits. No speculative refactors.
8+
- Changes should generally be scoped to the `front_end/` directory. Focus code searches here.
9+
10+
## Workflow
11+
12+
- Update `BUILD.gn` files when adding new modules and imports.
13+
- New files should prepend "Copyright (c) Meta Platforms, Inc. and affiliates." as the first line of the license header, above the Chromium Authors license. Keep in sync with `META_CODE_PATHS` in `scripts/eslint_rules/lib/check-license-header.js`.
14+
15+
## Architecture
16+
17+
- For UI code, prefer modern `html` template code and locate styles in one adjacent CSS file. Example: `front_end/ui/components/cards/Cards.ts`.
-7.97 KB
Loading
-15.4 KB
Loading
-3.09 KB
Loading

front_end/core/host/RNPerfMetrics.ts

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ class RNPerfMetrics {
186186
});
187187
}
188188

189+
developerResourcesStartupLoadingFinishedEvent(numResources: number, timeSinceLaunch: DOMHighResTimeStamp): void {
190+
this.sendEvent({
191+
eventName: 'DeveloperResources.StartupLoadingFinished',
192+
params: {
193+
numResources,
194+
timeSinceLaunch,
195+
},
196+
});
197+
}
198+
189199
fuseboxSetClientMetadataStarted(): void {
190200
this.sendEvent({eventName: 'FuseboxSetClientMetadataStarted'});
191201
}
@@ -298,6 +308,24 @@ class RNPerfMetrics {
298308
});
299309
}
300310

311+
manualBreakpointSetSucceeded(bpSettingDuration: number): void {
312+
this.sendEvent({
313+
eventName: 'ManualBreakpointSetSucceeded',
314+
params: {
315+
bpSettingDuration,
316+
}
317+
});
318+
}
319+
320+
stackTraceFrameClicked(isLinkified: boolean): void {
321+
this.sendEvent({
322+
eventName: 'StackTraceFrameClicked',
323+
params: {
324+
isLinkified,
325+
}
326+
});
327+
}
328+
301329
panelShown(_panelName: string, _isLaunching?: boolean): void {
302330
// no-op
303331
// We only care about the "main" and "drawer" panels for now via panelShownInLocation(…)
@@ -417,6 +445,14 @@ export type DeveloperResourceLoadingFinishedEvent = Readonly<{
417445
}>,
418446
}>;
419447

448+
export type DeveloperResourcesStartupLoadingFinishedEvent = Readonly<{
449+
eventName: 'DeveloperResources.StartupLoadingFinished',
450+
params: Readonly<{
451+
numResources: number,
452+
timeSinceLaunch: DOMHighResTimeStamp,
453+
}>,
454+
}>;
455+
420456
export type FuseboxSetClientMetadataStartedEvent = Readonly<{
421457
eventName: 'FuseboxSetClientMetadataStarted',
422458
}>;
@@ -489,12 +525,26 @@ export type StackTraceFrameUrlResolutionFailed = Readonly<{
489525
}>,
490526
}>;
491527

528+
export type StackTraceFrameClicked = Readonly<{
529+
eventName: 'StackTraceFrameClicked',
530+
params: Readonly<{
531+
isLinkified: boolean,
532+
}>,
533+
}>;
534+
535+
export type ManualBreakpointSetSucceeded = Readonly<{
536+
eventName: 'ManualBreakpointSetSucceeded',
537+
params: Readonly<{
538+
bpSettingDuration: number,
539+
}>,
540+
}>;
541+
492542
export type ReactNativeChromeDevToolsEvent =
493543
EntrypointLoadingStartedEvent|EntrypointLoadingFinishedEvent|DebuggerReadyEvent|BrowserVisibilityChangeEvent|
494-
BrowserErrorEvent|RemoteDebuggingTerminatedEvent|DeveloperResourceLoadingStartedEvent|
495-
DeveloperResourceLoadingFinishedEvent|FuseboxSetClientMetadataStartedEvent|FuseboxSetClientMetadataFinishedEvent|
496-
MemoryPanelActionStartedEvent|MemoryPanelActionFinishedEvent|PanelShownEvent|PanelClosedEvent|
497-
StackTraceSymbolicationSucceeded|StackTraceSymbolicationFailed|StackTraceFrameUrlResolutionSucceeded|
498-
StackTraceFrameUrlResolutionFailed;
544+
BrowserErrorEvent|RemoteDebuggingTerminatedEvent|DeveloperResourcesStartupLoadingFinishedEvent|
545+
DeveloperResourceLoadingStartedEvent|DeveloperResourceLoadingFinishedEvent|FuseboxSetClientMetadataStartedEvent|
546+
FuseboxSetClientMetadataFinishedEvent|MemoryPanelActionStartedEvent|MemoryPanelActionFinishedEvent|PanelShownEvent|
547+
PanelClosedEvent|StackTraceSymbolicationSucceeded|StackTraceSymbolicationFailed|StackTraceFrameUrlResolutionSucceeded|
548+
StackTraceFrameUrlResolutionFailed|ManualBreakpointSetSucceeded|StackTraceFrameClicked;
499549

500550
export type DecoratedReactNativeChromeDevToolsEvent = CommonEventFields&ReactNativeChromeDevToolsEvent;

front_end/core/rn_experiments/experimentsImpl.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ Instance.register({
185185
enabledByDefault: ({ isReactNativeEntryPoint }) => isReactNativeEntryPoint,
186186
});
187187

188-
Instance.register({
189-
name: RNExperimentName.ENABLE_PERFORMANCE_PANEL,
190-
title: 'Enable Performance panel',
191-
unstable: true,
192-
enabledByDefault: ({ isReactNativeEntryPoint }) => !isReactNativeEntryPoint,
193-
});
194-
195188
Instance.register({
196189
name: RNExperimentName.ENABLE_NETWORK_PANEL,
197190
title: 'Enable Network panel',

front_end/core/root/Runtime.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ export const experiments = new ExperimentsSupport();
305305
export enum RNExperimentName {
306306
REACT_NATIVE_SPECIFIC_UI = 'react-native-specific-ui',
307307
JS_HEAP_PROFILER_ENABLE = 'js-heap-profiler-enable',
308-
ENABLE_PERFORMANCE_PANEL = 'enable-performance-panel',
309308
ENABLE_NETWORK_PANEL = 'enable-network-panel',
310309
ENABLE_TIMELINE_FRAMES = 'enable-timeline-frames',
311310
}
@@ -342,7 +341,6 @@ export const enum ExperimentName {
342341
JS_HEAP_PROFILER_ENABLE = RNExperimentName.JS_HEAP_PROFILER_ENABLE,
343342
REACT_NATIVE_SPECIFIC_UI = RNExperimentName.REACT_NATIVE_SPECIFIC_UI,
344343
NOT_REACT_NATIVE_SPECIFIC_UI = '!' + RNExperimentName.REACT_NATIVE_SPECIFIC_UI,
345-
ENABLE_PERFORMANCE_PANEL = RNExperimentName.ENABLE_PERFORMANCE_PANEL,
346344
ENABLE_NETWORK_PANEL = RNExperimentName.ENABLE_NETWORK_PANEL,
347345
ENABLE_TIMELINE_FRAMES = RNExperimentName.ENABLE_TIMELINE_FRAMES,
348346
}

front_end/core/sdk/PageResourceLoader.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
import type {Target} from './Target.js';
2121
import {TargetManager} from './TargetManager.js';
2222

23+
const RNDT_STARTUP_RESOURCES_LOADED_COOLDOWN = 3000;
24+
2325
const UIStrings = {
2426
/**
2527
*@description Error message for canceled source map loads
@@ -82,6 +84,8 @@ interface LoadQueueEntry {
8284
*/
8385
export 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, 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+
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

front_end/core/sdk/ReactNativeApplicationModel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,18 @@ export class ReactNativeApplicationModel extends SDKModel<EventTypes> implements
5151
this.metadataCached = metadata;
5252
this.dispatchEventToListeners(Events.METADATA_UPDATED, metadata);
5353
}
54+
55+
traceRequested(): void {
56+
this.dispatchEventToListeners(Events.TRACE_REQUESTED);
57+
}
5458
}
5559

5660
export const enum Events {
5761
METADATA_UPDATED = 'MetadataUpdated',
62+
TRACE_REQUESTED = 'TraceRequested',
5863
}
5964

6065
export interface EventTypes {
6166
[Events.METADATA_UPDATED]: Protocol.ReactNativeApplication.MetadataUpdatedEvent;
67+
[Events.TRACE_REQUESTED]: void;
6268
}

front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export class HeapSnapshotLoader {
7272
}
7373

7474
async buildSnapshot(secondWorker: MessagePort): Promise<JSHeapSnapshot> {
75+
await this.parsingComplete;
76+
7577
this.#snapshot = this.#snapshot || {};
7678

7779
this.#progress.updateStatus('Processing snapshot…');

0 commit comments

Comments
 (0)