@paulirish/trace_engine 0.0.4 → 0.0.6

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/trace.mjs CHANGED
@@ -17,6 +17,7 @@ var handlers_exports = {};
17
17
  __export(handlers_exports, {
18
18
  Migration: () => Migration_exports,
19
19
  ModelHandlers: () => ModelHandlers_exports,
20
+ Threads: () => Threads_exports,
20
21
  Types: () => types_exports2
21
22
  });
22
23
 
@@ -385,7 +386,8 @@ __export(types_exports, {
385
386
  // front_end/models/trace/types/Configuration.ts
386
387
  var Configuration_exports = {};
387
388
  __export(Configuration_exports, {
388
- DEFAULT: () => DEFAULT
389
+ DEFAULT: () => DEFAULT,
390
+ configToCacheKey: () => configToCacheKey
389
391
  });
390
392
  var DEFAULT = {
391
393
  settings: {},
@@ -398,6 +400,12 @@ var DEFAULT = {
398
400
  pauseDuration: 1
399
401
  }
400
402
  };
403
+ function configToCacheKey(config2) {
404
+ return [
405
+ `experiments.timelineShowAllEvents:${config2.experiments.timelineShowAllEvents}`,
406
+ `experiments.timelineV8RuntimeCallStats:${config2.experiments.timelineV8RuntimeCallStats}`
407
+ ].join("-");
408
+ }
401
409
 
402
410
  // front_end/models/trace/types/File.ts
403
411
  var File_exports = {};
@@ -459,6 +467,7 @@ __export(TraceEvents_exports, {
459
467
  isSyntheticInteractionEvent: () => isSyntheticInteractionEvent,
460
468
  isSyntheticLayoutShift: () => isSyntheticLayoutShift,
461
469
  isSyntheticNetworkRequestDetailsEvent: () => isSyntheticNetworkRequestDetailsEvent,
470
+ isSyntheticTraceEventCpuProfile: () => isSyntheticTraceEventCpuProfile,
462
471
  isSyntheticUserTimingTraceEvent: () => isSyntheticUserTimingTraceEvent,
463
472
  isThreadName: () => isThreadName,
464
473
  isTraceEventAnimation: () => isTraceEventAnimation,
@@ -712,6 +721,9 @@ function isTraceEventGPUTask(traceEventData) {
712
721
  function isTraceEventProfile(traceEventData) {
713
722
  return traceEventData.name === "Profile";
714
723
  }
724
+ function isSyntheticTraceEventCpuProfile(traceEventData) {
725
+ return traceEventData.name === "CpuProfile";
726
+ }
715
727
  function isTraceEventProfileChunk(traceEventData) {
716
728
  return traceEventData.name === "ProfileChunk";
717
729
  }
@@ -1051,25 +1063,138 @@ function data() {
1051
1063
  };
1052
1064
  }
1053
1065
 
1066
+ // front_end/models/trace/handlers/AuctionWorkletsHandler.ts
1067
+ var AuctionWorkletsHandler_exports = {};
1068
+ __export(AuctionWorkletsHandler_exports, {
1069
+ data: () => data2,
1070
+ finalize: () => finalize2,
1071
+ handleEvent: () => handleEvent2,
1072
+ reset: () => reset2
1073
+ });
1074
+ var runningInProcessEvents = /* @__PURE__ */ new Map();
1075
+ var doneWithProcessEvents = /* @__PURE__ */ new Map();
1076
+ var createdSyntheticEvents = /* @__PURE__ */ new Map();
1077
+ var utilityThreads = /* @__PURE__ */ new Map();
1078
+ var v8HelperThreads = /* @__PURE__ */ new Map();
1079
+ function reset2() {
1080
+ runningInProcessEvents.clear();
1081
+ doneWithProcessEvents.clear();
1082
+ createdSyntheticEvents.clear();
1083
+ utilityThreads.clear();
1084
+ v8HelperThreads.clear();
1085
+ }
1086
+ function handleEvent2(event) {
1087
+ if (TraceEvents_exports.isTraceEventAuctionWorkletRunningInProcess(event)) {
1088
+ runningInProcessEvents.set(event.args.data.pid, event);
1089
+ return;
1090
+ }
1091
+ if (TraceEvents_exports.isTraceEventAuctionWorkletDoneWithProcess(event)) {
1092
+ doneWithProcessEvents.set(event.args.data.pid, event);
1093
+ return;
1094
+ }
1095
+ if (TraceEvents_exports.isThreadName(event)) {
1096
+ if (event.args.name === "auction_worklet.CrUtilityMain") {
1097
+ utilityThreads.set(event.pid, event);
1098
+ return;
1099
+ }
1100
+ if (event.args.name === "AuctionV8HelperThread") {
1101
+ v8HelperThreads.set(event.pid, event);
1102
+ }
1103
+ }
1104
+ }
1105
+ function workletType(input) {
1106
+ switch (input) {
1107
+ case "seller":
1108
+ return TraceEvents_exports.AuctionWorkletType.SELLER;
1109
+ case "bidder":
1110
+ return TraceEvents_exports.AuctionWorkletType.BIDDER;
1111
+ default:
1112
+ return TraceEvents_exports.AuctionWorkletType.UNKNOWN;
1113
+ }
1114
+ }
1115
+ function makeSyntheticEventBase(event) {
1116
+ return {
1117
+ name: "SyntheticAuctionWorkletEvent",
1118
+ s: TraceEvents_exports.TraceEventScope.THREAD,
1119
+ cat: event.cat,
1120
+ tid: event.tid,
1121
+ ts: event.ts,
1122
+ ph: TraceEvents_exports.Phase.INSTANT,
1123
+ pid: event.args.data.pid,
1124
+ host: event.args.data.host,
1125
+ target: event.args.data.target,
1126
+ type: workletType(event.args.data.type)
1127
+ };
1128
+ }
1129
+ async function finalize2() {
1130
+ for (const [pid, utilityThreadNameEvent] of utilityThreads) {
1131
+ const v8HelperEvent = v8HelperThreads.get(pid);
1132
+ if (!v8HelperEvent) {
1133
+ continue;
1134
+ }
1135
+ const runningEvent = runningInProcessEvents.get(pid);
1136
+ const doneWithEvent = doneWithProcessEvents.get(pid);
1137
+ let syntheticEvent = null;
1138
+ if (runningEvent) {
1139
+ syntheticEvent = {
1140
+ ...makeSyntheticEventBase(runningEvent),
1141
+ args: {
1142
+ data: {
1143
+ runningInProcessEvent: runningEvent,
1144
+ utilityThread: utilityThreadNameEvent,
1145
+ v8HelperThread: v8HelperEvent
1146
+ }
1147
+ }
1148
+ };
1149
+ if (doneWithEvent) {
1150
+ syntheticEvent.args.data.doneWithProcessEvent = doneWithEvent;
1151
+ }
1152
+ } else if (doneWithEvent) {
1153
+ syntheticEvent = {
1154
+ ...makeSyntheticEventBase(doneWithEvent),
1155
+ args: {
1156
+ data: {
1157
+ doneWithProcessEvent: doneWithEvent,
1158
+ utilityThread: utilityThreadNameEvent,
1159
+ v8HelperThread: v8HelperEvent
1160
+ }
1161
+ }
1162
+ };
1163
+ if (runningEvent) {
1164
+ syntheticEvent.args.data.runningInProcessEvent = runningEvent;
1165
+ }
1166
+ }
1167
+ if (syntheticEvent === null) {
1168
+ continue;
1169
+ }
1170
+ createdSyntheticEvents.set(pid, syntheticEvent);
1171
+ }
1172
+ }
1173
+ function data2() {
1174
+ return {
1175
+ worklets: new Map(createdSyntheticEvents)
1176
+ };
1177
+ }
1178
+
1054
1179
  // front_end/models/trace/handlers/GPUHandler.ts
1055
1180
  var GPUHandler_exports = {};
1056
1181
  __export(GPUHandler_exports, {
1057
- data: () => data3,
1182
+ data: () => data4,
1058
1183
  deps: () => deps,
1059
- finalize: () => finalize3,
1060
- handleEvent: () => handleEvent3,
1184
+ finalize: () => finalize4,
1185
+ handleEvent: () => handleEvent4,
1061
1186
  initialize: () => initialize2,
1062
- reset: () => reset3
1187
+ reset: () => reset4
1063
1188
  });
1064
1189
 
1065
1190
  // front_end/models/trace/handlers/MetaHandler.ts
1066
1191
  var MetaHandler_exports = {};
1067
1192
  __export(MetaHandler_exports, {
1068
- data: () => data2,
1069
- finalize: () => finalize2,
1070
- handleEvent: () => handleEvent2,
1193
+ data: () => data3,
1194
+ finalize: () => finalize3,
1195
+ handleEvent: () => handleEvent3,
1071
1196
  initialize: () => initialize,
1072
- reset: () => reset2
1197
+ reset: () => reset3
1073
1198
  });
1074
1199
  var rendererProcessesByFrameId = /* @__PURE__ */ new Map();
1075
1200
  var mainFrameId = "";
@@ -1098,7 +1223,7 @@ var eventPhasesOfInterestForTraceBounds = /* @__PURE__ */ new Set([
1098
1223
  TraceEvents_exports.Phase.INSTANT
1099
1224
  ]);
1100
1225
  var handlerState2 = 1 /* UNINITIALIZED */;
1101
- function reset2() {
1226
+ function reset3() {
1102
1227
  navigationsByFrameId.clear();
1103
1228
  navigationsByNavigationId.clear();
1104
1229
  mainFrameNavigations.length = 0;
@@ -1143,7 +1268,7 @@ function updateRendererProcessByFrame(event, frame) {
1143
1268
  }
1144
1269
  });
1145
1270
  }
1146
- function handleEvent2(event) {
1271
+ function handleEvent3(event) {
1147
1272
  if (handlerState2 !== 2 /* INITIALIZED */) {
1148
1273
  throw new Error("Meta Handler is not initialized");
1149
1274
  }
@@ -1233,7 +1358,7 @@ function handleEvent2(event) {
1233
1358
  return;
1234
1359
  }
1235
1360
  }
1236
- async function finalize2() {
1361
+ async function finalize3() {
1237
1362
  if (handlerState2 !== 2 /* INITIALIZED */) {
1238
1363
  throw new Error("Handler is not initialized");
1239
1364
  }
@@ -1269,7 +1394,7 @@ async function finalize2() {
1269
1394
  }
1270
1395
  handlerState2 = 3 /* FINALIZED */;
1271
1396
  }
1272
- function data2() {
1397
+ function data3() {
1273
1398
  if (handlerState2 !== 3 /* FINALIZED */) {
1274
1399
  throw new Error("Meta Handler is not finalized");
1275
1400
  }
@@ -1297,7 +1422,8 @@ var helpers_exports = {};
1297
1422
  __export(helpers_exports, {
1298
1423
  SamplesIntegrator: () => SamplesIntegrator_exports,
1299
1424
  Timing: () => Timing_exports3,
1300
- Trace: () => Trace_exports
1425
+ Trace: () => Trace_exports,
1426
+ TreeHelpers: () => TreeHelpers_exports
1301
1427
  });
1302
1428
 
1303
1429
  // front_end/models/trace/helpers/SamplesIntegrator.ts
@@ -1320,7 +1446,9 @@ __export(Timing_exports3, {
1320
1446
  secondsToMicroseconds: () => secondsToMicroseconds,
1321
1447
  secondsToMilliseconds: () => secondsToMilliseconds,
1322
1448
  timeStampForEventAdjustedByClosestNavigation: () => timeStampForEventAdjustedByClosestNavigation,
1323
- traceBoundsMilliseconds: () => traceBoundsMilliseconds
1449
+ traceWindowFromMilliSeconds: () => traceWindowFromMilliSeconds,
1450
+ traceWindowMilliSeconds: () => traceWindowMilliSeconds,
1451
+ traceWindowMillisecondsToMicroSeconds: () => traceWindowMillisecondsToMicroSeconds
1324
1452
  });
1325
1453
 
1326
1454
  // front_end/models/trace/helpers/Trace.ts
@@ -1331,6 +1459,7 @@ __export(Trace_exports, {
1331
1459
  extractId: () => extractId,
1332
1460
  extractOriginFromTrace: () => extractOriginFromTrace,
1333
1461
  getNavigationForTraceEvent: () => getNavigationForTraceEvent,
1462
+ makeProfileCall: () => makeProfileCall,
1334
1463
  mergeEventsInOrder: () => mergeEventsInOrder,
1335
1464
  sortTraceEventsInPlace: () => sortTraceEventsInPlace
1336
1465
  });
@@ -1436,6 +1565,21 @@ function activeURLForFrameAtTime(frameId, time, rendererProcessesByFrame) {
1436
1565
  }
1437
1566
  return null;
1438
1567
  }
1568
+ function makeProfileCall(node, ts, pid, tid) {
1569
+ return {
1570
+ cat: "",
1571
+ name: "ProfileCall",
1572
+ nodeId: node.id,
1573
+ args: {},
1574
+ ph: TraceEvents_exports.Phase.COMPLETE,
1575
+ pid,
1576
+ tid,
1577
+ ts,
1578
+ dur: Timing_exports2.MicroSeconds(0),
1579
+ selfTime: Timing_exports2.MicroSeconds(0),
1580
+ callFrame: node.callFrame
1581
+ };
1582
+ }
1439
1583
 
1440
1584
  // front_end/models/trace/helpers/Timing.ts
1441
1585
  var millisecondsToMicroseconds = (value) => Timing_exports2.MicroSeconds(value * 1e3);
@@ -1545,13 +1689,28 @@ function eventTimingsSeconds(event) {
1545
1689
  selfTime: microSecondsToSeconds(microTimes.selfTime)
1546
1690
  };
1547
1691
  }
1548
- function traceBoundsMilliseconds(bounds) {
1692
+ function traceWindowMilliSeconds(bounds) {
1549
1693
  return {
1550
1694
  min: microSecondsToMilliseconds(bounds.min),
1551
1695
  max: microSecondsToMilliseconds(bounds.max),
1552
1696
  range: microSecondsToMilliseconds(bounds.range)
1553
1697
  };
1554
1698
  }
1699
+ function traceWindowMillisecondsToMicroSeconds(bounds) {
1700
+ return {
1701
+ min: millisecondsToMicroseconds(bounds.min),
1702
+ max: millisecondsToMicroseconds(bounds.max),
1703
+ range: millisecondsToMicroseconds(bounds.range)
1704
+ };
1705
+ }
1706
+ function traceWindowFromMilliSeconds(min, max) {
1707
+ const traceWindow = {
1708
+ min: millisecondsToMicroseconds(min),
1709
+ max: millisecondsToMicroseconds(max),
1710
+ range: millisecondsToMicroseconds(Timing_exports2.MilliSeconds(max - min))
1711
+ };
1712
+ return traceWindow;
1713
+ }
1555
1714
 
1556
1715
  // front_end/models/trace/helpers/SamplesIntegrator.ts
1557
1716
  var SamplesIntegrator = class {
@@ -1562,6 +1721,7 @@ var SamplesIntegrator = class {
1562
1721
  #lockedJsStackDepth = [];
1563
1722
  #fakeJSInvocation = false;
1564
1723
  #profileModel;
1724
+ #nodeForGC = /* @__PURE__ */ new Map();
1565
1725
  #engineConfig;
1566
1726
  constructor(profileModel, pid, tid, configuration) {
1567
1727
  this.#profileModel = profileModel;
@@ -1650,26 +1810,39 @@ var SamplesIntegrator = class {
1650
1810
  return [];
1651
1811
  }
1652
1812
  const calls = [];
1813
+ let prevNode;
1653
1814
  for (let i = 0; i < samples.length; i++) {
1654
1815
  const node = this.#profileModel.nodeByIndex(i);
1655
1816
  const timestamp = millisecondsToMicroseconds(Timing_exports2.MilliSeconds(timestamps[i]));
1656
1817
  if (!node) {
1657
1818
  continue;
1658
1819
  }
1659
- const call = SamplesIntegrator.makeProfileCall(node, timestamp, this.#processId, this.#threadId);
1820
+ const call = makeProfileCall(node, timestamp, this.#processId, this.#threadId);
1660
1821
  calls.push(call);
1822
+ if (node.id === this.#profileModel.gcNode?.id && prevNode) {
1823
+ this.#nodeForGC.set(call, prevNode);
1824
+ continue;
1825
+ }
1826
+ prevNode = node;
1661
1827
  }
1662
1828
  return calls;
1663
1829
  }
1664
1830
  #getStackTraceFromProfileCall(profileCall) {
1665
1831
  let node = this.#profileModel.nodeById(profileCall.nodeId);
1832
+ const isGarbageCollection = Boolean(node?.id === this.#profileModel.gcNode?.id);
1833
+ if (isGarbageCollection) {
1834
+ node = this.#nodeForGC.get(profileCall) || null;
1835
+ }
1666
1836
  if (!node) {
1667
1837
  return [];
1668
1838
  }
1669
- const callFrames = new Array(node.depth + 1);
1839
+ const callFrames = new Array(node.depth + 1 + Number(isGarbageCollection));
1670
1840
  let i = callFrames.length - 1;
1841
+ if (isGarbageCollection) {
1842
+ callFrames[i--] = profileCall;
1843
+ }
1671
1844
  while (node) {
1672
- callFrames[i--] = SamplesIntegrator.makeProfileCall(node, profileCall.ts, this.#processId, this.#threadId);
1845
+ callFrames[i--] = makeProfileCall(node, profileCall.ts, this.#processId, this.#threadId);
1673
1846
  node = node.parent;
1674
1847
  }
1675
1848
  return callFrames;
@@ -1691,10 +1864,10 @@ var SamplesIntegrator = class {
1691
1864
  this.#truncateJSStack(i, event.ts);
1692
1865
  for (; i < stackTrace.length; ++i) {
1693
1866
  const call = stackTrace[i];
1694
- this.#currentJSStack.push(call);
1695
1867
  if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id || call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {
1696
1868
  continue;
1697
1869
  }
1870
+ this.#currentJSStack.push(call);
1698
1871
  this.#constructedProfileCalls.push(call);
1699
1872
  }
1700
1873
  }
@@ -1770,28 +1943,137 @@ var SamplesIntegrator = class {
1770
1943
  }
1771
1944
  stack.length = j;
1772
1945
  }
1773
- static makeProfileCall(node, ts, pid, tid) {
1774
- return {
1775
- cat: "",
1776
- name: "ProfileCall",
1777
- nodeId: node.id,
1778
- args: {},
1779
- ph: TraceEvents_exports.Phase.COMPLETE,
1780
- pid,
1781
- tid,
1782
- ts,
1783
- dur: Timing_exports2.MicroSeconds(0),
1784
- selfTime: Timing_exports2.MicroSeconds(0),
1785
- callFrame: node.callFrame
1786
- };
1787
- }
1788
1946
  };
1789
1947
 
1948
+ // front_end/models/trace/helpers/TreeHelpers.ts
1949
+ var TreeHelpers_exports = {};
1950
+ __export(TreeHelpers_exports, {
1951
+ makeEmptyTraceEntryNode: () => makeEmptyTraceEntryNode,
1952
+ makeEmptyTraceEntryTree: () => makeEmptyTraceEntryTree,
1953
+ makeTraceEntryNodeId: () => makeTraceEntryNodeId,
1954
+ treify: () => treify,
1955
+ walkEntireTree: () => walkEntireTree,
1956
+ walkTreeFromEntry: () => walkTreeFromEntry
1957
+ });
1958
+ var nodeIdCount = 0;
1959
+ var makeTraceEntryNodeId = () => ++nodeIdCount;
1960
+ var makeEmptyTraceEntryTree = () => ({
1961
+ nodes: /* @__PURE__ */ new Map(),
1962
+ roots: /* @__PURE__ */ new Set(),
1963
+ maxDepth: 0
1964
+ });
1965
+ var makeEmptyTraceEntryNode = (entry, id) => ({
1966
+ entry,
1967
+ id,
1968
+ parentId: null,
1969
+ children: /* @__PURE__ */ new Set(),
1970
+ depth: 0
1971
+ });
1972
+ var TraceEntryNodeIdTag = class {
1973
+ #tag;
1974
+ };
1975
+ function treify(entries, options) {
1976
+ const entryToNode3 = /* @__PURE__ */ new Map();
1977
+ const stack = [];
1978
+ nodeIdCount = -1;
1979
+ const tree = makeEmptyTraceEntryTree();
1980
+ for (let i = 0; i < entries.length; i++) {
1981
+ const event = entries[i];
1982
+ if (options && !options.filter.has(event.name)) {
1983
+ continue;
1984
+ }
1985
+ const duration = event.dur || 0;
1986
+ const nodeId = makeTraceEntryNodeId();
1987
+ const node = makeEmptyTraceEntryNode(event, nodeId);
1988
+ if (stack.length === 0) {
1989
+ tree.nodes.set(nodeId, node);
1990
+ tree.roots.add(node);
1991
+ event.selfTime = Timing_exports2.MicroSeconds(duration);
1992
+ stack.push(node);
1993
+ tree.maxDepth = Math.max(tree.maxDepth, stack.length);
1994
+ entryToNode3.set(event, node);
1995
+ continue;
1996
+ }
1997
+ const parentNode = stack.at(-1);
1998
+ if (parentNode === void 0) {
1999
+ throw new Error("Impossible: no parent node found in the stack");
2000
+ }
2001
+ const parentEvent = parentNode.entry;
2002
+ const begin = event.ts;
2003
+ const parentBegin = parentEvent.ts;
2004
+ const parentDuration = parentEvent.dur || 0;
2005
+ const end = begin + duration;
2006
+ const parentEnd = parentBegin + parentDuration;
2007
+ const startsBeforeParent = begin < parentBegin;
2008
+ if (startsBeforeParent) {
2009
+ throw new Error("Impossible: current event starts before the parent event");
2010
+ }
2011
+ const startsAfterParent = begin >= parentEnd;
2012
+ if (startsAfterParent) {
2013
+ stack.pop();
2014
+ i--;
2015
+ nodeIdCount--;
2016
+ continue;
2017
+ }
2018
+ const endsAfterParent = end > parentEnd;
2019
+ if (endsAfterParent) {
2020
+ continue;
2021
+ }
2022
+ tree.nodes.set(nodeId, node);
2023
+ node.depth = stack.length;
2024
+ node.parentId = parentNode.id;
2025
+ parentNode.children.add(node);
2026
+ event.selfTime = Timing_exports2.MicroSeconds(duration);
2027
+ if (parentEvent.selfTime !== void 0) {
2028
+ parentEvent.selfTime = Timing_exports2.MicroSeconds(parentEvent.selfTime - (event.dur || 0));
2029
+ }
2030
+ stack.push(node);
2031
+ tree.maxDepth = Math.max(tree.maxDepth, stack.length);
2032
+ entryToNode3.set(event, node);
2033
+ }
2034
+ return { tree, entryToNode: entryToNode3 };
2035
+ }
2036
+ function walkTreeFromEntry(entryToNode3, rootEntry, onEntryStart, onEntryEnd) {
2037
+ const startNode = entryToNode3.get(rootEntry);
2038
+ if (!startNode) {
2039
+ return;
2040
+ }
2041
+ walkTreeByNode(entryToNode3, startNode, onEntryStart, onEntryEnd);
2042
+ }
2043
+ function walkEntireTree(entryToNode3, tree, onEntryStart, onEntryEnd, traceWindowToInclude) {
2044
+ for (const rootNode of tree.roots) {
2045
+ walkTreeByNode(entryToNode3, rootNode, onEntryStart, onEntryEnd, traceWindowToInclude);
2046
+ }
2047
+ }
2048
+ function walkTreeByNode(entryToNode3, rootNode, onEntryStart, onEntryEnd, traceWindowToInclude) {
2049
+ if (traceWindowToInclude && !treeNodeIsInWindow(rootNode, traceWindowToInclude)) {
2050
+ return;
2051
+ }
2052
+ onEntryStart(rootNode.entry);
2053
+ for (const child of rootNode.children) {
2054
+ walkTreeByNode(entryToNode3, child, onEntryStart, onEntryEnd, traceWindowToInclude);
2055
+ }
2056
+ onEntryEnd(rootNode.entry);
2057
+ }
2058
+ function treeNodeIsInWindow(node, traceWindow) {
2059
+ const { startTime, endTime } = eventTimingsMicroSeconds(node.entry);
2060
+ if (startTime >= traceWindow.min && startTime < traceWindow.max) {
2061
+ return true;
2062
+ }
2063
+ if (endTime > traceWindow.min && endTime <= traceWindow.max) {
2064
+ return true;
2065
+ }
2066
+ if (startTime <= traceWindow.min && endTime >= traceWindow.max) {
2067
+ return true;
2068
+ }
2069
+ return false;
2070
+ }
2071
+
1790
2072
  // front_end/models/trace/handlers/GPUHandler.ts
1791
2073
  var handlerState3 = 1 /* UNINITIALIZED */;
1792
2074
  var eventsInProcessThread = /* @__PURE__ */ new Map();
1793
2075
  var mainGPUThreadTasks = [];
1794
- function reset3() {
2076
+ function reset4() {
1795
2077
  eventsInProcessThread.clear();
1796
2078
  mainGPUThreadTasks = [];
1797
2079
  handlerState3 = 1 /* UNINITIALIZED */;
@@ -1802,7 +2084,7 @@ function initialize2() {
1802
2084
  }
1803
2085
  handlerState3 = 2 /* INITIALIZED */;
1804
2086
  }
1805
- function handleEvent3(event) {
2087
+ function handleEvent4(event) {
1806
2088
  if (handlerState3 !== 2 /* INITIALIZED */) {
1807
2089
  throw new Error("GPU Handler is not initialized");
1808
2090
  }
@@ -1811,18 +2093,18 @@ function handleEvent3(event) {
1811
2093
  }
1812
2094
  Trace_exports.addEventToProcessThread(event, eventsInProcessThread);
1813
2095
  }
1814
- async function finalize3() {
2096
+ async function finalize4() {
1815
2097
  if (handlerState3 !== 2 /* INITIALIZED */) {
1816
2098
  throw new Error("GPU Handler is not initialized");
1817
2099
  }
1818
- const { gpuProcessId: gpuProcessId2, gpuThreadId: gpuThreadId2 } = data2();
2100
+ const { gpuProcessId: gpuProcessId2, gpuThreadId: gpuThreadId2 } = data3();
1819
2101
  const gpuThreadsForProcess = eventsInProcessThread.get(gpuProcessId2);
1820
2102
  if (gpuThreadsForProcess && gpuThreadId2) {
1821
2103
  mainGPUThreadTasks = gpuThreadsForProcess.get(gpuThreadId2) || [];
1822
2104
  }
1823
2105
  handlerState3 = 3 /* FINALIZED */;
1824
2106
  }
1825
- function data3() {
2107
+ function data4() {
1826
2108
  if (handlerState3 !== 3 /* FINALIZED */) {
1827
2109
  throw new Error("GPU Handler is not finalized");
1828
2110
  }
@@ -1840,13 +2122,13 @@ __export(LayoutShiftsHandler_exports, {
1840
2122
  LayoutShiftsThreshold: () => LayoutShiftsThreshold,
1841
2123
  MAX_CLUSTER_DURATION: () => MAX_CLUSTER_DURATION,
1842
2124
  MAX_SHIFT_TIME_DELTA: () => MAX_SHIFT_TIME_DELTA,
1843
- data: () => data6,
2125
+ data: () => data7,
1844
2126
  deps: () => deps4,
1845
- finalize: () => finalize6,
2127
+ finalize: () => finalize7,
1846
2128
  findNextScreenshotEventIndex: () => findNextScreenshotEventIndex,
1847
- handleEvent: () => handleEvent6,
2129
+ handleEvent: () => handleEvent7,
1848
2130
  initialize: () => initialize3,
1849
- reset: () => reset6,
2131
+ reset: () => reset7,
1850
2132
  stateForLayoutShiftScore: () => stateForLayoutShiftScore
1851
2133
  });
1852
2134
 
@@ -1856,14 +2138,14 @@ __export(PageLoadMetricsHandler_exports, {
1856
2138
  MarkerName: () => MarkerName,
1857
2139
  MetricName: () => MetricName,
1858
2140
  ScoreClassification: () => ScoreClassification,
1859
- data: () => data4,
2141
+ data: () => data5,
1860
2142
  deps: () => deps2,
1861
2143
  eventIsPageLoadEvent: () => eventIsPageLoadEvent,
1862
- finalize: () => finalize4,
2144
+ finalize: () => finalize5,
1863
2145
  getFrameIdForPageLoadEvent: () => getFrameIdForPageLoadEvent,
1864
- handleEvent: () => handleEvent4,
2146
+ handleEvent: () => handleEvent5,
1865
2147
  isTraceEventMarkerEvent: () => isTraceEventMarkerEvent,
1866
- reset: () => reset4,
2148
+ reset: () => reset5,
1867
2149
  scoreClassificationForDOMContentLoaded: () => scoreClassificationForDOMContentLoaded,
1868
2150
  scoreClassificationForFirstContentfulPaint: () => scoreClassificationForFirstContentfulPaint,
1869
2151
  scoreClassificationForLargestContentfulPaint: () => scoreClassificationForLargestContentfulPaint,
@@ -1872,7 +2154,7 @@ __export(PageLoadMetricsHandler_exports, {
1872
2154
  });
1873
2155
  var metricScoresByFrameId = /* @__PURE__ */ new Map();
1874
2156
  var allMarkerEvents = [];
1875
- function reset4() {
2157
+ function reset5() {
1876
2158
  metricScoresByFrameId.clear();
1877
2159
  pageLoadEventsArray = [];
1878
2160
  allMarkerEvents = [];
@@ -1899,7 +2181,7 @@ var pageLoadEventTypeGuards = [
1899
2181
  function eventIsPageLoadEvent(event) {
1900
2182
  return pageLoadEventTypeGuards.some((fn) => fn(event));
1901
2183
  }
1902
- function handleEvent4(event) {
2184
+ function handleEvent5(event) {
1903
2185
  if (!eventIsPageLoadEvent(event)) {
1904
2186
  return;
1905
2187
  }
@@ -1911,7 +2193,7 @@ function storePageLoadMetricAgainstNavigationId(navigation, event) {
1911
2193
  throw new Error("Navigation event unexpectedly had no navigation ID.");
1912
2194
  }
1913
2195
  const frameId = getFrameIdForPageLoadEvent(event);
1914
- const { rendererProcessesByFrame } = data2();
2196
+ const { rendererProcessesByFrame } = data3();
1915
2197
  const rendererProcessesInFrame = rendererProcessesByFrame.get(frameId);
1916
2198
  if (!rendererProcessesInFrame) {
1917
2199
  return;
@@ -1923,12 +2205,6 @@ function storePageLoadMetricAgainstNavigationId(navigation, event) {
1923
2205
  if (TraceEvents_exports.isTraceEventNavigationStart(event)) {
1924
2206
  return;
1925
2207
  }
1926
- const minTime = processData[0].window.min;
1927
- const maxTime = processData.at(-1)?.window.max || 0;
1928
- const eventBelongsToProcess = event.ts >= minTime && event.ts <= maxTime;
1929
- if (!eventBelongsToProcess) {
1930
- return;
1931
- }
1932
2208
  if (TraceEvents_exports.isTraceEventFirstContentfulPaint(event)) {
1933
2209
  const fcpTime = Timing_exports2.MicroSeconds(event.ts - navigation.ts);
1934
2210
  const score = Timing_exports3.formatMicrosecondsTime(fcpTime, {
@@ -2082,7 +2358,7 @@ function getNavigationForPageLoadEvent(event) {
2082
2358
  if (!navigationId) {
2083
2359
  throw new Error("Trace event unexpectedly had no navigation ID.");
2084
2360
  }
2085
- const { navigationsByNavigationId: navigationsByNavigationId2 } = data2();
2361
+ const { navigationsByNavigationId: navigationsByNavigationId2 } = data3();
2086
2362
  const navigation = navigationsByNavigationId2.get(navigationId);
2087
2363
  if (!navigation) {
2088
2364
  return null;
@@ -2091,7 +2367,7 @@ function getNavigationForPageLoadEvent(event) {
2091
2367
  }
2092
2368
  if (TraceEvents_exports.isTraceEventMarkDOMContent(event) || TraceEvents_exports.isTraceEventInteractiveTime(event) || TraceEvents_exports.isTraceEventLayoutShift(event) || TraceEvents_exports.isTraceEventMarkLoad(event)) {
2093
2369
  const frameId = getFrameIdForPageLoadEvent(event);
2094
- const { navigationsByFrameId: navigationsByFrameId2 } = data2();
2370
+ const { navigationsByFrameId: navigationsByFrameId2 } = data3();
2095
2371
  return Trace_exports.getNavigationForTraceEvent(event, frameId, navigationsByFrameId2);
2096
2372
  }
2097
2373
  if (TraceEvents_exports.isTraceEventNavigationStart(event)) {
@@ -2164,7 +2440,7 @@ function gatherFinalLCPEvents() {
2164
2440
  }
2165
2441
  return allFinalLCPEvents;
2166
2442
  }
2167
- async function finalize4() {
2443
+ async function finalize5() {
2168
2444
  pageLoadEventsArray.sort((a, b) => a.ts - b.ts);
2169
2445
  for (const pageLoadEvent of pageLoadEventsArray) {
2170
2446
  const navigation = getNavigationForPageLoadEvent(pageLoadEvent);
@@ -2173,12 +2449,12 @@ async function finalize4() {
2173
2449
  }
2174
2450
  }
2175
2451
  const allFinalLCPEvents = gatherFinalLCPEvents();
2176
- const mainFrame = data2().mainFrameId;
2452
+ const mainFrame = data3().mainFrameId;
2177
2453
  const allEventsButLCP = pageLoadEventsArray.filter((event) => !TraceEvents_exports.isTraceEventLargestContentfulPaintCandidate(event));
2178
2454
  const markerEvents = [...allFinalLCPEvents, ...allEventsButLCP].filter(isTraceEventMarkerEvent);
2179
2455
  allMarkerEvents = markerEvents.filter((event) => getFrameIdForPageLoadEvent(event) === mainFrame).sort((a, b) => a.ts - b.ts);
2180
2456
  }
2181
- function data4() {
2457
+ function data5() {
2182
2458
  return {
2183
2459
  metricScoresByFrameId: new Map(metricScoresByFrameId),
2184
2460
  allMarkerEvents: [...allMarkerEvents]
@@ -2209,32 +2485,32 @@ var MetricName = /* @__PURE__ */ ((MetricName2) => {
2209
2485
  // front_end/models/trace/handlers/ScreenshotsHandler.ts
2210
2486
  var ScreenshotsHandler_exports = {};
2211
2487
  __export(ScreenshotsHandler_exports, {
2212
- data: () => data5,
2488
+ data: () => data6,
2213
2489
  deps: () => deps3,
2214
- finalize: () => finalize5,
2215
- handleEvent: () => handleEvent5,
2216
- reset: () => reset5
2490
+ finalize: () => finalize6,
2491
+ handleEvent: () => handleEvent6,
2492
+ reset: () => reset6
2217
2493
  });
2218
2494
  var eventsInProcessThread2 = /* @__PURE__ */ new Map();
2219
2495
  var snapshots = [];
2220
- function reset5() {
2496
+ function reset6() {
2221
2497
  eventsInProcessThread2.clear();
2222
2498
  snapshots.length = 0;
2223
2499
  }
2224
- function handleEvent5(event) {
2225
- if (event.ph !== TraceEvents_exports.Phase.OBJECT_SNAPSHOT || event.name !== "Screenshot") {
2500
+ function handleEvent6(event) {
2501
+ if (event.name !== "Screenshot") {
2226
2502
  return;
2227
2503
  }
2228
2504
  Trace_exports.addEventToProcessThread(event, eventsInProcessThread2);
2229
2505
  }
2230
- async function finalize5() {
2231
- const { browserProcessId: browserProcessId2, browserThreadId: browserThreadId2 } = data2();
2506
+ async function finalize6() {
2507
+ const { browserProcessId: browserProcessId2, browserThreadId: browserThreadId2 } = data3();
2232
2508
  const browserThreads = eventsInProcessThread2.get(browserProcessId2);
2233
2509
  if (browserThreads) {
2234
2510
  snapshots = browserThreads.get(browserThreadId2) || [];
2235
2511
  }
2236
2512
  }
2237
- function data5() {
2513
+ function data6() {
2238
2514
  return [...snapshots];
2239
2515
  }
2240
2516
  function deps3() {
@@ -2259,7 +2535,7 @@ function initialize3() {
2259
2535
  }
2260
2536
  handlerState4 = 2 /* INITIALIZED */;
2261
2537
  }
2262
- function reset6() {
2538
+ function reset7() {
2263
2539
  handlerState4 = 1 /* UNINITIALIZED */;
2264
2540
  layoutShiftEvents.length = 0;
2265
2541
  layoutInvalidationEvents.length = 0;
@@ -2269,7 +2545,7 @@ function reset6() {
2269
2545
  scoreRecords.length = 0;
2270
2546
  clsWindowID = -1;
2271
2547
  }
2272
- function handleEvent6(event) {
2548
+ function handleEvent7(event) {
2273
2549
  if (handlerState4 !== 2 /* INITIALIZED */) {
2274
2550
  throw new Error("Handler is not initialized");
2275
2551
  }
@@ -2301,7 +2577,7 @@ function updateTraceWindowMax(traceWindow, newMax) {
2301
2577
  traceWindow.range = Timing_exports2.MicroSeconds(traceWindow.max - traceWindow.min);
2302
2578
  }
2303
2579
  function findNextScreenshotSource(timestamp) {
2304
- const screenshots = data5();
2580
+ const screenshots = data6();
2305
2581
  const screenshotIndex = findNextScreenshotEventIndex(screenshots, timestamp);
2306
2582
  if (!screenshotIndex) {
2307
2583
  return void 0;
@@ -2312,7 +2588,7 @@ function findNextScreenshotEventIndex(screenshots, timestamp) {
2312
2588
  return array_utilities_exports.nearestIndexFromBeginning(screenshots, (frame) => frame.ts > timestamp);
2313
2589
  }
2314
2590
  function buildScoreRecords() {
2315
- const { traceBounds: traceBounds2 } = data2();
2591
+ const { traceBounds: traceBounds2 } = data3();
2316
2592
  scoreRecords.push({ ts: traceBounds2.min, score: 0 });
2317
2593
  for (const cluster of clusters) {
2318
2594
  let clusterScore = 0;
@@ -2330,7 +2606,7 @@ function buildScoreRecords() {
2330
2606
  scoreRecords.push({ ts: cluster.clusterWindow.max, score: 0 });
2331
2607
  }
2332
2608
  }
2333
- async function finalize6() {
2609
+ async function finalize7() {
2334
2610
  layoutShiftEvents.sort((a, b) => a.ts - b.ts);
2335
2611
  prePaintEvents.sort((a, b) => a.ts - b.ts);
2336
2612
  layoutInvalidationEvents.sort((a, b) => a.ts - b.ts);
@@ -2339,7 +2615,7 @@ async function finalize6() {
2339
2615
  handlerState4 = 3 /* FINALIZED */;
2340
2616
  }
2341
2617
  async function buildLayoutShiftsClusters() {
2342
- const { navigationsByFrameId: navigationsByFrameId2, mainFrameId: mainFrameId2, traceBounds: traceBounds2 } = data2();
2618
+ const { navigationsByFrameId: navigationsByFrameId2, mainFrameId: mainFrameId2, traceBounds: traceBounds2 } = data3();
2343
2619
  const navigations = navigationsByFrameId2.get(mainFrameId2) || [];
2344
2620
  if (layoutShiftEvents.length === 0) {
2345
2621
  return;
@@ -2450,7 +2726,7 @@ async function buildLayoutShiftsClusters() {
2450
2726
  }
2451
2727
  }
2452
2728
  }
2453
- function data6() {
2729
+ function data7() {
2454
2730
  if (handlerState4 !== 3 /* FINALIZED */) {
2455
2731
  throw new Error("Layout Shifts Handler is not finalized");
2456
2732
  }
@@ -2487,34 +2763,34 @@ var LayoutShiftsThreshold = /* @__PURE__ */ ((LayoutShiftsThreshold2) => {
2487
2763
  // front_end/models/trace/handlers/MemoryHandler.ts
2488
2764
  var MemoryHandler_exports = {};
2489
2765
  __export(MemoryHandler_exports, {
2490
- data: () => data7,
2491
- handleEvent: () => handleEvent7,
2492
- reset: () => reset7
2766
+ data: () => data8,
2767
+ handleEvent: () => handleEvent8,
2768
+ reset: () => reset8
2493
2769
  });
2494
2770
  var updateCountersByProcess = /* @__PURE__ */ new Map();
2495
- function reset7() {
2771
+ function reset8() {
2496
2772
  updateCountersByProcess.clear();
2497
2773
  }
2498
- function handleEvent7(event) {
2774
+ function handleEvent8(event) {
2499
2775
  if (TraceEvents_exports.isTraceEventUpdateCounters(event)) {
2500
2776
  const countersForProcess = map_utilities_exports.getWithDefault(updateCountersByProcess, event.pid, () => []);
2501
2777
  countersForProcess.push(event);
2502
2778
  updateCountersByProcess.set(event.pid, countersForProcess);
2503
2779
  }
2504
2780
  }
2505
- function data7() {
2781
+ function data8() {
2506
2782
  return { updateCountersByProcess: new Map(updateCountersByProcess) };
2507
2783
  }
2508
2784
 
2509
2785
  // front_end/models/trace/handlers/NetworkRequestsHandler.ts
2510
2786
  var NetworkRequestsHandler_exports = {};
2511
2787
  __export(NetworkRequestsHandler_exports, {
2512
- data: () => data8,
2788
+ data: () => data9,
2513
2789
  deps: () => deps5,
2514
- finalize: () => finalize7,
2515
- handleEvent: () => handleEvent8,
2790
+ finalize: () => finalize8,
2791
+ handleEvent: () => handleEvent9,
2516
2792
  initialize: () => initialize4,
2517
- reset: () => reset8
2793
+ reset: () => reset9
2518
2794
  });
2519
2795
  var MILLISECONDS_TO_MICROSECONDS = 1e3;
2520
2796
  var SECONDS_TO_MICROSECONDS = 1e6;
@@ -2546,7 +2822,7 @@ function firstPositiveValueInList(entries) {
2546
2822
  return 0;
2547
2823
  }
2548
2824
  var handlerState5 = 1 /* UNINITIALIZED */;
2549
- function reset8() {
2825
+ function reset9() {
2550
2826
  requestsByOrigin.clear();
2551
2827
  requestMap.clear();
2552
2828
  requestsByTime.length = 0;
@@ -2555,7 +2831,7 @@ function reset8() {
2555
2831
  function initialize4() {
2556
2832
  handlerState5 = 2 /* INITIALIZED */;
2557
2833
  }
2558
- function handleEvent8(event) {
2834
+ function handleEvent9(event) {
2559
2835
  if (handlerState5 !== 2 /* INITIALIZED */) {
2560
2836
  throw new Error("Network Request handler is not initialized");
2561
2837
  }
@@ -2588,11 +2864,11 @@ function handleEvent8(event) {
2588
2864
  return;
2589
2865
  }
2590
2866
  }
2591
- async function finalize7() {
2867
+ async function finalize8() {
2592
2868
  if (handlerState5 !== 2 /* INITIALIZED */) {
2593
2869
  throw new Error("Network Request handler is not initialized");
2594
2870
  }
2595
- const { rendererProcessesByFrame } = data2();
2871
+ const { rendererProcessesByFrame } = data3();
2596
2872
  for (const [requestId, request] of requestMap.entries()) {
2597
2873
  if (!request.sendRequests || !request.receiveResponse) {
2598
2874
  continue;
@@ -2735,7 +3011,7 @@ async function finalize7() {
2735
3011
  }
2736
3012
  handlerState5 = 3 /* FINALIZED */;
2737
3013
  }
2738
- function data8() {
3014
+ function data9() {
2739
3015
  if (handlerState5 !== 3 /* FINALIZED */) {
2740
3016
  throw new Error("Network Request handler is not finalized");
2741
3017
  }
@@ -2753,11 +3029,11 @@ var UserInteractionsHandler_exports = {};
2753
3029
  __export(UserInteractionsHandler_exports, {
2754
3030
  LONG_INTERACTION_THRESHOLD: () => LONG_INTERACTION_THRESHOLD,
2755
3031
  categoryOfInteraction: () => categoryOfInteraction,
2756
- data: () => data9,
2757
- finalize: () => finalize8,
2758
- handleEvent: () => handleEvent9,
3032
+ data: () => data10,
3033
+ finalize: () => finalize9,
3034
+ handleEvent: () => handleEvent10,
2759
3035
  removeNestedInteractions: () => removeNestedInteractions,
2760
- reset: () => reset9
3036
+ reset: () => reset10
2761
3037
  });
2762
3038
  var allEvents = [];
2763
3039
  var LONG_INTERACTION_THRESHOLD = Timing_exports3.millisecondsToMicroseconds(Timing_exports2.MilliSeconds(200));
@@ -2767,7 +3043,7 @@ var interactionEventsWithNoNesting = [];
2767
3043
  var eventTimingEndEventsById = /* @__PURE__ */ new Map();
2768
3044
  var eventTimingStartEventsForInteractions = [];
2769
3045
  var handlerState6 = 1 /* UNINITIALIZED */;
2770
- function reset9() {
3046
+ function reset10() {
2771
3047
  allEvents.length = 0;
2772
3048
  interactionEvents.length = 0;
2773
3049
  eventTimingStartEventsForInteractions.length = 0;
@@ -2776,7 +3052,7 @@ function reset9() {
2776
3052
  longestInteractionEvent = null;
2777
3053
  handlerState6 = 2 /* INITIALIZED */;
2778
3054
  }
2779
- function handleEvent9(event) {
3055
+ function handleEvent10(event) {
2780
3056
  if (handlerState6 !== 2 /* INITIALIZED */) {
2781
3057
  throw new Error("Handler is not initialized");
2782
3058
  }
@@ -2847,7 +3123,7 @@ function removeNestedInteractions(interactions) {
2847
3123
  });
2848
3124
  return keptEvents;
2849
3125
  }
2850
- async function finalize8() {
3126
+ async function finalize9() {
2851
3127
  for (const interactionStartEvent of eventTimingStartEventsForInteractions) {
2852
3128
  const endEvent = eventTimingEndEventsById.get(interactionStartEvent.id);
2853
3129
  if (!endEvent) {
@@ -2881,7 +3157,7 @@ async function finalize8() {
2881
3157
  handlerState6 = 3 /* FINALIZED */;
2882
3158
  interactionEventsWithNoNesting.push(...removeNestedInteractions(interactionEvents));
2883
3159
  }
2884
- function data9() {
3160
+ function data10() {
2885
3161
  return {
2886
3162
  allEvents: [...allEvents],
2887
3163
  interactionEvents: [...interactionEvents],
@@ -2896,10 +3172,10 @@ function data9() {
2896
3172
  // front_end/models/trace/handlers/UserTimingsHandler.ts
2897
3173
  var UserTimingsHandler_exports = {};
2898
3174
  __export(UserTimingsHandler_exports, {
2899
- data: () => data10,
2900
- finalize: () => finalize9,
2901
- handleEvent: () => handleEvent10,
2902
- reset: () => reset10
3175
+ data: () => data11,
3176
+ finalize: () => finalize10,
3177
+ handleEvent: () => handleEvent11,
3178
+ reset: () => reset11
2903
3179
  });
2904
3180
  var syntheticEvents = [];
2905
3181
  var performanceMeasureEvents = [];
@@ -2907,7 +3183,7 @@ var performanceMarkEvents = [];
2907
3183
  var consoleTimings = [];
2908
3184
  var timestampEvents = [];
2909
3185
  var handlerState7 = 1 /* UNINITIALIZED */;
2910
- function reset10() {
3186
+ function reset11() {
2911
3187
  syntheticEvents.length = 0;
2912
3188
  performanceMeasureEvents.length = 0;
2913
3189
  performanceMarkEvents.length = 0;
@@ -2953,7 +3229,7 @@ var navTimingNames = [
2953
3229
  "loadEventStart",
2954
3230
  "loadEventEnd"
2955
3231
  ];
2956
- function handleEvent10(event) {
3232
+ function handleEvent11(event) {
2957
3233
  if (handlerState7 !== 2 /* INITIALIZED */) {
2958
3234
  throw new Error("UserTimings handler is not initialized");
2959
3235
  }
@@ -2975,7 +3251,7 @@ function handleEvent10(event) {
2975
3251
  timestampEvents.push(event);
2976
3252
  }
2977
3253
  }
2978
- async function finalize9() {
3254
+ async function finalize10() {
2979
3255
  if (handlerState7 !== 2 /* INITIALIZED */) {
2980
3256
  throw new Error("UserTimings handler is not initialized");
2981
3257
  }
@@ -3025,7 +3301,7 @@ async function finalize9() {
3025
3301
  syntheticEvents.sort((a, b) => a.ts - b.ts);
3026
3302
  handlerState7 = 3 /* FINALIZED */;
3027
3303
  }
3028
- function data10() {
3304
+ function data11() {
3029
3305
  if (handlerState7 !== 3 /* FINALIZED */) {
3030
3306
  throw new Error("UserTimings handler is not finalized");
3031
3307
  }
@@ -3042,15 +3318,17 @@ var WarningsHandler_exports = {};
3042
3318
  __export(WarningsHandler_exports, {
3043
3319
  FORCED_LAYOUT_AND_STYLES_THRESHOLD: () => FORCED_LAYOUT_AND_STYLES_THRESHOLD,
3044
3320
  LONG_MAIN_THREAD_TASK_THRESHOLD: () => LONG_MAIN_THREAD_TASK_THRESHOLD,
3045
- data: () => data11,
3046
- handleEvent: () => handleEvent11,
3047
- reset: () => reset11
3321
+ data: () => data12,
3322
+ deps: () => deps6,
3323
+ finalize: () => finalize11,
3324
+ handleEvent: () => handleEvent12,
3325
+ reset: () => reset12
3048
3326
  });
3049
3327
  var warningsPerEvent = /* @__PURE__ */ new Map();
3050
3328
  var eventsPerWarning = /* @__PURE__ */ new Map();
3051
3329
  var FORCED_LAYOUT_AND_STYLES_THRESHOLD = Timing_exports3.millisecondsToMicroseconds(Timing_exports2.MilliSeconds(10));
3052
3330
  var LONG_MAIN_THREAD_TASK_THRESHOLD = Timing_exports3.millisecondsToMicroseconds(Timing_exports2.MilliSeconds(50));
3053
- function reset11() {
3331
+ function reset12() {
3054
3332
  warningsPerEvent.clear();
3055
3333
  eventsPerWarning.clear();
3056
3334
  }
@@ -3062,7 +3340,7 @@ function storeWarning(event, warning) {
3062
3340
  existingEvents.push(event);
3063
3341
  eventsPerWarning.set(warning, existingEvents);
3064
3342
  }
3065
- function handleEvent11(event) {
3343
+ function handleEvent12(event) {
3066
3344
  if (event.name === TraceEvents_exports.KnownEventName.RunTask) {
3067
3345
  const { duration } = Timing_exports3.eventTimingsMicroSeconds(event);
3068
3346
  if (duration > LONG_MAIN_THREAD_TASK_THRESHOLD) {
@@ -3090,7 +3368,16 @@ function handleEvent11(event) {
3090
3368
  return;
3091
3369
  }
3092
3370
  }
3093
- function data11() {
3371
+ function deps6() {
3372
+ return ["UserInteractions"];
3373
+ }
3374
+ async function finalize11() {
3375
+ const longInteractions = data10().interactionsOverThreshold;
3376
+ for (const interaction of longInteractions) {
3377
+ storeWarning(interaction, "LONG_INTERACTION");
3378
+ }
3379
+ }
3380
+ function data12() {
3094
3381
  return {
3095
3382
  perEvent: new Map(warningsPerEvent),
3096
3383
  perWarning: new Map(eventsPerWarning)
@@ -3100,11 +3387,11 @@ function data11() {
3100
3387
  // front_end/models/trace/handlers/WorkersHandler.ts
3101
3388
  var WorkersHandler_exports = {};
3102
3389
  __export(WorkersHandler_exports, {
3103
- data: () => data12,
3104
- finalize: () => finalize10,
3105
- handleEvent: () => handleEvent12,
3390
+ data: () => data13,
3391
+ finalize: () => finalize12,
3392
+ handleEvent: () => handleEvent13,
3106
3393
  initialize: () => initialize5,
3107
- reset: () => reset12
3394
+ reset: () => reset13
3108
3395
  });
3109
3396
  var handlerState8 = 1 /* UNINITIALIZED */;
3110
3397
  var sessionIdEvents = [];
@@ -3116,12 +3403,12 @@ function initialize5() {
3116
3403
  }
3117
3404
  handlerState8 = 2 /* INITIALIZED */;
3118
3405
  }
3119
- function reset12() {
3406
+ function reset13() {
3120
3407
  sessionIdEvents.length = 0;
3121
3408
  workerIdByThread.clear();
3122
3409
  handlerState8 = 1 /* UNINITIALIZED */;
3123
3410
  }
3124
- function handleEvent12(event) {
3411
+ function handleEvent13(event) {
3125
3412
  if (handlerState8 !== 2 /* INITIALIZED */) {
3126
3413
  throw new Error("Workers Handler is not initialized");
3127
3414
  }
@@ -3129,7 +3416,7 @@ function handleEvent12(event) {
3129
3416
  sessionIdEvents.push(event);
3130
3417
  }
3131
3418
  }
3132
- async function finalize10() {
3419
+ async function finalize12() {
3133
3420
  if (handlerState8 !== 2 /* INITIALIZED */) {
3134
3421
  throw new Error("Handler is not initialized");
3135
3422
  }
@@ -3142,7 +3429,7 @@ async function finalize10() {
3142
3429
  }
3143
3430
  handlerState8 = 3 /* FINALIZED */;
3144
3431
  }
3145
- function data12() {
3432
+ function data13() {
3146
3433
  if (handlerState8 !== 3 /* FINALIZED */) {
3147
3434
  throw new Error("Workers Handler is not finalized");
3148
3435
  }
@@ -3156,6 +3443,7 @@ function data12() {
3156
3443
  // front_end/models/trace/handlers/Migration.ts
3157
3444
  var ENABLED_TRACE_HANDLERS = {
3158
3445
  Animations: AnimationHandler_exports,
3446
+ AuctionWorklets: AuctionWorkletsHandler_exports,
3159
3447
  UserTimings: UserTimingsHandler_exports,
3160
3448
  PageLoadMetrics: PageLoadMetricsHandler_exports,
3161
3449
  UserInteractions: UserInteractionsHandler_exports,
@@ -3190,119 +3478,6 @@ __export(ModelHandlers_exports, {
3190
3478
  Workers: () => WorkersHandler_exports
3191
3479
  });
3192
3480
 
3193
- // front_end/models/trace/handlers/AuctionWorkletsHandler.ts
3194
- var AuctionWorkletsHandler_exports = {};
3195
- __export(AuctionWorkletsHandler_exports, {
3196
- data: () => data13,
3197
- finalize: () => finalize11,
3198
- handleEvent: () => handleEvent13,
3199
- reset: () => reset13
3200
- });
3201
- var runningInProcessEvents = /* @__PURE__ */ new Map();
3202
- var doneWithProcessEvents = /* @__PURE__ */ new Map();
3203
- var createdSyntheticEvents = /* @__PURE__ */ new Map();
3204
- var utilityThreads = /* @__PURE__ */ new Map();
3205
- var v8HelperThreads = /* @__PURE__ */ new Map();
3206
- function reset13() {
3207
- runningInProcessEvents.clear();
3208
- doneWithProcessEvents.clear();
3209
- createdSyntheticEvents.clear();
3210
- utilityThreads.clear();
3211
- v8HelperThreads.clear();
3212
- }
3213
- function handleEvent13(event) {
3214
- if (TraceEvents_exports.isTraceEventAuctionWorkletRunningInProcess(event)) {
3215
- runningInProcessEvents.set(event.args.data.pid, event);
3216
- return;
3217
- }
3218
- if (TraceEvents_exports.isTraceEventAuctionWorkletDoneWithProcess(event)) {
3219
- doneWithProcessEvents.set(event.args.data.pid, event);
3220
- return;
3221
- }
3222
- if (TraceEvents_exports.isThreadName(event)) {
3223
- if (event.args.name === "auction_worklet.CrUtilityMain") {
3224
- utilityThreads.set(event.pid, event);
3225
- return;
3226
- }
3227
- if (event.args.name === "AuctionV8HelperThread") {
3228
- v8HelperThreads.set(event.pid, event);
3229
- }
3230
- }
3231
- }
3232
- function workletType(input) {
3233
- switch (input) {
3234
- case "seller":
3235
- return TraceEvents_exports.AuctionWorkletType.SELLER;
3236
- case "bidder":
3237
- return TraceEvents_exports.AuctionWorkletType.BIDDER;
3238
- default:
3239
- return TraceEvents_exports.AuctionWorkletType.UNKNOWN;
3240
- }
3241
- }
3242
- function makeSyntheticEventBase(event) {
3243
- return {
3244
- name: "SyntheticAuctionWorkletEvent",
3245
- s: TraceEvents_exports.TraceEventScope.THREAD,
3246
- cat: event.cat,
3247
- tid: event.tid,
3248
- ts: event.ts,
3249
- ph: TraceEvents_exports.Phase.INSTANT,
3250
- pid: event.args.data.pid,
3251
- host: event.args.data.host,
3252
- target: event.args.data.target,
3253
- type: workletType(event.args.data.type)
3254
- };
3255
- }
3256
- async function finalize11() {
3257
- for (const [pid, utilityThreadNameEvent] of utilityThreads) {
3258
- const v8HelperEvent = v8HelperThreads.get(pid);
3259
- if (!v8HelperEvent) {
3260
- continue;
3261
- }
3262
- const runningEvent = runningInProcessEvents.get(pid);
3263
- const doneWithEvent = doneWithProcessEvents.get(pid);
3264
- let syntheticEvent = null;
3265
- if (runningEvent) {
3266
- syntheticEvent = {
3267
- ...makeSyntheticEventBase(runningEvent),
3268
- args: {
3269
- data: {
3270
- runningInProcessEvent: runningEvent,
3271
- utilityThread: utilityThreadNameEvent,
3272
- v8HelperThread: v8HelperEvent
3273
- }
3274
- }
3275
- };
3276
- if (doneWithEvent) {
3277
- syntheticEvent.args.data.doneWithProcessEvent = doneWithEvent;
3278
- }
3279
- } else if (doneWithEvent) {
3280
- syntheticEvent = {
3281
- ...makeSyntheticEventBase(doneWithEvent),
3282
- args: {
3283
- data: {
3284
- doneWithProcessEvent: doneWithEvent,
3285
- utilityThread: utilityThreadNameEvent,
3286
- v8HelperThread: v8HelperEvent
3287
- }
3288
- }
3289
- };
3290
- if (runningEvent) {
3291
- syntheticEvent.args.data.runningInProcessEvent = runningEvent;
3292
- }
3293
- }
3294
- if (syntheticEvent === null) {
3295
- continue;
3296
- }
3297
- createdSyntheticEvents.set(pid, syntheticEvent);
3298
- }
3299
- }
3300
- function data13() {
3301
- return {
3302
- worklets: new Map(createdSyntheticEvents)
3303
- };
3304
- }
3305
-
3306
3481
  // front_end/models/trace/handlers/LargestImagePaintHandler.ts
3307
3482
  var LargestImagePaintHandler_exports = {};
3308
3483
  __export(LargestImagePaintHandler_exports, {
@@ -3360,24 +3535,23 @@ __export(RendererHandler_exports, {
3360
3535
  assignThreadName: () => assignThreadName,
3361
3536
  buildHierarchy: () => buildHierarchy,
3362
3537
  data: () => data17,
3363
- deps: () => deps6,
3364
- finalize: () => finalize13,
3538
+ deps: () => deps7,
3539
+ finalize: () => finalize14,
3365
3540
  handleEvent: () => handleEvent17,
3366
3541
  handleUserConfig: () => handleUserConfig,
3367
3542
  initialize: () => initialize7,
3368
3543
  makeCompleteEvent: () => makeCompleteEvent,
3369
3544
  reset: () => reset17,
3370
3545
  sanitizeProcesses: () => sanitizeProcesses,
3371
- sanitizeThreads: () => sanitizeThreads,
3372
- treify: () => treify
3546
+ sanitizeThreads: () => sanitizeThreads
3373
3547
  });
3374
3548
 
3375
3549
  // front_end/models/trace/handlers/SamplesHandler.ts
3376
3550
  var SamplesHandler_exports = {};
3377
3551
  __export(SamplesHandler_exports, {
3378
- buildProfileCalls: () => buildProfileCalls,
3379
3552
  data: () => data16,
3380
- finalize: () => finalize12,
3553
+ finalize: () => finalize13,
3554
+ getProfileCallFunctionName: () => getProfileCallFunctionName,
3381
3555
  handleEvent: () => handleEvent16,
3382
3556
  initialize: () => initialize6,
3383
3557
  reset: () => reset16
@@ -3535,7 +3709,7 @@ var CPUProfileDataModel = class extends ProfileTreeModel {
3535
3709
  this.profileHead = this.translateProfileTree(profile.nodes);
3536
3710
  this.initialize(this.profileHead);
3537
3711
  this.extractMetaNodes();
3538
- if (this.samples) {
3712
+ if (this.samples?.length) {
3539
3713
  this.sortSamples();
3540
3714
  this.normalizeTimestamps();
3541
3715
  this.fixMissingSamples();
@@ -3858,61 +4032,63 @@ var CPUProfileDataModel = class extends ProfileTreeModel {
3858
4032
  // front_end/models/trace/handlers/SamplesHandler.ts
3859
4033
  var events = /* @__PURE__ */ new Map();
3860
4034
  var profilesInProcess = /* @__PURE__ */ new Map();
4035
+ var entryToNode = /* @__PURE__ */ new Map();
3861
4036
  var preprocessedData = /* @__PURE__ */ new Map();
3862
4037
  var handlerState9 = 1 /* UNINITIALIZED */;
3863
4038
  function buildProfileCalls() {
3864
4039
  for (const [processId, profiles] of preprocessedData) {
3865
4040
  for (const [profileId, preProcessedData] of profiles) {
3866
- let openFrameCallback = function(_depth, node, timeStampMs) {
4041
+ let openFrameCallback = function(depth, node, timeStampMs) {
4042
+ if (threadId === void 0) {
4043
+ return;
4044
+ }
3867
4045
  const ts = Timing_exports3.millisecondsToMicroseconds(Timing_exports2.MilliSeconds(timeStampMs));
3868
- trackingStack.push({ callFrame: node.callFrame, ts, pid: processId, children: [], tid: threadId });
3869
- }, closeFrameCallback = function(depth, node, _timeStamp, durMs, selfTimeMs) {
3870
- const partialProfileCall = trackingStack.pop();
3871
- if (!partialProfileCall) {
4046
+ const nodeId = node.id;
4047
+ const profileCall = Trace_exports.makeProfileCall(node, ts, processId, threadId);
4048
+ finalizedData.profileCalls.push(profileCall);
4049
+ indexStack.push(finalizedData.profileCalls.length - 1);
4050
+ const traceEntryNode = TreeHelpers_exports.makeEmptyTraceEntryNode(profileCall, nodeId);
4051
+ finalizedData.profileTree?.nodes.set(nodeId, traceEntryNode);
4052
+ entryToNode.set(profileCall, traceEntryNode);
4053
+ traceEntryNode.depth = depth;
4054
+ if (indexStack.length === 1) {
4055
+ finalizedData.profileTree?.roots.add(traceEntryNode);
4056
+ }
4057
+ }, closeFrameCallback = function(_depth, node, _timeStamp, durMs, selfTimeMs) {
4058
+ const profileCallIndex = indexStack.pop();
4059
+ const profileCall = profileCallIndex !== void 0 && finalizedData.profileCalls[profileCallIndex];
4060
+ if (!profileCall) {
3872
4061
  return;
3873
4062
  }
3874
- const { callFrame, ts, pid, children, tid } = partialProfileCall;
3875
- if (callFrame === void 0 || ts === void 0 || pid === void 0 || profileId === void 0 || children === void 0 || tid === void 0) {
4063
+ const { callFrame, ts, pid, tid } = profileCall;
4064
+ const traceEntryNode = entryToNode.get(profileCall);
4065
+ if (callFrame === void 0 || ts === void 0 || pid === void 0 || profileId === void 0 || tid === void 0 || traceEntryNode === void 0) {
3876
4066
  return;
3877
4067
  }
3878
4068
  const dur = Timing_exports3.millisecondsToMicroseconds(Timing_exports2.MilliSeconds(durMs));
3879
4069
  const selfTime = Timing_exports3.millisecondsToMicroseconds(Timing_exports2.MilliSeconds(selfTimeMs));
3880
- const completeProfileCall = {
3881
- callFrame,
3882
- ts,
3883
- pid,
3884
- dur,
3885
- selfTime,
3886
- children,
3887
- ph: TraceEvents_exports.Phase.COMPLETE,
3888
- cat: "",
3889
- args: {},
3890
- name: "ProfileCall",
3891
- tid,
3892
- nodeId: node.id
3893
- };
3894
- const parent = trackingStack.at(-1);
3895
- const calls = finalizedData.profileCalls;
3896
- calls.push(completeProfileCall);
3897
- if (!parent) {
4070
+ profileCall.dur = dur;
4071
+ profileCall.selfTime = selfTime;
4072
+ const parentIndex = indexStack.at(-1);
4073
+ const parent = parentIndex !== void 0 && finalizedData.profileCalls.at(parentIndex);
4074
+ const parentNode = parent && entryToNode.get(parent);
4075
+ if (!parentNode) {
3898
4076
  return;
3899
4077
  }
3900
- parent.children = parent.children || [];
3901
- parent.children.push(completeProfileCall);
3902
- if (parent.selfTime) {
3903
- parent.selfTime = Timing_exports2.MicroSeconds(parent.selfTime - dur);
3904
- }
4078
+ traceEntryNode.parentId = parentNode.id;
4079
+ parentNode.children.add(traceEntryNode);
3905
4080
  };
3906
4081
  const threadId = preProcessedData.threadId;
3907
- if (!preProcessedData.rawProfile.nodes.length || !threadId) {
4082
+ if (!preProcessedData.rawProfile.nodes.length || threadId === void 0) {
3908
4083
  continue;
3909
4084
  }
3910
- const trackingStack = [];
4085
+ const indexStack = [];
3911
4086
  const profileModel = new CPUProfileDataModel_exports.CPUProfileDataModel(preProcessedData.rawProfile);
3912
- const finalizedData = { rawProfile: preProcessedData.rawProfile, parsedProfile: profileModel, profileCalls: [] };
3913
- profileModel.forEachFrame(openFrameCallback, closeFrameCallback);
3914
- Trace_exports.sortTraceEventsInPlace(finalizedData.profileCalls);
4087
+ const profileTree = TreeHelpers_exports.makeEmptyTraceEntryTree();
4088
+ profileTree.maxDepth = profileModel.maxDepth;
4089
+ const finalizedData = { rawProfile: preProcessedData.rawProfile, parsedProfile: profileModel, profileCalls: [], profileTree };
3915
4090
  const dataByThread = map_utilities_exports.getWithDefault(profilesInProcess, processId, () => /* @__PURE__ */ new Map());
4091
+ profileModel.forEachFrame(openFrameCallback, closeFrameCallback);
3916
4092
  dataByThread.set(threadId, finalizedData);
3917
4093
  }
3918
4094
  }
@@ -3921,6 +4097,7 @@ function reset16() {
3921
4097
  events.clear();
3922
4098
  preprocessedData.clear();
3923
4099
  profilesInProcess.clear();
4100
+ entryToNode.clear();
3924
4101
  handlerState9 = 1 /* UNINITIALIZED */;
3925
4102
  }
3926
4103
  function initialize6() {
@@ -3933,6 +4110,15 @@ function handleEvent16(event) {
3933
4110
  if (handlerState9 !== 2 /* INITIALIZED */) {
3934
4111
  throw new Error("Samples Handler is not initialized");
3935
4112
  }
4113
+ if (TraceEvents_exports.isSyntheticTraceEventCpuProfile(event)) {
4114
+ const pid = event.pid;
4115
+ const tid = event.tid;
4116
+ const profileId = "0x1";
4117
+ const profileData = getOrCreatePreProcessedData(pid, profileId);
4118
+ profileData.rawProfile = event.args.data.cpuProfile;
4119
+ profileData.threadId = tid;
4120
+ return;
4121
+ }
3936
4122
  if (TraceEvents_exports.isTraceEventProfile(event)) {
3937
4123
  const profileData = getOrCreatePreProcessedData(event.pid, event.id);
3938
4124
  profileData.rawProfile.startTime = event.ts;
@@ -3979,7 +4165,7 @@ function handleEvent16(event) {
3979
4165
  return;
3980
4166
  }
3981
4167
  }
3982
- async function finalize12() {
4168
+ async function finalize13() {
3983
4169
  if (handlerState9 !== 2 /* INITIALIZED */) {
3984
4170
  throw new Error("Samples Handler is not initialized");
3985
4171
  }
@@ -3991,7 +4177,8 @@ function data16() {
3991
4177
  throw new Error("Samples Handler is not finalized");
3992
4178
  }
3993
4179
  return {
3994
- profilesInProcess: new Map(profilesInProcess)
4180
+ profilesInProcess: new Map(profilesInProcess),
4181
+ entryToNode: new Map(entryToNode)
3995
4182
  };
3996
4183
  }
3997
4184
  function getOrCreatePreProcessedData(processId, profileId) {
@@ -4008,14 +4195,20 @@ function getOrCreatePreProcessedData(processId, profileId) {
4008
4195
  profileId
4009
4196
  }));
4010
4197
  }
4198
+ function getProfileCallFunctionName(data18, entry) {
4199
+ const profile = data18.profilesInProcess.get(entry.pid)?.get(entry.tid);
4200
+ const node = profile?.parsedProfile.nodeById(entry.nodeId);
4201
+ if (node?.functionName) {
4202
+ return node.functionName;
4203
+ }
4204
+ return entry.callFrame.functionName;
4205
+ }
4011
4206
 
4012
4207
  // front_end/models/trace/handlers/RendererHandler.ts
4013
4208
  var processes = /* @__PURE__ */ new Map();
4014
4209
  var compositorTileWorkers = Array();
4015
- var entryToNode = /* @__PURE__ */ new Map();
4210
+ var entryToNode2 = /* @__PURE__ */ new Map();
4016
4211
  var allRendererEvents = [];
4017
- var nodeIdCount = 0;
4018
- var makeRendererEntrytNodeId = () => ++nodeIdCount;
4019
4212
  var completeEventStack = [];
4020
4213
  var handlerState10 = 1 /* UNINITIALIZED */;
4021
4214
  var config = Configuration_exports.DEFAULT;
@@ -4028,18 +4221,6 @@ var makeRendererThread = () => ({
4028
4221
  name: null,
4029
4222
  entries: []
4030
4223
  });
4031
- var makeEmptyRendererTree = () => ({
4032
- nodes: /* @__PURE__ */ new Map(),
4033
- roots: /* @__PURE__ */ new Set(),
4034
- maxDepth: 0
4035
- });
4036
- var makeEmptyRendererEventNode = (entry, id) => ({
4037
- entry,
4038
- id,
4039
- parentId: null,
4040
- children: /* @__PURE__ */ new Set(),
4041
- depth: 0
4042
- });
4043
4224
  var getOrCreateRendererProcess = (processes2, pid) => {
4044
4225
  return map_utilities_exports.getWithDefault(processes2, pid, makeRendererProcess);
4045
4226
  };
@@ -4051,11 +4232,10 @@ function handleUserConfig(userConfig) {
4051
4232
  }
4052
4233
  function reset17() {
4053
4234
  processes.clear();
4054
- entryToNode.clear();
4235
+ entryToNode2.clear();
4055
4236
  allRendererEvents.length = 0;
4056
4237
  completeEventStack.length = 0;
4057
4238
  compositorTileWorkers.length = 0;
4058
- nodeIdCount = -1;
4059
4239
  handlerState10 = 1 /* UNINITIALIZED */;
4060
4240
  }
4061
4241
  function initialize7() {
@@ -4092,11 +4272,11 @@ function handleEvent17(event) {
4092
4272
  allRendererEvents.push(event);
4093
4273
  }
4094
4274
  }
4095
- async function finalize13() {
4275
+ async function finalize14() {
4096
4276
  if (handlerState10 !== 2 /* INITIALIZED */) {
4097
4277
  throw new Error("Renderer Handler is not initialized");
4098
4278
  }
4099
- const { mainFrameId: mainFrameId2, rendererProcessesByFrame, threadsInProcess: threadsInProcess2 } = data2();
4279
+ const { mainFrameId: mainFrameId2, rendererProcessesByFrame, threadsInProcess: threadsInProcess2 } = data3();
4100
4280
  assignMeta(processes, mainFrameId2, rendererProcessesByFrame, threadsInProcess2);
4101
4281
  sanitizeProcesses(processes);
4102
4282
  buildHierarchy(processes);
@@ -4110,7 +4290,7 @@ function data17() {
4110
4290
  return {
4111
4291
  processes: new Map(processes),
4112
4292
  compositorTileWorkers: new Map(gatherCompositorThreads()),
4113
- entryToNode: new Map(entryToNode),
4293
+ entryToNode: new Map(entryToNode2),
4114
4294
  allRendererEvents: [...allRendererEvents]
4115
4295
  };
4116
4296
  }
@@ -4167,9 +4347,15 @@ function assignThreadName(processes2, rendererProcessesByFrame, threadsInProcess
4167
4347
  }
4168
4348
  }
4169
4349
  function sanitizeProcesses(processes2) {
4350
+ const auctionWorklets = data2().worklets;
4170
4351
  for (const [pid, process] of processes2) {
4171
4352
  if (process.url === null) {
4172
- processes2.delete(pid);
4353
+ const maybeWorklet = auctionWorklets.get(pid);
4354
+ if (maybeWorklet) {
4355
+ process.url = maybeWorklet.host;
4356
+ } else {
4357
+ processes2.delete(pid);
4358
+ }
4173
4359
  continue;
4174
4360
  }
4175
4361
  const asUrl = new URL(process.url);
@@ -4191,7 +4377,7 @@ function buildHierarchy(processes2, options) {
4191
4377
  for (const [pid, process] of processes2) {
4192
4378
  for (const [tid, thread] of process.threads) {
4193
4379
  if (!thread.entries.length) {
4194
- thread.tree = makeEmptyRendererTree();
4380
+ thread.tree = TreeHelpers_exports.makeEmptyTraceEntryTree();
4195
4381
  continue;
4196
4382
  }
4197
4383
  Trace_exports.sortTraceEventsInPlace(thread.entries);
@@ -4201,69 +4387,13 @@ function buildHierarchy(processes2, options) {
4201
4387
  if (profileCalls) {
4202
4388
  thread.entries = Trace_exports.mergeEventsInOrder(thread.entries, profileCalls);
4203
4389
  }
4204
- thread.tree = treify(thread.entries, options);
4205
- }
4206
- }
4207
- }
4208
- function treify(entries, options) {
4209
- const stack = [];
4210
- nodeIdCount = -1;
4211
- const tree = makeEmptyRendererTree();
4212
- for (let i = 0; i < entries.length; i++) {
4213
- const event = entries[i];
4214
- if (options && !options.filter.has(event.name)) {
4215
- continue;
4216
- }
4217
- const duration = event.dur || 0;
4218
- const nodeId = makeRendererEntrytNodeId();
4219
- const node = makeEmptyRendererEventNode(event, nodeId);
4220
- if (stack.length === 0) {
4221
- tree.nodes.set(nodeId, node);
4222
- tree.roots.add(node);
4223
- event.selfTime = Timing_exports2.MicroSeconds(duration);
4224
- stack.push(node);
4225
- tree.maxDepth = Math.max(tree.maxDepth, stack.length);
4226
- entryToNode.set(event, node);
4227
- continue;
4228
- }
4229
- const parentNode = stack.at(-1);
4230
- if (parentNode === void 0) {
4231
- throw new Error("Impossible: no parent node found in the stack");
4232
- }
4233
- const parentEvent = parentNode.entry;
4234
- const begin = event.ts;
4235
- const parentBegin = parentEvent.ts;
4236
- const parentDuration = parentEvent.dur || 0;
4237
- const end = begin + duration;
4238
- const parentEnd = parentBegin + parentDuration;
4239
- const startsBeforeParent = begin < parentBegin;
4240
- if (startsBeforeParent) {
4241
- throw new Error("Impossible: current event starts before the parent event");
4242
- }
4243
- const startsAfterParent = begin >= parentEnd;
4244
- if (startsAfterParent) {
4245
- stack.pop();
4246
- i--;
4247
- nodeIdCount--;
4248
- continue;
4249
- }
4250
- const endsAfterParent = end > parentEnd;
4251
- if (endsAfterParent) {
4252
- continue;
4253
- }
4254
- tree.nodes.set(nodeId, node);
4255
- node.depth = stack.length;
4256
- node.parentId = parentNode.id;
4257
- parentNode.children.add(node);
4258
- event.selfTime = Timing_exports2.MicroSeconds(duration);
4259
- if (parentEvent.selfTime !== void 0) {
4260
- parentEvent.selfTime = Timing_exports2.MicroSeconds(parentEvent.selfTime - (event.dur || 0));
4390
+ const treeData = TreeHelpers_exports.treify(thread.entries, options);
4391
+ thread.tree = treeData.tree;
4392
+ for (const [entry, node] of treeData.entryToNode) {
4393
+ entryToNode2.set(entry, node);
4394
+ }
4261
4395
  }
4262
- stack.push(node);
4263
- tree.maxDepth = Math.max(tree.maxDepth, stack.length);
4264
- entryToNode.set(event, node);
4265
4396
  }
4266
- return tree;
4267
4397
  }
4268
4398
  function makeCompleteEvent(event) {
4269
4399
  if (TraceEvents_exports.isTraceEventEnd(event)) {
@@ -4286,12 +4416,78 @@ function makeCompleteEvent(event) {
4286
4416
  completeEventStack.push(syntheticComplete);
4287
4417
  return syntheticComplete;
4288
4418
  }
4289
- function deps6() {
4290
- return ["Meta", "Samples"];
4419
+ function deps7() {
4420
+ return ["Meta", "Samples", "AuctionWorklets"];
4421
+ }
4422
+
4423
+ // front_end/models/trace/handlers/Threads.ts
4424
+ var Threads_exports = {};
4425
+ __export(Threads_exports, {
4426
+ ThreadType: () => ThreadType,
4427
+ threadsInTrace: () => threadsInTrace
4428
+ });
4429
+ var ThreadType = /* @__PURE__ */ ((ThreadType2) => {
4430
+ ThreadType2["MAIN_THREAD"] = "MAIN_THREAD";
4431
+ ThreadType2["WORKER"] = "WORKER";
4432
+ ThreadType2["RASTERIZER"] = "RASTERIZER";
4433
+ ThreadType2["AUCTION_WORKLET"] = "AUCTION_WORKLET";
4434
+ ThreadType2["OTHER"] = "OTHER";
4435
+ ThreadType2["CPU_PROFILE"] = "CPU_PROFILE";
4436
+ return ThreadType2;
4437
+ })(ThreadType || {});
4438
+ function getThreadTypeForRendererThread(traceParseData, pid, thread) {
4439
+ let threadType = "OTHER" /* OTHER */;
4440
+ if (thread.name === "CrRendererMain") {
4441
+ threadType = "MAIN_THREAD" /* MAIN_THREAD */;
4442
+ } else if (thread.name === "DedicatedWorker thread") {
4443
+ threadType = "WORKER" /* WORKER */;
4444
+ } else if (thread.name?.startsWith("CompositorTileWorker")) {
4445
+ threadType = "RASTERIZER" /* RASTERIZER */;
4446
+ } else if (traceParseData.AuctionWorklets.worklets.has(pid)) {
4447
+ threadType = "AUCTION_WORKLET" /* AUCTION_WORKLET */;
4448
+ }
4449
+ return threadType;
4450
+ }
4451
+ function threadsInTrace(traceParseData) {
4452
+ const foundThreads = [];
4453
+ if (traceParseData.Renderer && traceParseData.Renderer.processes.size) {
4454
+ for (const [pid, process] of traceParseData.Renderer.processes) {
4455
+ for (const [tid, thread] of process.threads) {
4456
+ const threadType = getThreadTypeForRendererThread(traceParseData, pid, thread);
4457
+ if (!thread.tree) {
4458
+ continue;
4459
+ }
4460
+ foundThreads.push({
4461
+ name: thread.name,
4462
+ pid,
4463
+ tid,
4464
+ entries: thread.entries,
4465
+ tree: thread.tree,
4466
+ type: threadType,
4467
+ entryToNode: traceParseData.Renderer.entryToNode
4468
+ });
4469
+ }
4470
+ }
4471
+ } else if (traceParseData.Samples && traceParseData.Samples.profilesInProcess.size) {
4472
+ for (const [pid, process] of traceParseData.Samples.profilesInProcess) {
4473
+ for (const [tid, thread] of process) {
4474
+ if (!thread.profileTree) {
4475
+ continue;
4476
+ }
4477
+ foundThreads.push({
4478
+ pid,
4479
+ tid,
4480
+ name: null,
4481
+ entries: thread.profileCalls,
4482
+ tree: thread.profileTree,
4483
+ type: "CPU_PROFILE" /* CPU_PROFILE */,
4484
+ entryToNode: traceParseData.Samples.entryToNode
4485
+ });
4486
+ }
4487
+ }
4488
+ }
4489
+ return foundThreads;
4291
4490
  }
4292
- var RendererEventNodeIdTag = class {
4293
- #tag;
4294
- };
4295
4491
 
4296
4492
  // front_end/models/trace/LegacyTracingModel.ts
4297
4493
  var LegacyTracingModel_exports = {};
@@ -5112,9 +5308,9 @@ function sortHandlers(traceHandlers) {
5112
5308
  if (!handler) {
5113
5309
  return;
5114
5310
  }
5115
- const deps7 = handler.deps?.();
5116
- if (deps7) {
5117
- deps7.forEach(visitHandler);
5311
+ const deps8 = handler.deps?.();
5312
+ if (deps8) {
5313
+ deps8.forEach(visitHandler);
5118
5314
  }
5119
5315
  sortedMap.set(handlerName, handler);
5120
5316
  };
@@ -5155,8 +5351,8 @@ var Model = class extends EventTarget {
5155
5351
  #lastRecordingIndex = 0;
5156
5352
  #processor;
5157
5353
  #config = Configuration_exports.DEFAULT;
5158
- static createWithAllHandlers() {
5159
- return new Model(ModelHandlers_exports);
5354
+ static createWithAllHandlers(config2) {
5355
+ return new Model(ModelHandlers_exports, config2);
5160
5356
  }
5161
5357
  static createWithRequiredHandlersForMigration(config2) {
5162
5358
  return new Model(Migration_exports.ENABLED_TRACE_HANDLERS, config2);
@@ -5276,9 +5472,9 @@ var TreeManipulator = class {
5276
5472
  #entryToNode;
5277
5473
  #lastVisibleEntries = null;
5278
5474
  #activeActions = [];
5279
- constructor(thread, entryToNode2) {
5475
+ constructor(thread, entryToNode3) {
5280
5476
  this.#thread = thread;
5281
- this.#entryToNode = entryToNode2;
5477
+ this.#entryToNode = entryToNode3;
5282
5478
  }
5283
5479
  applyAction(action) {
5284
5480
  if (this.#actionIsActive(action)) {