@paulirish/trace_engine 0.0.3 → 0.0.4

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
@@ -208,17 +208,6 @@ function arrayDoesNotContainNullOrUndefined(arr) {
208
208
  return !arr.includes(null) && !arr.includes(void 0);
209
209
  }
210
210
 
211
- // front_end/core/platform/DevToolsPath.ts
212
- var DevToolsPath_exports = {};
213
- __export(DevToolsPath_exports, {
214
- EmptyEncodedPathString: () => EmptyEncodedPathString,
215
- EmptyRawPathString: () => EmptyRawPathString,
216
- EmptyUrlString: () => EmptyUrlString
217
- });
218
- var EmptyUrlString = "";
219
- var EmptyRawPathString = "";
220
- var EmptyEncodedPathString = "";
221
-
222
211
  // front_end/core/platform/map-utilities.ts
223
212
  var map_utilities_exports = {};
224
213
  __export(map_utilities_exports, {
@@ -384,13 +373,6 @@ function assertNever(type, message) {
384
373
  throw new Error(message);
385
374
  }
386
375
 
387
- // front_end/core/platform/platform.ts
388
- function DCHECK(condition, message = "DCHECK") {
389
- if (!condition()) {
390
- throw new Error(message + ":" + new Error().stack);
391
- }
392
- }
393
-
394
376
  // front_end/models/trace/types/types.ts
395
377
  var types_exports = {};
396
378
  __export(types_exports, {
@@ -406,8 +388,14 @@ __export(Configuration_exports, {
406
388
  DEFAULT: () => DEFAULT
407
389
  });
408
390
  var DEFAULT = {
409
- settings: {
410
- showNativeFunctionsInJSProfile: false
391
+ settings: {},
392
+ experiments: {
393
+ timelineV8RuntimeCallStats: false,
394
+ timelineShowAllEvents: false
395
+ },
396
+ processing: {
397
+ eventsPerChunk: 15e3,
398
+ pauseDuration: 1
411
399
  }
412
400
  };
413
401
 
@@ -466,6 +454,7 @@ __export(TraceEvents_exports, {
466
454
  isNestableAsyncPhase: () => isNestableAsyncPhase,
467
455
  isProcessName: () => isProcessName,
468
456
  isProfileCall: () => isProfileCall,
457
+ isRendererEvent: () => isRendererEvent,
469
458
  isSyntheticConsoleTimingTraceEvent: () => isSyntheticConsoleTimingTraceEvent,
470
459
  isSyntheticInteractionEvent: () => isSyntheticInteractionEvent,
471
460
  isSyntheticLayoutShift: () => isSyntheticLayoutShift,
@@ -597,6 +586,9 @@ var StyleRecalcInvalidationReason = /* @__PURE__ */ ((StyleRecalcInvalidationRea
597
586
  function isSyntheticInteractionEvent(event) {
598
587
  return Boolean("interactionId" in event && event.args?.data && "beginEvent" in event.args.data && "endEvent" in event.args.data);
599
588
  }
589
+ function isRendererEvent(event) {
590
+ return isTraceEventRendererEvent(event) || isProfileCall(event);
591
+ }
600
592
  var ProfileIdTag = class {
601
593
  #profileIdTag;
602
594
  };
@@ -1314,260 +1306,6 @@ __export(SamplesIntegrator_exports, {
1314
1306
  SamplesIntegrator: () => SamplesIntegrator
1315
1307
  });
1316
1308
 
1317
- // front_end/core/root/Runtime.ts
1318
- var Runtime_exports = {};
1319
- __export(Runtime_exports, {
1320
- ConditionName: () => ConditionName,
1321
- Experiment: () => Experiment,
1322
- ExperimentName: () => ExperimentName,
1323
- ExperimentsSupport: () => ExperimentsSupport,
1324
- Runtime: () => Runtime,
1325
- experiments: () => experiments,
1326
- getRemoteBase: () => getRemoteBase
1327
- });
1328
- var queryParamsObject = new URLSearchParams(location.search);
1329
- var runtimePlatform = "";
1330
- var runtimeInstance;
1331
- function getRemoteBase(location2 = self.location.toString()) {
1332
- const url = new URL(location2);
1333
- const remoteBase = url.searchParams.get("remoteBase");
1334
- if (!remoteBase) {
1335
- return null;
1336
- }
1337
- const version = /\/serve_file\/(@[0-9a-zA-Z]+)\/?$/.exec(remoteBase);
1338
- if (!version) {
1339
- return null;
1340
- }
1341
- return { base: `devtools://devtools/remote/serve_file/${version[1]}/`, version: version[1] };
1342
- }
1343
- var Runtime = class {
1344
- constructor() {
1345
- }
1346
- static instance(opts = { forceNew: null }) {
1347
- const { forceNew } = opts;
1348
- if (!runtimeInstance || forceNew) {
1349
- runtimeInstance = new Runtime();
1350
- }
1351
- return runtimeInstance;
1352
- }
1353
- static removeInstance() {
1354
- runtimeInstance = void 0;
1355
- }
1356
- static queryParam(name) {
1357
- return queryParamsObject.get(name);
1358
- }
1359
- static setQueryParamForTesting(name, value) {
1360
- queryParamsObject.set(name, value);
1361
- }
1362
- static experimentsSetting() {
1363
- try {
1364
- return JSON.parse(self.localStorage && self.localStorage["experiments"] ? self.localStorage["experiments"] : "{}");
1365
- } catch (e) {
1366
- console.error("Failed to parse localStorage['experiments']");
1367
- return {};
1368
- }
1369
- }
1370
- static setPlatform(platform) {
1371
- runtimePlatform = platform;
1372
- }
1373
- static platform() {
1374
- return runtimePlatform;
1375
- }
1376
- static isDescriptorEnabled(descriptor) {
1377
- const activatorExperiment = descriptor["experiment"];
1378
- if (activatorExperiment === "*") {
1379
- return true;
1380
- }
1381
- if (activatorExperiment && activatorExperiment.startsWith("!") && experiments.isEnabled(activatorExperiment.substring(1))) {
1382
- return false;
1383
- }
1384
- if (activatorExperiment && !activatorExperiment.startsWith("!") && !experiments.isEnabled(activatorExperiment)) {
1385
- return false;
1386
- }
1387
- const condition = descriptor["condition"];
1388
- if (condition && !condition.startsWith("!") && !Runtime.queryParam(condition)) {
1389
- return false;
1390
- }
1391
- if (condition && condition.startsWith("!") && Runtime.queryParam(condition.substring(1))) {
1392
- return false;
1393
- }
1394
- return true;
1395
- }
1396
- loadLegacyModule(modulePath) {
1397
- return import(`../../${modulePath}`);
1398
- }
1399
- };
1400
- var ExperimentsSupport = class {
1401
- #experiments;
1402
- #experimentNames;
1403
- #enabledTransiently;
1404
- #enabledByDefault;
1405
- #serverEnabled;
1406
- #nonConfigurable;
1407
- constructor() {
1408
- this.#experiments = [];
1409
- this.#experimentNames = /* @__PURE__ */ new Set();
1410
- this.#enabledTransiently = /* @__PURE__ */ new Set();
1411
- this.#enabledByDefault = /* @__PURE__ */ new Set();
1412
- this.#serverEnabled = /* @__PURE__ */ new Set();
1413
- this.#nonConfigurable = /* @__PURE__ */ new Set();
1414
- }
1415
- allConfigurableExperiments() {
1416
- const result = [];
1417
- for (const experiment of this.#experiments) {
1418
- if (!this.#enabledTransiently.has(experiment.name) && !this.#nonConfigurable.has(experiment.name)) {
1419
- result.push(experiment);
1420
- }
1421
- }
1422
- return result;
1423
- }
1424
- setExperimentsSetting(value) {
1425
- if (!self.localStorage) {
1426
- return;
1427
- }
1428
- self.localStorage["experiments"] = JSON.stringify(value);
1429
- }
1430
- register(experimentName, experimentTitle, unstable, docLink, feedbackLink) {
1431
- DCHECK(() => !this.#experimentNames.has(experimentName), "Duplicate registration of experiment " + experimentName);
1432
- this.#experimentNames.add(experimentName);
1433
- this.#experiments.push(new Experiment(this, experimentName, experimentTitle, Boolean(unstable), docLink ?? DevToolsPath_exports.EmptyUrlString, feedbackLink ?? DevToolsPath_exports.EmptyUrlString));
1434
- }
1435
- isEnabled(experimentName) {
1436
- this.checkExperiment(experimentName);
1437
- if (Runtime.experimentsSetting()[experimentName] === false) {
1438
- return false;
1439
- }
1440
- if (this.#enabledTransiently.has(experimentName) || this.#enabledByDefault.has(experimentName)) {
1441
- return true;
1442
- }
1443
- if (this.#serverEnabled.has(experimentName)) {
1444
- return true;
1445
- }
1446
- return Boolean(Runtime.experimentsSetting()[experimentName]);
1447
- }
1448
- setEnabled(experimentName, enabled) {
1449
- this.checkExperiment(experimentName);
1450
- const experimentsSetting = Runtime.experimentsSetting();
1451
- experimentsSetting[experimentName] = enabled;
1452
- this.setExperimentsSetting(experimentsSetting);
1453
- }
1454
- enableExperimentsTransiently(experimentNames) {
1455
- for (const experimentName of experimentNames) {
1456
- this.checkExperiment(experimentName);
1457
- this.#enabledTransiently.add(experimentName);
1458
- }
1459
- }
1460
- enableExperimentsByDefault(experimentNames) {
1461
- for (const experimentName of experimentNames) {
1462
- this.checkExperiment(experimentName);
1463
- this.#enabledByDefault.add(experimentName);
1464
- }
1465
- }
1466
- setServerEnabledExperiments(experimentNames) {
1467
- for (const experiment of experimentNames) {
1468
- this.checkExperiment(experiment);
1469
- this.#serverEnabled.add(experiment);
1470
- }
1471
- }
1472
- setNonConfigurableExperiments(experimentNames) {
1473
- for (const experiment of experimentNames) {
1474
- this.checkExperiment(experiment);
1475
- this.#nonConfigurable.add(experiment);
1476
- }
1477
- }
1478
- enableForTest(experimentName) {
1479
- this.checkExperiment(experimentName);
1480
- this.#enabledTransiently.add(experimentName);
1481
- }
1482
- disableForTest(experimentName) {
1483
- this.checkExperiment(experimentName);
1484
- this.#enabledTransiently.delete(experimentName);
1485
- }
1486
- clearForTest() {
1487
- this.#experiments = [];
1488
- this.#experimentNames.clear();
1489
- this.#enabledTransiently.clear();
1490
- this.#enabledByDefault.clear();
1491
- this.#serverEnabled.clear();
1492
- }
1493
- cleanUpStaleExperiments() {
1494
- const experimentsSetting = Runtime.experimentsSetting();
1495
- const cleanedUpExperimentSetting = {};
1496
- for (const { name: experimentName } of this.#experiments) {
1497
- if (experimentsSetting.hasOwnProperty(experimentName)) {
1498
- const isEnabled = experimentsSetting[experimentName];
1499
- if (isEnabled || this.#enabledByDefault.has(experimentName)) {
1500
- cleanedUpExperimentSetting[experimentName] = isEnabled;
1501
- }
1502
- }
1503
- }
1504
- this.setExperimentsSetting(cleanedUpExperimentSetting);
1505
- }
1506
- checkExperiment(experimentName) {
1507
- DCHECK(() => this.#experimentNames.has(experimentName), "Unknown experiment " + experimentName);
1508
- }
1509
- };
1510
- var Experiment = class {
1511
- name;
1512
- title;
1513
- unstable;
1514
- docLink;
1515
- feedbackLink;
1516
- #experiments;
1517
- constructor(experiments2, name, title, unstable, docLink, feedbackLink) {
1518
- this.name = name;
1519
- this.title = title;
1520
- this.unstable = unstable;
1521
- this.docLink = docLink;
1522
- this.feedbackLink = feedbackLink;
1523
- this.#experiments = experiments2;
1524
- }
1525
- isEnabled() {
1526
- return this.#experiments.isEnabled(this.name);
1527
- }
1528
- setEnabled(enabled) {
1529
- this.#experiments.setEnabled(this.name, enabled);
1530
- }
1531
- };
1532
- var experiments = new ExperimentsSupport();
1533
- var ExperimentName = /* @__PURE__ */ ((ExperimentName2) => {
1534
- ExperimentName2["CAPTURE_NODE_CREATION_STACKS"] = "captureNodeCreationStacks";
1535
- ExperimentName2["CSS_OVERVIEW"] = "cssOverview";
1536
- ExperimentName2["LIVE_HEAP_PROFILE"] = "liveHeapProfile";
1537
- ExperimentName2["DEVELOPER_RESOURCES_VIEW"] = "developerResourcesView";
1538
- ExperimentName2["CSP_VIOLATIONS_VIEW"] = "cspViolationsView";
1539
- ExperimentName2["WASM_DWARF_DEBUGGING"] = "wasmDWARFDebugging";
1540
- ExperimentName2["ALL"] = "*";
1541
- ExperimentName2["PROTOCOL_MONITOR"] = "protocolMonitor";
1542
- ExperimentName2["WEBAUTHN_PANE"] = "webauthnPane";
1543
- ExperimentName2["FULL_ACCESSIBILITY_TREE"] = "fullAccessibilityTree";
1544
- ExperimentName2["PRECISE_CHANGES"] = "preciseChanges";
1545
- ExperimentName2["STYLES_PANE_CSS_CHANGES"] = "stylesPaneCSSChanges";
1546
- ExperimentName2["HEADER_OVERRIDES"] = "headerOverrides";
1547
- ExperimentName2["EYEDROPPER_COLOR_PICKER"] = "eyedropperColorPicker";
1548
- ExperimentName2["INSTRUMENTATION_BREAKPOINTS"] = "instrumentationBreakpoints";
1549
- ExperimentName2["AUTHORED_DEPLOYED_GROUPING"] = "authoredDeployedGrouping";
1550
- ExperimentName2["IMPORTANT_DOM_PROPERTIES"] = "importantDOMProperties";
1551
- ExperimentName2["JUST_MY_CODE"] = "justMyCode";
1552
- ExperimentName2["PRELOADING_STATUS_PANEL"] = "preloadingStatusPanel";
1553
- ExperimentName2["DISABLE_COLOR_FORMAT_SETTING"] = "disableColorFormatSetting";
1554
- ExperimentName2["TIMELINE_AS_CONSOLE_PROFILE_RESULT_PANEL"] = "timelineAsConsoleProfileResultPanel";
1555
- ExperimentName2["OUTERMOST_TARGET_SELECTOR"] = "outermostTargetSelector";
1556
- ExperimentName2["JS_PROFILER_TEMP_ENABLE"] = "jsProfilerTemporarilyEnable";
1557
- ExperimentName2["HIGHLIGHT_ERRORS_ELEMENTS_PANEL"] = "highlightErrorsElementsPanel";
1558
- ExperimentName2["SET_ALL_BREAKPOINTS_EAGERLY"] = "setAllBreakpointsEagerly";
1559
- ExperimentName2["SELF_XSS_WARNING"] = "selfXssWarning";
1560
- ExperimentName2["USE_SOURCE_MAP_SCOPES"] = "useSourceMapScopes";
1561
- ExperimentName2["STORAGE_BUCKETS_TREE"] = "storageBucketsTree";
1562
- ExperimentName2["DELETE_OVERRIDES_TEMP_ENABLE"] = "deleteOverridesTemporarilyEnable";
1563
- return ExperimentName2;
1564
- })(ExperimentName || {});
1565
- var ConditionName = /* @__PURE__ */ ((ConditionName2) => {
1566
- ConditionName2["CAN_DOCK"] = "can_dock";
1567
- ConditionName2["NOT_SOURCES_HIDE_ADD_FOLDER"] = "!sources.hide_add_folder";
1568
- return ConditionName2;
1569
- })(ConditionName || {});
1570
-
1571
1309
  // front_end/models/trace/helpers/Timing.ts
1572
1310
  var Timing_exports3 = {};
1573
1311
  __export(Timing_exports3, {
@@ -1726,7 +1464,7 @@ var defaultFormatOptions = {
1726
1464
  };
1727
1465
  var serialize = (value) => JSON.stringify(value);
1728
1466
  var formatterFactory = (key) => {
1729
- return new Intl.NumberFormat(navigator.language, key ? JSON.parse(key) : {});
1467
+ return new Intl.NumberFormat(void 0, key ? JSON.parse(key) : {});
1730
1468
  };
1731
1469
  var formatters = /* @__PURE__ */ new Map();
1732
1470
  map_utilities_exports.getWithDefault(formatters, serialize({ style: "decimal" }), formatterFactory);
@@ -1786,7 +1524,7 @@ function eventTimingsMicroSeconds(event) {
1786
1524
  startTime: event.ts,
1787
1525
  endTime: Timing_exports2.MicroSeconds(event.ts + (event.dur || Timing_exports2.MicroSeconds(0))),
1788
1526
  duration: Timing_exports2.MicroSeconds(event.dur || 0),
1789
- selfTime: Timing_exports2.MicroSeconds(event.dur || 0)
1527
+ selfTime: TraceEvents_exports.isRendererEvent(event) ? Timing_exports2.MicroSeconds(event.selfTime || 0) : Timing_exports2.MicroSeconds(event.dur || 0)
1790
1528
  };
1791
1529
  }
1792
1530
  function eventTimingsMilliSeconds(event) {
@@ -1824,21 +1562,21 @@ var SamplesIntegrator = class {
1824
1562
  #lockedJsStackDepth = [];
1825
1563
  #fakeJSInvocation = false;
1826
1564
  #profileModel;
1827
- #nodeForGC = /* @__PURE__ */ new Map();
1828
- #showNativeFunctionsInJSProfile;
1829
- constructor(profileModel, pid, tid, settings = {
1830
- showNativeFunctionsInJSProfile: Configuration_exports.DEFAULT.settings.showNativeFunctionsInJSProfile
1831
- }) {
1565
+ #engineConfig;
1566
+ constructor(profileModel, pid, tid, configuration) {
1832
1567
  this.#profileModel = profileModel;
1833
1568
  this.#threadId = tid;
1834
1569
  this.#processId = pid;
1835
- this.#showNativeFunctionsInJSProfile = settings.showNativeFunctionsInJSProfile;
1570
+ this.#engineConfig = configuration || Configuration_exports.DEFAULT;
1836
1571
  }
1837
1572
  buildProfileCalls(traceEvents) {
1838
1573
  const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());
1839
1574
  const stack = [];
1840
1575
  for (let i = 0; i < mergedEvents.length; i++) {
1841
1576
  const event = mergedEvents[i];
1577
+ if (event.ph === TraceEvents_exports.Phase.INSTANT) {
1578
+ continue;
1579
+ }
1842
1580
  if (stack.length === 0) {
1843
1581
  if (TraceEvents_exports.isProfileCall(event)) {
1844
1582
  this.#onProfileCall(event);
@@ -1879,9 +1617,6 @@ var SamplesIntegrator = class {
1879
1617
  return this.#constructedProfileCalls;
1880
1618
  }
1881
1619
  #onTraceEventStart(event) {
1882
- if (event.ph === TraceEvents_exports.Phase.INSTANT) {
1883
- return;
1884
- }
1885
1620
  if (event.name === TraceEvents_exports.KnownEventName.RunMicrotasks || event.name === TraceEvents_exports.KnownEventName.RunTask) {
1886
1621
  this.#lockedJsStackDepth = [];
1887
1622
  this.#truncateJSStack(0, event.ts);
@@ -1915,7 +1650,6 @@ var SamplesIntegrator = class {
1915
1650
  return [];
1916
1651
  }
1917
1652
  const calls = [];
1918
- let prevNode;
1919
1653
  for (let i = 0; i < samples.length; i++) {
1920
1654
  const node = this.#profileModel.nodeByIndex(i);
1921
1655
  const timestamp = millisecondsToMicroseconds(Timing_exports2.MilliSeconds(timestamps[i]));
@@ -1924,28 +1658,16 @@ var SamplesIntegrator = class {
1924
1658
  }
1925
1659
  const call = SamplesIntegrator.makeProfileCall(node, timestamp, this.#processId, this.#threadId);
1926
1660
  calls.push(call);
1927
- if (node.id === this.#profileModel.gcNode?.id && prevNode) {
1928
- this.#nodeForGC.set(call, prevNode);
1929
- continue;
1930
- }
1931
- prevNode = node;
1932
1661
  }
1933
1662
  return calls;
1934
1663
  }
1935
1664
  #getStackTraceFromProfileCall(profileCall) {
1936
1665
  let node = this.#profileModel.nodeById(profileCall.nodeId);
1937
- const isGarbageCollection = Boolean(node?.id === this.#profileModel.gcNode?.id);
1938
- if (isGarbageCollection) {
1939
- node = this.#nodeForGC.get(profileCall) || null;
1940
- }
1941
1666
  if (!node) {
1942
1667
  return [];
1943
1668
  }
1944
- const callFrames = new Array(node.depth + 1 + Number(isGarbageCollection));
1669
+ const callFrames = new Array(node.depth + 1);
1945
1670
  let i = callFrames.length - 1;
1946
- if (isGarbageCollection) {
1947
- callFrames[i--] = profileCall;
1948
- }
1949
1671
  while (node) {
1950
1672
  callFrames[i--] = SamplesIntegrator.makeProfileCall(node, profileCall.ts, this.#processId, this.#threadId);
1951
1673
  node = node.parent;
@@ -1954,9 +1676,7 @@ var SamplesIntegrator = class {
1954
1676
  }
1955
1677
  #extractStackTrace(event) {
1956
1678
  const stackTrace = TraceEvents_exports.isProfileCall(event) ? this.#getStackTraceFromProfileCall(event) : this.#currentJSStack;
1957
- SamplesIntegrator.filterStackFrames(stackTrace, {
1958
- showNativeFunctionsInJSProfile: this.#showNativeFunctionsInJSProfile
1959
- });
1679
+ SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);
1960
1680
  const endTime = event.ts + (event.dur || 0);
1961
1681
  const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);
1962
1682
  let i;
@@ -1972,7 +1692,7 @@ var SamplesIntegrator = class {
1972
1692
  for (; i < stackTrace.length; ++i) {
1973
1693
  const call = stackTrace[i];
1974
1694
  this.#currentJSStack.push(call);
1975
- if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id || call.nodeId === this.#profileModel.idleNode?.id) {
1695
+ 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) {
1976
1696
  continue;
1977
1697
  }
1978
1698
  this.#constructedProfileCalls.push(call);
@@ -2013,14 +1733,8 @@ var SamplesIntegrator = class {
2013
1733
  static framesAreEqual(frame1, frame2) {
2014
1734
  return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName && frame1.lineNumber === frame2.lineNumber;
2015
1735
  }
2016
- static showNativeName(name) {
2017
- return false;
2018
- try {
2019
- const showRuntimeCallStats = Runtime_exports.experiments.isEnabled("timelineV8RuntimeCallStats");
2020
- return showRuntimeCallStats && Boolean(SamplesIntegrator.nativeGroup(name));
2021
- } catch (error) {
2022
- return false;
2023
- }
1736
+ static showNativeName(name, runtimeCallStatsEnabled) {
1737
+ return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));
2024
1738
  }
2025
1739
  static nativeGroup(nativeName) {
2026
1740
  if (nativeName.startsWith("Parse")) {
@@ -2034,8 +1748,8 @@ var SamplesIntegrator = class {
2034
1748
  static isNativeRuntimeFrame(frame) {
2035
1749
  return frame.url === "native V8Runtime";
2036
1750
  }
2037
- static filterStackFrames(stack, settings) {
2038
- let showAllEvents = false;
1751
+ static filterStackFrames(stack, engineConfig) {
1752
+ const showAllEvents = engineConfig.experiments.timelineShowAllEvents;
2039
1753
  if (showAllEvents) {
2040
1754
  return;
2041
1755
  }
@@ -2043,13 +1757,8 @@ var SamplesIntegrator = class {
2043
1757
  let j = 0;
2044
1758
  for (let i = 0; i < stack.length; ++i) {
2045
1759
  const frame = stack[i].callFrame;
2046
- const url = frame.url;
2047
- const isNativeFrame = url && url.startsWith("native ");
2048
- if (!settings.showNativeFunctionsInJSProfile && isNativeFrame) {
2049
- continue;
2050
- }
2051
1760
  const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);
2052
- if (nativeRuntimeFrame && !SamplesIntegrator.showNativeName(frame.functionName)) {
1761
+ if (nativeRuntimeFrame && !SamplesIntegrator.showNativeName(frame.functionName, engineConfig.experiments.timelineV8RuntimeCallStats)) {
2053
1762
  continue;
2054
1763
  }
2055
1764
  const nativeFrameName = nativeRuntimeFrame ? SamplesIntegrator.nativeGroup(frame.functionName) : null;
@@ -2066,6 +1775,7 @@ var SamplesIntegrator = class {
2066
1775
  cat: "",
2067
1776
  name: "ProfileCall",
2068
1777
  nodeId: node.id,
1778
+ args: {},
2069
1779
  ph: TraceEvents_exports.Phase.COMPLETE,
2070
1780
  pid,
2071
1781
  tid,
@@ -3858,12 +3568,6 @@ var CPUProfileDataModel = class extends ProfileTreeModel {
3858
3568
  return timestamps;
3859
3569
  }
3860
3570
  translateProfileTree(nodes) {
3861
- function isNativeNode(node) {
3862
- if (node.callFrame) {
3863
- return Boolean(node.callFrame.url) && node.callFrame.url.startsWith("native ");
3864
- }
3865
- return Boolean(node["url"]) && node["url"].startsWith("native ");
3866
- }
3867
3571
  function buildChildrenFromParents(nodes2) {
3868
3572
  if (nodes2[0].children) {
3869
3573
  return;
@@ -3906,7 +3610,6 @@ var CPUProfileDataModel = class extends ProfileTreeModel {
3906
3610
  buildChildrenFromParents(nodes);
3907
3611
  this.totalHitCount = nodes.reduce((acc, node) => acc + (node.hitCount || 0), 0);
3908
3612
  const sampleTime = (this.profileEndTime - this.profileStartTime) / this.totalHitCount;
3909
- const keepNatives = true;
3910
3613
  const root = nodes[0];
3911
3614
  const idToUseForRemovedNode = /* @__PURE__ */ new Map([[root.id, root.id]]);
3912
3615
  this.#idToParsedNode = /* @__PURE__ */ new Map();
@@ -3927,12 +3630,8 @@ var CPUProfileDataModel = class extends ProfileTreeModel {
3927
3630
  sourceNode.children = [];
3928
3631
  }
3929
3632
  const targetNode = new CPUProfileNode(sourceNode, sampleTime);
3930
- if (keepNatives || !isNativeNode(sourceNode)) {
3931
- parentNode.children.push(targetNode);
3932
- parentNode = targetNode;
3933
- } else {
3934
- parentNode.self += targetNode.self;
3935
- }
3633
+ parentNode.children.push(targetNode);
3634
+ parentNode = targetNode;
3936
3635
  idToUseForRemovedNode.set(sourceNode.id, parentNode.id);
3937
3636
  parentNodeStack.push.apply(parentNodeStack, sourceNode.children.map(() => parentNode));
3938
3637
  sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children.map((id) => protocolNodeById.get(id)));
@@ -4187,6 +3886,7 @@ function buildProfileCalls() {
4187
3886
  children,
4188
3887
  ph: TraceEvents_exports.Phase.COMPLETE,
4189
3888
  cat: "",
3889
+ args: {},
4190
3890
  name: "ProfileCall",
4191
3891
  tid,
4192
3892
  nodeId: node.id
@@ -4246,8 +3946,8 @@ function handleEvent16(event) {
4246
3946
  const samples = nodesAndSamples?.samples || [];
4247
3947
  const nodes = [];
4248
3948
  for (const n of nodesAndSamples?.nodes || []) {
4249
- const lineNumber = n.callFrame.lineNumber || -1;
4250
- const columnNumber = n.callFrame.columnNumber || -1;
3949
+ const lineNumber = typeof n.callFrame.lineNumber === "undefined" ? -1 : n.callFrame.lineNumber;
3950
+ const columnNumber = typeof n.callFrame.columnNumber === "undefined" ? -1 : n.callFrame.columnNumber;
4251
3951
  const scriptId = String(n.callFrame.scriptId);
4252
3952
  const url = n.callFrame.url || "";
4253
3953
  const node = {
@@ -4337,7 +4037,7 @@ var makeEmptyRendererEventNode = (entry, id) => ({
4337
4037
  entry,
4338
4038
  id,
4339
4039
  parentId: null,
4340
- childrenIds: /* @__PURE__ */ new Set(),
4040
+ children: /* @__PURE__ */ new Set(),
4341
4041
  depth: 0
4342
4042
  });
4343
4043
  var getOrCreateRendererProcess = (processes2, pid) => {
@@ -4496,9 +4196,7 @@ function buildHierarchy(processes2, options) {
4496
4196
  }
4497
4197
  Trace_exports.sortTraceEventsInPlace(thread.entries);
4498
4198
  const cpuProfile = data16().profilesInProcess.get(pid)?.get(tid)?.parsedProfile;
4499
- const samplesIntegrator = cpuProfile && new SamplesIntegrator_exports.SamplesIntegrator(cpuProfile, pid, tid, {
4500
- showNativeFunctionsInJSProfile: config.settings.showNativeFunctionsInJSProfile
4501
- });
4199
+ const samplesIntegrator = cpuProfile && new SamplesIntegrator_exports.SamplesIntegrator(cpuProfile, pid, tid, config);
4502
4200
  const profileCalls = samplesIntegrator?.buildProfileCalls(thread.entries);
4503
4201
  if (profileCalls) {
4504
4202
  thread.entries = Trace_exports.mergeEventsInOrder(thread.entries, profileCalls);
@@ -4521,7 +4219,7 @@ function treify(entries, options) {
4521
4219
  const node = makeEmptyRendererEventNode(event, nodeId);
4522
4220
  if (stack.length === 0) {
4523
4221
  tree.nodes.set(nodeId, node);
4524
- tree.roots.add(nodeId);
4222
+ tree.roots.add(node);
4525
4223
  event.selfTime = Timing_exports2.MicroSeconds(duration);
4526
4224
  stack.push(node);
4527
4225
  tree.maxDepth = Math.max(tree.maxDepth, stack.length);
@@ -4556,7 +4254,7 @@ function treify(entries, options) {
4556
4254
  tree.nodes.set(nodeId, node);
4557
4255
  node.depth = stack.length;
4558
4256
  node.parentId = parentNode.id;
4559
- parentNode.childrenIds.add(nodeId);
4257
+ parentNode.children.add(node);
4560
4258
  event.selfTime = Timing_exports2.MicroSeconds(duration);
4561
4259
  if (parentEvent.selfTime !== void 0) {
4562
4260
  parentEvent.selfTime = Timing_exports2.MicroSeconds(parentEvent.selfTime - (event.dur || 0));
@@ -5288,22 +4986,18 @@ var TraceParseProgressEvent = _TraceParseProgressEvent;
5288
4986
  __publicField(TraceParseProgressEvent, "eventName", "traceparseprogress");
5289
4987
  var TraceProcessor = class extends EventTarget {
5290
4988
  #traceHandlers;
5291
- #pauseDuration;
5292
- #eventsPerChunk;
5293
4989
  #status = "IDLE" /* IDLE */;
5294
4990
  #modelConfiguration = Configuration_exports.DEFAULT;
5295
4991
  static createWithAllHandlers() {
5296
- return new TraceProcessor(ModelHandlers_exports, {}, Configuration_exports.DEFAULT);
4992
+ return new TraceProcessor(ModelHandlers_exports, Configuration_exports.DEFAULT);
5297
4993
  }
5298
- constructor(traceHandlers, { pauseDuration = 1, eventsPerChunk = 15e3 } = {}, modelConfiguration) {
4994
+ constructor(traceHandlers, modelConfiguration) {
5299
4995
  super();
5300
4996
  this.#verifyHandlers(traceHandlers);
5301
4997
  this.#traceHandlers = {
5302
4998
  Meta: ModelHandlers_exports.Meta,
5303
4999
  ...traceHandlers
5304
5000
  };
5305
- this.#pauseDuration = pauseDuration;
5306
- this.#eventsPerChunk = eventsPerChunk;
5307
5001
  if (modelConfiguration) {
5308
5002
  this.#modelConfiguration = modelConfiguration;
5309
5003
  }
@@ -5363,7 +5057,8 @@ var TraceProcessor = class extends EventTarget {
5363
5057
  }
5364
5058
  }
5365
5059
  async #parse(traceEvents, freshRecording) {
5366
- const traceEventIterator = new TraceEventIterator(traceEvents, this.#pauseDuration, this.#eventsPerChunk);
5060
+ const { pauseDuration, eventsPerChunk } = this.#modelConfiguration.processing;
5061
+ const traceEventIterator = new TraceEventIterator(traceEvents, pauseDuration, eventsPerChunk);
5367
5062
  const sortedHandlers = [...sortHandlers(this.#traceHandlers).values()];
5368
5063
  for (const handler of sortedHandlers) {
5369
5064
  handler.reset();
@@ -5471,7 +5166,7 @@ var Model = class extends EventTarget {
5471
5166
  if (config2) {
5472
5167
  this.#config = config2;
5473
5168
  }
5474
- this.#processor = new TraceProcessor(handlers, {}, this.#config);
5169
+ this.#processor = new TraceProcessor(handlers, this.#config);
5475
5170
  }
5476
5171
  updateConfiguration(config2) {
5477
5172
  this.#config = config2;
@@ -5636,7 +5331,7 @@ var TreeManipulator = class {
5636
5331
  if (!entryNode) {
5637
5332
  continue;
5638
5333
  }
5639
- const allAncestors = this.#findAllAncestorsOfNode(this.#thread.tree, entryNode);
5334
+ const allAncestors = this.#findAllAncestorsOfNode(entryNode);
5640
5335
  allAncestors.forEach((ancestor) => entriesToHide.add(ancestor));
5641
5336
  break;
5642
5337
  }
@@ -5649,19 +5344,15 @@ var TreeManipulator = class {
5649
5344
  });
5650
5345
  return this.#lastVisibleEntries;
5651
5346
  }
5652
- #findAllAncestorsOfNode(tree, root) {
5347
+ #findAllAncestorsOfNode(root) {
5653
5348
  const ancestors = [];
5654
- const childIds = Array.from(root.childrenIds);
5655
- while (childIds.length > 0) {
5656
- const id = childIds.shift();
5657
- if (!id) {
5658
- break;
5659
- }
5660
- const childNode = tree.nodes.get(id);
5349
+ const children = Array.from(root.children);
5350
+ while (children.length > 0) {
5351
+ const childNode = children.shift();
5661
5352
  if (childNode) {
5662
5353
  ancestors.push(childNode.entry);
5663
- const newChildIds = Array.from(childNode.childrenIds);
5664
- childIds.push(...newChildIds);
5354
+ const newChildIds = Array.from(childNode.children);
5355
+ children.push(...newChildIds);
5665
5356
  }
5666
5357
  }
5667
5358
  return ancestors;