chrome-devtools-frontend 1.0.1515988 → 1.0.1518653
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/checklist/README.md +2 -2
- package/docs/checklist/javascript.md +1 -1
- package/docs/contributing/README.md +1 -1
- package/docs/contributing/settings-experiments-features.md +9 -8
- package/docs/cookbook/devtools_on_devtools.md +2 -2
- package/docs/cookbook/localization.md +10 -10
- package/docs/devtools-protocol.md +9 -8
- package/docs/ecosystem/automatic_workspace_folders.md +3 -3
- package/docs/get_the_code.md +0 -2
- package/docs/styleguide/ux/components.md +166 -85
- package/docs/styleguide/ux/numbers.md +3 -4
- package/front_end/core/common/README.md +13 -12
- package/front_end/core/host/GdpClient.ts +16 -1
- package/front_end/core/host/UserMetrics.ts +8 -2
- package/front_end/core/root/Runtime.ts +13 -0
- package/front_end/core/sdk/CSSMatchedStyles.ts +5 -1
- package/front_end/entrypoints/main/MainImpl.ts +6 -3
- package/front_end/generated/InspectorBackendCommands.js +10 -7
- package/front_end/generated/SupportedCSSProperties.js +21 -7
- package/front_end/generated/protocol-mapping.d.ts +16 -1
- package/front_end/generated/protocol-proxy-api.d.ts +13 -1
- package/front_end/generated/protocol.ts +95 -0
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +170 -54
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +14 -181
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +13 -315
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +224 -50
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +310 -11
- package/front_end/models/ai_assistance/performance/AIContext.ts +15 -2
- package/front_end/models/ai_code_completion/AiCodeCompletion.ts +41 -19
- package/front_end/models/badges/Badge.ts +8 -3
- package/front_end/models/badges/CodeWhispererBadge.ts +2 -4
- package/front_end/models/badges/StarterBadge.ts +2 -2
- package/front_end/models/badges/UserBadges.ts +59 -6
- package/front_end/models/formatter/FormatterWorkerPool.ts +3 -3
- package/front_end/models/javascript_metadata/NativeFunctions.js +1 -1
- package/front_end/models/trace/README.md +28 -1
- package/front_end/models/trace/handlers/UserTimingsHandler.ts +1 -1
- package/front_end/models/trace/helpers/Trace.ts +99 -43
- package/front_end/models/trace/types/TraceEvents.ts +9 -0
- package/front_end/panels/accessibility/ARIAAttributesView.ts +113 -191
- package/front_end/panels/accessibility/AccessibilityNodeView.ts +9 -9
- package/front_end/panels/accessibility/AccessibilitySubPane.ts +6 -4
- package/front_end/panels/accessibility/accessibilityProperties.css +2 -0
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +16 -2
- package/front_end/panels/ai_assistance/components/ChatView.ts +9 -10
- package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +42 -0
- package/front_end/panels/common/AiCodeCompletionDisclaimer.ts +32 -9
- package/front_end/panels/common/AiCodeCompletionSummaryToolbar.ts +7 -1
- package/front_end/panels/common/BadgeNotification.ts +67 -15
- package/front_end/panels/common/GdpSignUpDialog.ts +18 -9
- package/front_end/panels/console/ConsolePrompt.ts +1 -1
- package/front_end/panels/console/ConsoleView.ts +6 -2
- package/front_end/panels/elements/ComputedStyleWidget.ts +1 -2
- package/front_end/panels/elements/ElementsPanel.ts +4 -0
- package/front_end/panels/elements/ElementsTreeElement.ts +18 -0
- package/front_end/panels/elements/ElementsTreeOutline.ts +13 -0
- package/front_end/panels/elements/LayoutPane.ts +1 -1
- package/front_end/panels/elements/StylePropertyTreeElement.ts +21 -6
- package/front_end/panels/media/TickingFlameChart.ts +1 -1
- package/front_end/panels/network/NetworkLogView.ts +5 -1
- package/front_end/panels/profiler/HeapSnapshotView.ts +34 -19
- package/front_end/panels/search/SearchResultsPane.ts +126 -145
- package/front_end/panels/search/SearchView.ts +43 -59
- package/front_end/panels/settings/components/SyncSection.ts +16 -8
- package/front_end/panels/sources/AiCodeCompletionPlugin.ts +6 -1
- package/front_end/panels/sources/OutlineQuickOpen.ts +3 -1
- package/front_end/panels/sources/SourcesPanel.ts +3 -0
- package/front_end/panels/timeline/AppenderUtils.ts +2 -2
- package/front_end/panels/timeline/ExtensionTrackAppender.ts +13 -4
- package/front_end/panels/timeline/GPUTrackAppender.ts +2 -1
- package/front_end/panels/timeline/InteractionsTrackAppender.ts +5 -1
- package/front_end/panels/timeline/LayoutShiftsTrackAppender.ts +2 -1
- package/front_end/panels/timeline/ThreadAppender.ts +12 -3
- package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +9 -4
- package/front_end/panels/timeline/TimelinePanel.ts +3 -2
- package/front_end/panels/timeline/TimelineUIUtils.ts +18 -12
- package/front_end/panels/timeline/TimingsTrackAppender.ts +6 -1
- package/front_end/panels/timeline/components/CPUThrottlingSelector.ts +95 -82
- package/front_end/panels/timeline/components/LiveMetricsView.ts +2 -2
- package/front_end/panels/timeline/components/cpuThrottlingSelector.css +17 -15
- package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +3 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/chunk/codemirror.js.map +1 -1
- package/front_end/third_party/codemirror.next/codemirror.next.d.ts +6 -9
- package/front_end/third_party/codemirror.next/package.json +2 -1
- package/front_end/third_party/diff/README.chromium +1 -0
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/Realm.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.js +0 -20
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/generated/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/generated/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +2 -23
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.js +0 -20
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/generated/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/generated/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js.map +1 -1
- package/front_end/third_party/puppeteer/package/package.json +1 -1
- package/front_end/third_party/puppeteer/package/src/cdp/Accessibility.ts +1 -21
- package/front_end/third_party/puppeteer/package/src/generated/version.ts +1 -1
- package/front_end/third_party/puppeteer/package/src/revisions.ts +1 -1
- package/front_end/ui/components/text_editor/config.ts +36 -8
- package/front_end/ui/components/tooltips/Tooltip.ts +71 -34
- package/front_end/ui/legacy/README.md +33 -24
- package/front_end/ui/legacy/SearchableView.ts +19 -26
- package/front_end/ui/legacy/TextPrompt.ts +166 -1
- package/front_end/ui/legacy/Treeoutline.ts +16 -2
- package/front_end/ui/legacy/UIUtils.ts +15 -2
- package/front_end/ui/legacy/XElement.ts +0 -43
- package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +20 -4
- package/front_end/ui/visual_logging/KnownContextValues.ts +24 -6
- package/front_end/ui/visual_logging/README.md +43 -27
- package/package.json +1 -1
@@ -4,9 +4,10 @@
|
|
4
4
|
|
5
5
|
import * as Common from '../../core/common/common.js';
|
6
6
|
import * as Host from '../../core/host/host.js';
|
7
|
+
import * as Root from '../../core/root/root.js';
|
7
8
|
|
8
9
|
import {AiExplorerBadge} from './AiExplorerBadge.js';
|
9
|
-
import type {Badge, BadgeAction, BadgeActionEvents, BadgeContext} from './Badge.js';
|
10
|
+
import type {Badge, BadgeAction, BadgeActionEvents, BadgeContext, TriggerOptions} from './Badge.js';
|
10
11
|
import {CodeWhispererBadge} from './CodeWhispererBadge.js';
|
11
12
|
import {DOMDetectiveBadge} from './DOMDetectiveBadge.js';
|
12
13
|
import {SpeedsterBadge} from './SpeedsterBadge.js';
|
@@ -22,6 +23,10 @@ export interface EventTypes {
|
|
22
23
|
[Events.BADGE_TRIGGERED]: Badge;
|
23
24
|
}
|
24
25
|
|
26
|
+
const SNOOZE_TIME_MS = 24 * 60 * 60 * 1000; // 24 hours
|
27
|
+
const MAX_SNOOZE_COUNT = 3;
|
28
|
+
const DELAY_BEFORE_TRIGGER = 1500;
|
29
|
+
|
25
30
|
let userBadgesInstance: UserBadges|undefined = undefined;
|
26
31
|
export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
27
32
|
readonly #badgeActionEventTarget = new Common.ObjectWrapper.ObjectWrapper<BadgeActionEvents>();
|
@@ -29,6 +34,10 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
29
34
|
#receiveBadgesSetting: Common.Settings.Setting<Boolean>;
|
30
35
|
#allBadges: Badge[];
|
31
36
|
|
37
|
+
#starterBadgeSnoozeCount: Common.Settings.Setting<number>;
|
38
|
+
#starterBadgeLastSnoozedTimestamp: Common.Settings.Setting<number>;
|
39
|
+
#starterBadgeDismissed: Common.Settings.Setting<boolean>;
|
40
|
+
|
32
41
|
static readonly BADGE_REGISTRY: BadgeClass[] = [
|
33
42
|
StarterBadge,
|
34
43
|
SpeedsterBadge,
|
@@ -41,8 +50,19 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
41
50
|
super();
|
42
51
|
|
43
52
|
this.#receiveBadgesSetting = Common.Settings.Settings.instance().moduleSetting('receive-gdp-badges');
|
53
|
+
if (Host.GdpClient.getGdpProfilesEnterprisePolicy() ===
|
54
|
+
Root.Runtime.GdpProfilesEnterprisePolicyValue.ENABLED_WITHOUT_BADGES) {
|
55
|
+
this.#receiveBadgesSetting.set(false);
|
56
|
+
}
|
44
57
|
this.#receiveBadgesSetting.addChangeListener(this.#reconcileBadges, this);
|
45
58
|
|
59
|
+
this.#starterBadgeSnoozeCount = Common.Settings.Settings.instance().createSetting(
|
60
|
+
'starter-badge-snooze-count', 0, Common.Settings.SettingStorageType.SYNCED);
|
61
|
+
this.#starterBadgeLastSnoozedTimestamp = Common.Settings.Settings.instance().createSetting(
|
62
|
+
'starter-badge-last-snoozed-timestamp', 0, Common.Settings.SettingStorageType.SYNCED);
|
63
|
+
this.#starterBadgeDismissed = Common.Settings.Settings.instance().createSetting(
|
64
|
+
'starter-badge-dismissed', false, Common.Settings.SettingStorageType.SYNCED);
|
65
|
+
|
46
66
|
this.#allBadges = UserBadges.BADGE_REGISTRY.map(badgeCtor => new badgeCtor({
|
47
67
|
onTriggerBadge: this.#onTriggerBadge.bind(this),
|
48
68
|
badgeActionEventTarget: this.#badgeActionEventTarget,
|
@@ -60,6 +80,15 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
60
80
|
return await this.#reconcileBadges();
|
61
81
|
}
|
62
82
|
|
83
|
+
snoozeStarterBadge(): void {
|
84
|
+
this.#starterBadgeSnoozeCount.set(this.#starterBadgeSnoozeCount.get() + 1);
|
85
|
+
this.#starterBadgeLastSnoozedTimestamp.set(Date.now());
|
86
|
+
}
|
87
|
+
|
88
|
+
dismissStarterBadge(): void {
|
89
|
+
this.#starterBadgeDismissed.set(true);
|
90
|
+
}
|
91
|
+
|
63
92
|
recordAction(action: BadgeAction): void {
|
64
93
|
// `Common.ObjectWrapper.ObjectWrapper` does not allow passing unions to
|
65
94
|
// the `dispatchEventToListeners` and `action` in this case is a union.
|
@@ -70,7 +99,8 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
70
99
|
this.#badgeActionEventTarget.dispatchEventToListeners(action);
|
71
100
|
}
|
72
101
|
|
73
|
-
async #onTriggerBadge(badge: Badge): Promise<void> {
|
102
|
+
async #onTriggerBadge(badge: Badge, opts?: TriggerOptions): Promise<void> {
|
103
|
+
const triggerTime = Date.now();
|
74
104
|
let shouldAwardBadge = false;
|
75
105
|
// By default, we award non-starter badges directly when they are triggered.
|
76
106
|
if (!badge.isStarterBadge) {
|
@@ -79,7 +109,8 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
79
109
|
const gdpProfile = await Host.GdpClient.GdpClient.instance().getProfile();
|
80
110
|
const receiveBadgesSettingEnabled = Boolean(this.#receiveBadgesSetting.get());
|
81
111
|
// If there is a GDP profile and the user has enabled receiving badges, we award the starter badge as well.
|
82
|
-
if (gdpProfile && receiveBadgesSettingEnabled)
|
112
|
+
if (gdpProfile && receiveBadgesSettingEnabled && !this.#isStarterBadgeDismissed() &&
|
113
|
+
!this.#isStarterBadgeSnoozed()) {
|
83
114
|
shouldAwardBadge = true;
|
84
115
|
}
|
85
116
|
}
|
@@ -92,7 +123,12 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
92
123
|
}
|
93
124
|
}
|
94
125
|
|
95
|
-
|
126
|
+
const timeElapsedAfterTriggerCall = Date.now() - triggerTime;
|
127
|
+
// We want to add exactly 1.5 second delay between the trigger action & the notification.
|
128
|
+
const delay = opts?.immediate ? 0 : Math.max(DELAY_BEFORE_TRIGGER - timeElapsedAfterTriggerCall, 0);
|
129
|
+
setTimeout(() => {
|
130
|
+
this.dispatchEventToListeners(Events.BADGE_TRIGGERED, badge);
|
131
|
+
}, delay);
|
96
132
|
}
|
97
133
|
|
98
134
|
#deactivateAllBadges(): void {
|
@@ -101,7 +137,17 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
101
137
|
});
|
102
138
|
}
|
103
139
|
|
104
|
-
|
140
|
+
#isStarterBadgeDismissed(): boolean {
|
141
|
+
return this.#starterBadgeDismissed.get();
|
142
|
+
}
|
143
|
+
|
144
|
+
#isStarterBadgeSnoozed(): boolean {
|
145
|
+
const snoozeCount = this.#starterBadgeSnoozeCount.get();
|
146
|
+
const lastSnoozed = this.#starterBadgeLastSnoozedTimestamp.get();
|
147
|
+
const snoozedRecently = (Date.now() - lastSnoozed) < SNOOZE_TIME_MS;
|
148
|
+
return snoozeCount >= MAX_SNOOZE_COUNT || snoozedRecently;
|
149
|
+
}
|
150
|
+
|
105
151
|
async #reconcileBadges(): Promise<void> {
|
106
152
|
const syncInfo = await new Promise<Host.InspectorFrontendHostAPI.SyncInformation>(
|
107
153
|
resolve => Host.InspectorFrontendHost.InspectorFrontendHostInstance.getSyncInformation(resolve));
|
@@ -111,6 +157,12 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
111
157
|
return;
|
112
158
|
}
|
113
159
|
|
160
|
+
if (!Host.GdpClient.isGdpProfilesAvailable() ||
|
161
|
+
Host.GdpClient.getGdpProfilesEnterprisePolicy() !== Root.Runtime.GdpProfilesEnterprisePolicyValue.ENABLED) {
|
162
|
+
this.#deactivateAllBadges();
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
114
166
|
const [gdpProfile, isEligibleToCreateProfile] = await Promise.all([
|
115
167
|
Host.GdpClient.GdpClient.instance().getProfile(),
|
116
168
|
Host.GdpClient.GdpClient.instance().isEligibleToCreateProfile(),
|
@@ -148,7 +200,8 @@ export class UserBadges extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
148
200
|
continue;
|
149
201
|
}
|
150
202
|
|
151
|
-
const shouldActivateStarterBadge = badge.isStarterBadge && isEligibleToCreateProfile
|
203
|
+
const shouldActivateStarterBadge = badge.isStarterBadge && isEligibleToCreateProfile &&
|
204
|
+
!this.#isStarterBadgeDismissed() && !this.#isStarterBadgeSnoozed();
|
152
205
|
const shouldActivateActivityBasedBadge =
|
153
206
|
!badge.isStarterBadge && Boolean(gdpProfile) && receiveBadgesSettingEnabled;
|
154
207
|
if (shouldActivateStarterBadge || shouldActivateActivityBasedBadge) {
|
@@ -7,8 +7,6 @@ import * as FormatterActions from '../../entrypoints/formatter_worker/FormatterA
|
|
7
7
|
|
8
8
|
export {DefinitionKind, type ScopeTreeNode} from '../../entrypoints/formatter_worker/FormatterActions.js';
|
9
9
|
|
10
|
-
const MAX_WORKERS = Math.max(2, navigator.hardwareConcurrency - 1);
|
11
|
-
|
12
10
|
let formatterWorkerPoolInstance: FormatterWorkerPool;
|
13
11
|
|
14
12
|
export class FormatterWorkerPool {
|
@@ -37,12 +35,14 @@ export class FormatterWorkerPool {
|
|
37
35
|
}
|
38
36
|
|
39
37
|
private processNextTask(): void {
|
38
|
+
const maxWorkers = Math.max(2, navigator.hardwareConcurrency - 1);
|
39
|
+
|
40
40
|
if (!this.taskQueue.length) {
|
41
41
|
return;
|
42
42
|
}
|
43
43
|
|
44
44
|
let freeWorker = [...this.workerTasks.keys()].find(worker => !this.workerTasks.get(worker));
|
45
|
-
if (!freeWorker && this.workerTasks.size <
|
45
|
+
if (!freeWorker && this.workerTasks.size < maxWorkers) {
|
46
46
|
freeWorker = this.createWorker();
|
47
47
|
}
|
48
48
|
if (!freeWorker) {
|
@@ -31,7 +31,7 @@ This folder contains the new trace engine that was first implemented for the Per
|
|
31
31
|
│
|
32
32
|
│
|
33
33
|
┌──────────────────▼─────────────────┐
|
34
|
-
│const data = model.parsedTrace()│
|
34
|
+
│const data = model.parsedTrace() │
|
35
35
|
└────────────────────────────────────┘
|
36
36
|
```
|
37
37
|
|
@@ -98,3 +98,30 @@ The object returned from `parsedTrace()` is an object of key-value pairs where e
|
|
98
98
|
// and so on for each enabled Handler
|
99
99
|
}
|
100
100
|
```
|
101
|
+
|
102
|
+
## Pairing begin & end events
|
103
|
+
|
104
|
+
Note: this detail is not useful if you are using the Trace Engine, but it is if you are working on it.
|
105
|
+
|
106
|
+
Trace events are often emitted as `begin` & `end` events to represent the lifetime of the event. These have the `b` and `e` phase.
|
107
|
+
|
108
|
+
When we find these events, we often try to pair them into what we call a "Synthetic" event. This is a trace event that doesn't exist in the raw trace, but one that we create to make it easier to deal with. This means we can represent a `b` & `e` pair as a single event rather than pass two events around.
|
109
|
+
|
110
|
+
When we pair these events, we look for an ID. Some events have a top level `id` field, others have a nested `id2.local` field (this is for various historical reasons). `getSyntheticId` in `Trace.Helpers` takes care of this, and tries to account for potential collisions by appending a few other pieces of metadata onto the ID.
|
111
|
+
|
112
|
+
This approach worked well until July 2025 when an upstream change in Perfetto [https://chromium.googlesource.com/external/github.com/google/perfetto.git/+/aef636b27ffbf379fd722e7798030da2c5c4d699] meant that Perfetto will try to minimise the amount of unique IDs it uses. A consequence of this change is that IDs can be reused by consecutive, non-overlapping events.
|
113
|
+
|
114
|
+
For example, take the following set of events:
|
115
|
+
|
116
|
+
```
|
117
|
+
=== E1 === === E2 ===
|
118
|
+
```
|
119
|
+
|
120
|
+
These could have the same ID, because they do not overlap.
|
121
|
+
|
122
|
+
Whereas these events will have different IDs because otherwise you cannot reliably pair them up:
|
123
|
+
|
124
|
+
```
|
125
|
+
=== E1 ===
|
126
|
+
=== E2 ===
|
127
|
+
```
|
@@ -223,9 +223,9 @@ export async function finalize(): Promise<void> {
|
|
223
223
|
|
224
224
|
export function data(): UserTimingsData {
|
225
225
|
return {
|
226
|
+
consoleTimings: syntheticEvents.filter(e => e.cat === 'blink.console') as Types.Events.SyntheticConsoleTimingPair[],
|
226
227
|
performanceMeasures: syntheticEvents.filter(e => e.cat === 'blink.user_timing') as
|
227
228
|
Types.Events.SyntheticUserTimingPair[],
|
228
|
-
consoleTimings: syntheticEvents.filter(e => e.cat === 'blink.console') as Types.Events.SyntheticConsoleTimingPair[],
|
229
229
|
performanceMarks: performanceMarkEvents,
|
230
230
|
timestampEvents,
|
231
231
|
measureTraceByTraceId,
|
@@ -12,6 +12,7 @@ import {SyntheticEventsManager} from './SyntheticEvents.js';
|
|
12
12
|
import {eventTimingsMicroSeconds} from './Timing.js';
|
13
13
|
|
14
14
|
interface MatchingPairableAsyncEvents {
|
15
|
+
syntheticId: string;
|
15
16
|
begin: Types.Events.PairableAsyncBegin|null;
|
16
17
|
end: Types.Events.PairableAsyncEnd|null;
|
17
18
|
instant?: Types.Events.PairableAsyncInstant[];
|
@@ -290,62 +291,113 @@ export function makeProfileCall(
|
|
290
291
|
}
|
291
292
|
|
292
293
|
/**
|
293
|
-
* Matches beginning events with PairableAsyncEnd and PairableAsyncInstant
|
294
|
-
* if provided
|
295
|
-
* account for that.
|
294
|
+
* Matches beginning events with PairableAsyncEnd and PairableAsyncInstant
|
295
|
+
* if provided. Traces may contain multiple instant events so we need to
|
296
|
+
* account for that. Additionally we have seen cases where we might only have a
|
297
|
+
* begin event & instant event(s), with no end event. So we account for that
|
298
|
+
* situation also.
|
296
299
|
*
|
297
|
-
*
|
300
|
+
* You might also like to read the models/trace/README.md which has some
|
301
|
+
* documentation on trace IDs. This is important as Perfetto will reuse trace
|
302
|
+
* IDs when emitting events (if they do not overlap). This means it's not as
|
303
|
+
* simple as grouping events by IDs. Instead, we group begin & instant events
|
304
|
+
* by ID as we find them. When we find end events, we then pop any matching
|
305
|
+
* begin/instant events off the stack and group those. That way, if we meet the
|
306
|
+
* same ID later on it doesn't cause us collisions.
|
307
|
+
*
|
308
|
+
* @returns An array of all the matched event groups, along with their ID. Note
|
309
|
+
* that two event groups can have the same ID if they were non-overlapping
|
310
|
+
* events. You cannot rely on ID being unique across a trace. The returned set
|
311
|
+
* of groups are NOT SORTED in any order.
|
298
312
|
*/
|
299
|
-
|
313
|
+
function matchEvents(unpairedEvents: Types.Events.PairableAsync[]): MatchingPairableAsyncEvents[] {
|
314
|
+
sortTraceEventsInPlace(unpairedEvents);
|
300
315
|
// map to store begin and end of the event
|
301
|
-
const
|
316
|
+
const matches: MatchingPairableAsyncEvents[] = [];
|
302
317
|
|
303
|
-
|
318
|
+
const beginEventsById = new Map<string, Types.Events.PairableAsyncBegin[]>();
|
319
|
+
const instantEventsById = new Map<string, Types.Events.PairableAsyncInstant[]>();
|
304
320
|
for (const event of unpairedEvents) {
|
305
|
-
const
|
306
|
-
if (
|
321
|
+
const id = getSyntheticId(event);
|
322
|
+
if (id === undefined) {
|
307
323
|
continue;
|
308
324
|
}
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
otherEventsWithID.end = event as Types.Events.PairableAsyncEnd;
|
324
|
-
} else if (isInstantEvent) {
|
325
|
-
if (!otherEventsWithID.instant) {
|
326
|
-
otherEventsWithID.instant = [];
|
325
|
+
if (Types.Events.isPairableAsyncBegin(event)) {
|
326
|
+
const existingEvents = beginEventsById.get(id) ?? [];
|
327
|
+
existingEvents.push(event);
|
328
|
+
beginEventsById.set(id, existingEvents);
|
329
|
+
} else if (Types.Events.isPairableAsyncInstant(event)) {
|
330
|
+
const existingEvents = instantEventsById.get(id) ?? [];
|
331
|
+
existingEvents.push(event);
|
332
|
+
instantEventsById.set(id, existingEvents);
|
333
|
+
} else if (Types.Events.isPairableAsyncEnd(event)) {
|
334
|
+
// Find matching begin event by ID
|
335
|
+
const beginEventsWithMatchingId = beginEventsById.get(id) ?? [];
|
336
|
+
const beginEvent = beginEventsWithMatchingId.pop();
|
337
|
+
if (!beginEvent) {
|
338
|
+
continue;
|
327
339
|
}
|
328
|
-
|
340
|
+
const instantEventsWithMatchingId = instantEventsById.get(id) ?? [];
|
341
|
+
// Find all instant events after the begin event ts.
|
342
|
+
const instantEventsForThisGroup: Types.Events.PairableAsyncInstant[] = [];
|
343
|
+
while (instantEventsWithMatchingId.length > 0) {
|
344
|
+
if (instantEventsWithMatchingId[0].ts >= beginEvent.ts) {
|
345
|
+
const event = instantEventsWithMatchingId.pop();
|
346
|
+
if (event) {
|
347
|
+
instantEventsForThisGroup.push(event);
|
348
|
+
}
|
349
|
+
} else {
|
350
|
+
break;
|
351
|
+
}
|
352
|
+
}
|
353
|
+
const matchingGroup: MatchingPairableAsyncEvents = {
|
354
|
+
begin: beginEvent,
|
355
|
+
end: event,
|
356
|
+
instant: instantEventsForThisGroup,
|
357
|
+
syntheticId: id,
|
358
|
+
};
|
359
|
+
matches.push(matchingGroup);
|
329
360
|
}
|
330
361
|
}
|
331
|
-
|
362
|
+
|
363
|
+
// At this point we know we have paired up all the Begin & End & Instant
|
364
|
+
// events. But it is possible to see only begin & instant events with the
|
365
|
+
// same ID, and no end event. So now we do a second pass through our begin
|
366
|
+
// events to find any that did not have an end event. If we find some
|
367
|
+
// instant events for the begin event, we create a new group.
|
368
|
+
// Also, because there were no end events, we know that the IDs will be
|
369
|
+
// unique now; e.g. each key in the map should have no more than one item in
|
370
|
+
// it.
|
371
|
+
for (const [id, beginEvents] of beginEventsById) {
|
372
|
+
const beginEvent = beginEvents.pop();
|
373
|
+
if (!beginEvent) {
|
374
|
+
continue;
|
375
|
+
}
|
376
|
+
const matchingInstantEvents = instantEventsById.get(id);
|
377
|
+
if (matchingInstantEvents?.length) {
|
378
|
+
matches.push({
|
379
|
+
syntheticId: id,
|
380
|
+
begin: beginEvent,
|
381
|
+
end: null,
|
382
|
+
instant: matchingInstantEvents,
|
383
|
+
});
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
return matches;
|
332
388
|
}
|
333
389
|
|
334
|
-
function getSyntheticId(event: Types.Events.PairableAsync): string|undefined {
|
390
|
+
export function getSyntheticId(event: Types.Events.PairableAsync): string|undefined {
|
335
391
|
const id = extractId(event);
|
336
392
|
return id && `${event.cat}:${id}:${event.name}`;
|
337
393
|
}
|
338
394
|
|
339
|
-
|
340
|
-
matchedPairs:
|
341
|
-
begin: Types.Events.PairableAsyncBegin | null,
|
342
|
-
end: Types.Events.PairableAsyncEnd | null,
|
343
|
-
instant?: Types.Events.PairableAsyncInstant[],
|
344
|
-
}>,
|
345
|
-
syntheticEventCallback?: (syntheticEvent: Types.Events.SyntheticEventPair<T>) => void,
|
395
|
+
function createSortedSyntheticEvents<T extends Types.Events.PairableAsync>(
|
396
|
+
matchedPairs: MatchingPairableAsyncEvents[],
|
346
397
|
): Array<Types.Events.SyntheticEventPair<T>> {
|
347
398
|
const syntheticEvents: Array<Types.Events.SyntheticEventPair<T>> = [];
|
348
|
-
for (const
|
399
|
+
for (const eventsTriplet of matchedPairs) {
|
400
|
+
const id = eventsTriplet.syntheticId;
|
349
401
|
const beginEvent = eventsTriplet.begin;
|
350
402
|
const endEvent = eventsTriplet.end;
|
351
403
|
const instantEvents = eventsTriplet.instant;
|
@@ -399,17 +451,21 @@ export function createSortedSyntheticEvents<T extends Types.Events.PairableAsync
|
|
399
451
|
// crbug.com/1472375
|
400
452
|
continue;
|
401
453
|
}
|
402
|
-
syntheticEventCallback?.(event);
|
403
454
|
syntheticEvents.push(event);
|
404
455
|
}
|
405
|
-
|
456
|
+
sortTraceEventsInPlace(syntheticEvents);
|
457
|
+
return syntheticEvents;
|
406
458
|
}
|
407
459
|
|
408
|
-
|
409
|
-
|
460
|
+
/**
|
461
|
+
* Groups up sets of async events into synthetic events.
|
462
|
+
* @param unpairedAsyncEvents the raw array of begin, end and async instant
|
463
|
+
* events. These MUST be sorted in timestamp ASC order.
|
464
|
+
*/
|
465
|
+
export function createMatchedSortedSyntheticEvents<T extends Types.Events.PairableAsync>(unpairedAsyncEvents: T[]):
|
410
466
|
Array<Types.Events.SyntheticEventPair<T>> {
|
411
467
|
const matchedPairs = matchEvents(unpairedAsyncEvents);
|
412
|
-
const syntheticEvents = createSortedSyntheticEvents<T>(matchedPairs
|
468
|
+
const syntheticEvents = createSortedSyntheticEvents<T>(matchedPairs);
|
413
469
|
return syntheticEvents;
|
414
470
|
}
|
415
471
|
|
@@ -1358,6 +1358,15 @@ export interface PairableAsyncInstant extends PairableAsync {
|
|
1358
1358
|
export interface PairableAsyncEnd extends PairableAsync {
|
1359
1359
|
ph: Phase.ASYNC_NESTABLE_END;
|
1360
1360
|
}
|
1361
|
+
export function isPairableAsyncBegin(e: Event): e is PairableAsyncBegin {
|
1362
|
+
return e.ph === Phase.ASYNC_NESTABLE_START;
|
1363
|
+
}
|
1364
|
+
export function isPairableAsyncEnd(e: Event): e is PairableAsyncEnd {
|
1365
|
+
return e.ph === Phase.ASYNC_NESTABLE_END;
|
1366
|
+
}
|
1367
|
+
export function isPairableAsyncInstant(e: Event): e is PairableAsyncInstant {
|
1368
|
+
return e.ph === Phase.ASYNC_NESTABLE_INSTANT;
|
1369
|
+
}
|
1361
1370
|
|
1362
1371
|
export interface AnimationFrame extends PairableAsync {
|
1363
1372
|
name: Name.ANIMATION_FRAME;
|