@paulirish/trace_engine 0.0.67 → 0.0.69

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.
Files changed (169) hide show
  1. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  2. package/README.md +17 -1
  3. package/core/common/ParsedURL.d.ts +0 -2
  4. package/core/common/ParsedURL.js +3 -3
  5. package/core/common/ParsedURL.js.map +1 -1
  6. package/core/platform/StringUtilities.d.ts +15 -4
  7. package/core/platform/StringUtilities.js +48 -12
  8. package/core/platform/StringUtilities.js.map +1 -1
  9. package/generated/protocol.d.ts +89 -19
  10. package/generated/protocol.js +9 -4
  11. package/locales/af.json +12 -12
  12. package/locales/am.json +19 -19
  13. package/locales/ar.json +56 -56
  14. package/locales/as.json +69 -69
  15. package/locales/az.json +22 -22
  16. package/locales/be.json +46 -46
  17. package/locales/bg.json +17 -17
  18. package/locales/bn.json +76 -76
  19. package/locales/bs.json +23 -23
  20. package/locales/ca.json +14 -14
  21. package/locales/cs.json +13 -13
  22. package/locales/cy.json +21 -21
  23. package/locales/da.json +12 -12
  24. package/locales/de.json +10 -10
  25. package/locales/el.json +14 -14
  26. package/locales/en-GB.json +73 -73
  27. package/locales/en-US.json +3 -6
  28. package/locales/en-XL.json +3 -6
  29. package/locales/es-419.json +64 -64
  30. package/locales/es.json +44 -44
  31. package/locales/et.json +48 -48
  32. package/locales/eu.json +18 -18
  33. package/locales/fa.json +39 -39
  34. package/locales/fi.json +11 -11
  35. package/locales/fil.json +34 -34
  36. package/locales/fr-CA.json +49 -49
  37. package/locales/fr.json +18 -18
  38. package/locales/gl.json +33 -33
  39. package/locales/gu.json +39 -39
  40. package/locales/he.json +72 -72
  41. package/locales/hi.json +40 -40
  42. package/locales/hr.json +26 -26
  43. package/locales/hu.json +56 -56
  44. package/locales/hy.json +19 -19
  45. package/locales/id.json +68 -68
  46. package/locales/is.json +11 -11
  47. package/locales/it.json +44 -44
  48. package/locales/ja.json +15 -15
  49. package/locales/ka.json +68 -68
  50. package/locales/kk.json +44 -44
  51. package/locales/km.json +18 -18
  52. package/locales/kn.json +28 -28
  53. package/locales/ko.json +11 -11
  54. package/locales/ky.json +22 -22
  55. package/locales/lo.json +33 -33
  56. package/locales/lt.json +9 -9
  57. package/locales/lv.json +35 -35
  58. package/locales/mk.json +18 -18
  59. package/locales/ml.json +19 -19
  60. package/locales/mn.json +40 -40
  61. package/locales/mr.json +12 -12
  62. package/locales/ms.json +15 -15
  63. package/locales/my.json +62 -62
  64. package/locales/ne.json +42 -42
  65. package/locales/nl.json +33 -33
  66. package/locales/no.json +17 -17
  67. package/locales/or.json +54 -54
  68. package/locales/pa.json +24 -24
  69. package/locales/pl.json +32 -32
  70. package/locales/pt-PT.json +12 -12
  71. package/locales/pt.json +41 -41
  72. package/locales/ro.json +11 -11
  73. package/locales/ru.json +40 -40
  74. package/locales/si.json +36 -36
  75. package/locales/sk.json +65 -65
  76. package/locales/sl.json +13 -13
  77. package/locales/sq.json +21 -21
  78. package/locales/sr-Latn.json +17 -17
  79. package/locales/sr.json +17 -17
  80. package/locales/sv.json +13 -13
  81. package/locales/sw.json +69 -69
  82. package/locales/ta.json +39 -39
  83. package/locales/te.json +38 -38
  84. package/locales/th.json +38 -38
  85. package/locales/tr.json +17 -17
  86. package/locales/uk.json +23 -23
  87. package/locales/ur.json +13 -13
  88. package/locales/uz.json +15 -15
  89. package/locales/vi.json +43 -43
  90. package/locales/zh-HK.json +38 -38
  91. package/locales/zh-TW.json +35 -35
  92. package/locales/zh.json +73 -73
  93. package/locales/zu.json +53 -53
  94. package/models/cpu_profile/CPUProfileDataModel.d.ts +0 -33
  95. package/models/cpu_profile/CPUProfileDataModel.js +14 -14
  96. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
  97. package/models/cpu_profile/ProfileTreeModel.d.ts +1 -2
  98. package/models/cpu_profile/ProfileTreeModel.js +4 -4
  99. package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
  100. package/models/trace/EventsSerializer.js +1 -13
  101. package/models/trace/EventsSerializer.js.map +1 -1
  102. package/models/trace/LanternComputationData.js +36 -10
  103. package/models/trace/LanternComputationData.js.map +1 -1
  104. package/models/trace/ModelImpl.js +0 -2
  105. package/models/trace/ModelImpl.js.map +1 -1
  106. package/models/trace/Processor.js +16 -8
  107. package/models/trace/Processor.js.map +1 -1
  108. package/models/trace/extras/ThirdParties.js +4 -6
  109. package/models/trace/extras/ThirdParties.js.map +1 -1
  110. package/models/trace/extras/TraceFilter.d.ts +1 -0
  111. package/models/trace/extras/TraceFilter.js +18 -8
  112. package/models/trace/extras/TraceFilter.js.map +1 -1
  113. package/models/trace/extras/TraceTree.d.ts +13 -16
  114. package/models/trace/extras/TraceTree.js +161 -110
  115. package/models/trace/extras/TraceTree.js.map +1 -1
  116. package/models/trace/handlers/ExtensionTraceDataHandler.d.ts +0 -5
  117. package/models/trace/handlers/ExtensionTraceDataHandler.js +0 -5
  118. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
  119. package/models/trace/handlers/FlowsHandler.js +34 -19
  120. package/models/trace/handlers/FlowsHandler.js.map +1 -1
  121. package/models/trace/handlers/InitiatorsHandler.js +22 -34
  122. package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
  123. package/models/trace/handlers/LayoutShiftsHandler.js +2 -6
  124. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  125. package/models/trace/handlers/MetaHandler.js +3 -0
  126. package/models/trace/handlers/MetaHandler.js.map +1 -1
  127. package/models/trace/handlers/NetworkRequestsHandler.js +12 -6
  128. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  129. package/models/trace/handlers/RendererHandler.js +7 -6
  130. package/models/trace/handlers/RendererHandler.js.map +1 -1
  131. package/models/trace/handlers/SamplesHandler.d.ts +0 -1
  132. package/models/trace/handlers/SamplesHandler.js +11 -6
  133. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  134. package/models/trace/handlers/ScriptsHandler.js +24 -22
  135. package/models/trace/handlers/ScriptsHandler.js.map +1 -1
  136. package/models/trace/handlers/types.d.ts +15 -0
  137. package/models/trace/handlers/types.js.map +1 -1
  138. package/models/trace/helpers/Extensions.js +1 -3
  139. package/models/trace/helpers/Extensions.js.map +1 -1
  140. package/models/trace/helpers/SamplesIntegrator.d.ts +17 -14
  141. package/models/trace/helpers/SamplesIntegrator.js +147 -84
  142. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  143. package/models/trace/helpers/SyntheticEvents.d.ts +0 -8
  144. package/models/trace/helpers/SyntheticEvents.js +10 -33
  145. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  146. package/models/trace/helpers/Trace.js +19 -14
  147. package/models/trace/helpers/Trace.js.map +1 -1
  148. package/models/trace/helpers/TreeHelpers.d.ts +13 -1
  149. package/models/trace/helpers/TreeHelpers.js +35 -8
  150. package/models/trace/helpers/TreeHelpers.js.map +1 -1
  151. package/models/trace/insights/DuplicatedJavaScript.js +1 -2
  152. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
  153. package/models/trace/insights/RenderBlocking.js +3 -1
  154. package/models/trace/insights/RenderBlocking.js.map +1 -1
  155. package/models/trace/insights/SlowCSSSelector.js +2 -2
  156. package/models/trace/insights/SlowCSSSelector.js.map +1 -1
  157. package/models/trace/lantern/metrics/LargestContentfulPaint.d.ts +6 -1
  158. package/models/trace/lantern/metrics/LargestContentfulPaint.js +130 -5
  159. package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -1
  160. package/models/trace/lantern/simulation/Simulator.d.ts +4 -0
  161. package/models/trace/lantern/simulation/Simulator.js +8 -1
  162. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  163. package/models/trace/lantern/types/Lantern.d.ts +4 -0
  164. package/models/trace/lantern/types/Lantern.js.map +1 -1
  165. package/models/trace/types/TraceEvents.d.ts +21 -19
  166. package/models/trace/types/TraceEvents.js.map +1 -1
  167. package/package.json +1 -1
  168. package/test/test-trace-engine.mjs +20 -17
  169. package/third_party/legacy-javascript/lib/legacy-javascript.js +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"CPUProfileDataModel.js","sourceRoot":"","sources":["../../../../../../front_end/models/cpu_profile/CPUProfileDataModel.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEpE,MAAM,OAAO,cAAe,SAAQ,WAAW;IACpC,EAAE,CAAS;IACX,IAAI,CAAS;IACtB,gEAAgE;IAChE,kEAAkE;IAClE,qEAAqE;IACrE,+DAA+D;IAC/D,yBAAyB;IACzB,aAAa,CAAiD;IACrD,WAAW,CAAc;IAElC,YAAY,IAAmC,EAAE,gBAAwB,CAAC,kBAAkB;QAC1F,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAK;YACjB,mEAAmE;YACnE,mBAAmB;YACnB,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC;YAClC,mEAAmE;YACnE,mBAAmB;YACnB,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC;YAC1B,mEAAmE;YACnE,mBAAmB;YACnB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC;YAChB,mEAAmE;YACnE,mBAAmB;YACnB,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;YAClC,mEAAmE;YACnE,mBAAmB;YACnB,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;SACR,CAAC;QACnD,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,gBAAgB,CAAC;QACpD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;Q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GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5G,EAAE,QAAQ,CAAC;YACX,MAAM,GAAG,YAAY,CAAC,EAAE,CAAC;QAC3B,CAAC;QACD,KAAK,IAAI,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACvE,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;YACxC,MAAM,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAC;YACpC,qBAAqB,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAC;YAChD,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC/G,EAAE,QAAQ,CAAC;QACb,CAAC;IACH,CAAC;IACD;;OAEG;IACH,WAAW,CAAC,KAAa;QACvB,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/E,CAAC;IACD;;OAEG;IACH,QAAQ,CAAC,MAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IAClD,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF","sourcesContent":["// Copyright 2014 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../core/platform/platform.js';\nimport type * as Protocol from '../../generated/protocol.js';\n\nimport {ProfileNode, ProfileTreeModel} from './ProfileTreeModel.js';\n\nexport class CPUProfileNode extends ProfileNode {\n override id: number;\n override self: number;\n // Position ticks are available in profile nodes coming from CDP\n // profiles and not in those coming from tracing. They are used to\n // calculate the line level execution time shown in the Sources panel\n // after recording a profile. For trace CPU profiles we use the\n // `lines` array instead.\n positionTicks: Protocol.Profiler.PositionTickInfo[]|undefined;\n override deoptReason: string|null;\n\n constructor(node: Protocol.Profiler.ProfileNode, samplingInterval: number /* milliseconds */) {\n const callFrame = node.callFrame || ({\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n functionName: node['functionName'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n scriptId: node['scriptId'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n url: node['url'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n lineNumber: node['lineNumber'] - 1,\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n columnNumber: node['columnNumber'] - 1,\n } as Protocol.Runtime.CallFrame);\n super(callFrame);\n this.id = node.id;\n this.self = (node.hitCount || 0) * samplingInterval;\n this.positionTicks = node.positionTicks;\n // Compatibility: legacy backends could provide \"no reason\" for optimized functions.\n this.deoptReason = node.deoptReason && node.deoptReason !== 'no reason' ? node.deoptReason : null;\n }\n}\n\nexport class CPUProfileDataModel extends ProfileTreeModel {\n profileStartTime: number /* milliseconds */;\n profileEndTime: number /* milliseconds */;\n timestamps: number[];\n samples: number[]|undefined;\n /**\n * Contains trace ids assigned to samples, if any. Trace ids are\n * keyed by the sample index in the profile. These are only created\n * for CPU profiles coming from traces.\n */\n traceIds?: Record<string, number>;\n /**\n * Each item in the `lines` array contains the script line executing\n * when the sample in that array position was taken.\n */\n lines?: number[];\n /**\n * Same as `lines` above, but with the script column.\n */\n columns?: number[];\n totalHitCount: number;\n profileHead: CPUProfileNode;\n /**\n * A cache for the nodes we have parsed.\n * Note: \"Parsed\" nodes are different from the \"Protocol\" nodes, the\n * latter being the raw data we receive from the backend.\n */\n #idToParsedNode!: Map<number, ProfileNode>;\n gcNode?: ProfileNode;\n programNode?: ProfileNode;\n idleNode?: ProfileNode;\n #stackStartTimes?: number[];\n #stackChildrenDuration?: number[];\n constructor(profile: ExtendedProfile) {\n super();\n // @ts-expect-error Legacy types\n const isLegacyFormat = Boolean(profile['head']);\n if (isLegacyFormat) {\n // Legacy format contains raw timestamps and start/stop times are in seconds.\n this.profileStartTime = profile.startTime * 1000;\n this.profileEndTime = profile.endTime * 1000;\n // @ts-expect-error Legacy types\n this.timestamps = profile.timestamps;\n this.compatibilityConversionHeadToNodes(profile);\n } else {\n // Current format encodes timestamps as deltas. Start/stop times are in microseconds.\n this.profileStartTime = profile.startTime / 1000;\n this.profileEndTime = profile.endTime / 1000;\n this.timestamps = this.convertTimeDeltas(profile);\n }\n this.traceIds = profile.traceIds;\n this.samples = profile.samples;\n\n this.lines = profile.lines;\n this.columns = profile.columns;\n this.totalHitCount = 0;\n this.profileHead = this.translateProfileTree(profile.nodes);\n this.initialize(this.profileHead);\n this.extractMetaNodes();\n if (this.samples?.length) {\n this.sortSamples();\n this.normalizeTimestamps();\n this.fixMissingSamples();\n }\n }\n\n private compatibilityConversionHeadToNodes(profile: Protocol.Profiler.Profile): void {\n // @ts-expect-error Legacy types\n if (!profile.head || profile.nodes) {\n return;\n }\n const nodes: Protocol.Profiler.ProfileNode[] = [];\n // @ts-expect-error Legacy types\n convertNodesTree(profile.head);\n profile.nodes = nodes;\n // @ts-expect-error Legacy types\n delete profile.head;\n function convertNodesTree(node: Protocol.Profiler.ProfileNode): number {\n nodes.push(node);\n // @ts-expect-error Legacy types\n node.children = (node.children as Protocol.Profiler.ProfileNode[]).map(convertNodesTree);\n return node.id;\n }\n }\n\n /**\n * Calculate timestamps using timeDeltas. Some CPU profile formats,\n * like the ones contained in traces have timeDeltas instead of\n * timestamps.\n */\n private convertTimeDeltas(profile: Protocol.Profiler.Profile): number[] {\n if (!profile.timeDeltas) {\n return [];\n }\n let lastTimeMicroSec = profile.startTime;\n const timestamps = new Array(profile.timeDeltas.length);\n for (let i = 0; i < profile.timeDeltas.length; ++i) {\n lastTimeMicroSec += profile.timeDeltas[i];\n timestamps[i] = lastTimeMicroSec;\n }\n return timestamps;\n }\n\n /**\n * Creates a Tree of CPUProfileNodes using the Protocol.Profiler.ProfileNodes.\n * As the tree is built, samples of native code (prefixed with \"native \") are\n * filtered out. Samples of filtered nodes are replaced with the parent of the\n * node being filtered.\n *\n * This function supports legacy and new definitions of the CDP Profiler.Profile\n * type.\n */\n private translateProfileTree(nodes: Protocol.Profiler.ProfileNode[]): CPUProfileNode {\n function buildChildrenFromParents(nodes: Protocol.Profiler.ProfileNode[]): void {\n if (nodes[0].children) {\n return;\n }\n nodes[0].children = [];\n for (let i = 1; i < nodes.length; ++i) {\n const node = nodes[i];\n // @ts-expect-error Legacy types\n const parentNode = protocolNodeById.get(node.parent);\n if (!parentNode) {\n continue;\n }\n if (parentNode.children) {\n parentNode.children.push(node.id);\n } else {\n parentNode.children = [node.id];\n }\n }\n }\n\n /**\n * Calculate how many times each node was sampled in the profile, if\n * not available in the profile data.\n */\n function buildHitCountFromSamples(nodes: Protocol.Profiler.ProfileNode[], samples: number[]|undefined): void {\n // If hit count is available, this profile has the new format, so\n // no need to continue.`\n if (typeof (nodes[0].hitCount) === 'number') {\n return;\n }\n if (!samples) {\n throw new Error('Error: Neither hitCount nor samples are present in profile.');\n }\n for (let i = 0; i < nodes.length; ++i) {\n nodes[i].hitCount = 0;\n }\n for (let i = 0; i < samples.length; ++i) {\n const node = protocolNodeById.get(samples[i]);\n if (node?.hitCount === undefined) {\n continue;\n }\n node.hitCount++;\n }\n }\n\n // A cache for the raw nodes received from the traces / CDP.\n const protocolNodeById = new Map<number, Protocol.Profiler.ProfileNode>();\n for (let i = 0; i < nodes.length; ++i) {\n const node = nodes[i];\n protocolNodeById.set(node.id, node);\n }\n\n buildHitCountFromSamples(nodes, this.samples);\n buildChildrenFromParents(nodes);\n this.totalHitCount = nodes.reduce((acc, node) => acc + (node.hitCount || 0), 0);\n const sampleTime = (this.profileEndTime - this.profileStartTime) / this.totalHitCount;\n const root = nodes[0];\n // If a node is filtered out, its samples are replaced with its parent,\n // so we keep track of the which id to use in the samples data.\n const idToUseForRemovedNode = new Map<number, number>([[root.id, root.id]]);\n this.#idToParsedNode = new Map();\n\n const resultRoot = new CPUProfileNode(root, sampleTime);\n this.#idToParsedNode.set(root.id, resultRoot);\n if (!root.children) {\n throw new Error('Missing children for root');\n }\n const parentNodeStack = root.children.map(() => resultRoot);\n const sourceNodeStack = root.children.map(id => protocolNodeById.get(id));\n while (sourceNodeStack.length) {\n let parentNode = parentNodeStack.pop();\n const sourceNode = sourceNodeStack.pop();\n if (!sourceNode || !parentNode) {\n continue;\n }\n if (!sourceNode.children) {\n sourceNode.children = [];\n }\n const targetNode = new CPUProfileNode(sourceNode, sampleTime);\n parentNode.children.push(targetNode);\n parentNode = targetNode;\n\n idToUseForRemovedNode.set(sourceNode.id, parentNode.id);\n parentNodeStack.push.apply(parentNodeStack, sourceNode.children.map(() => parentNode));\n sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children.map(id => protocolNodeById.get(id)));\n this.#idToParsedNode.set(sourceNode.id, targetNode);\n }\n if (this.samples) {\n this.samples = this.samples.map(id => idToUseForRemovedNode.get(id) as number);\n }\n return resultRoot;\n }\n\n /**\n * Sorts the samples array using the timestamps array (there is a one\n * to one matching by index between the two).\n */\n private sortSamples(): void {\n if (!this.timestamps || !this.samples) {\n return;\n }\n\n const timestamps = this.timestamps;\n const samples = this.samples;\n const orderedIndices = timestamps.map((_x, index) => index);\n orderedIndices.sort((a, b) => timestamps[a] - timestamps[b]);\n\n this.timestamps = [];\n this.samples = [];\n\n for (let i = 0; i < orderedIndices.length; i++) {\n const orderedIndex = orderedIndices[i];\n this.timestamps.push(timestamps[orderedIndex]);\n this.samples.push(samples[orderedIndex]);\n }\n }\n\n /**\n * Fills in timestamps and/or time deltas from legacy profiles where\n * they could be missing.\n */\n private normalizeTimestamps(): void {\n if (!this.samples) {\n return;\n }\n let timestamps: number[] = this.timestamps;\n if (!timestamps) {\n // Support loading CPU profiles that are missing timestamps and\n // timedeltas\n const profileStartTime = this.profileStartTime;\n const interval = (this.profileEndTime - profileStartTime) / this.samples.length;\n // Add an extra timestamp used to calculate the last sample duration.\n timestamps = new Array(this.samples.length + 1);\n for (let i = 0; i < timestamps.length; ++i) {\n timestamps[i] = profileStartTime + i * interval;\n }\n this.timestamps = timestamps;\n return;\n }\n\n // Convert samples from micro to milliseconds\n for (let i = 0; i < timestamps.length; ++i) {\n timestamps[i] /= 1000;\n }\n if (this.samples.length === timestamps.length) {\n // Add an extra timestamp used to calculate the last sample duration.\n const lastTimestamp = timestamps.at(-1) || 0;\n const averageIntervalTime = (lastTimestamp - timestamps[0]) / (timestamps.length - 1);\n this.timestamps.push(lastTimestamp + averageIntervalTime);\n }\n this.profileStartTime = timestamps.at(0) || this.profileStartTime;\n this.profileEndTime = timestamps.at(-1) || this.profileEndTime;\n }\n\n /**\n * Some nodes do not refer to JS samples but to V8 system tasks, AKA\n * \"meta\" nodes. This function extracts those nodes from the profile.\n */\n private extractMetaNodes(): void {\n const topLevelNodes = this.profileHead.children;\n for (let i = 0; i < topLevelNodes.length && !(this.gcNode && this.programNode && this.idleNode); i++) {\n const node = topLevelNodes[i];\n if (node.functionName === '(garbage collector)') {\n this.gcNode = node;\n } else if (node.functionName === '(program)') {\n this.programNode = node;\n } else if (node.functionName === '(idle)') {\n this.idleNode = node;\n }\n }\n }\n\n private fixMissingSamples(): void {\n // Sometimes the V8 sampler is not able to parse the JS stack and returns\n // a (program) sample instead. The issue leads to call frames being split\n // apart when they shouldn't.\n // Here's a workaround for that. When there's a single (program) sample\n // between two call stacks sharing the same bottom node, it is replaced\n // with the preceding sample.\n const samples = this.samples;\n if (!samples) {\n return;\n }\n const samplesCount = samples.length;\n if (!this.programNode || samplesCount < 3) {\n return;\n }\n const idToNode = this.#idToParsedNode;\n const programNodeId = this.programNode.id;\n const gcNodeId = this.gcNode ? this.gcNode.id : -1;\n const idleNodeId = this.idleNode ? this.idleNode.id : -1;\n let prevNodeId: number = samples[0];\n let nodeId: number = samples[1];\n for (let sampleIndex = 1; sampleIndex < samplesCount - 1; sampleIndex++) {\n const nextNodeId = samples[sampleIndex + 1];\n const prevNode = idToNode.get(prevNodeId);\n const nextNode = idToNode.get(nextNodeId);\n if (prevNodeId === undefined || nextNodeId === undefined || !prevNode || !nextNode) {\n console.error(`Unexpectedly found undefined nodes: ${prevNodeId} ${nextNodeId}`);\n continue;\n }\n if (nodeId === programNodeId && !isSystemNode(prevNodeId) && !isSystemNode(nextNodeId) &&\n bottomNode(prevNode) === bottomNode(nextNode)) {\n samples[sampleIndex] = prevNodeId;\n }\n prevNodeId = nodeId;\n nodeId = nextNodeId;\n }\n function bottomNode(node: ProfileNode): ProfileNode {\n while (node.parent?.parent) {\n node = node.parent;\n }\n return node;\n }\n function isSystemNode(nodeId: number): boolean {\n return nodeId === programNodeId || nodeId === gcNodeId || nodeId === idleNodeId;\n }\n }\n\n /**\n * Traverses the call tree derived from the samples calling back when a call is opened\n * and when it's closed\n */\n forEachFrame(\n openFrameCallback: (depth: number, node: ProfileNode, sampleIndex: number, timestamp: number) => void,\n closeFrameCallback:\n (depth: number, node: ProfileNode, sampleIndex: number, timestamp: number, dur: number,\n selfTime: number) => void,\n startTime?: number, stopTime?: number): void {\n if (!this.profileHead || !this.samples) {\n return;\n }\n\n startTime = startTime || 0;\n stopTime = stopTime || Infinity;\n const samples = this.samples;\n const timestamps = this.timestamps;\n const idToNode = this.#idToParsedNode;\n const gcNode = this.gcNode;\n const samplesCount = samples.length;\n const startIndex =\n Platform.ArrayUtilities.lowerBound(timestamps, startTime, Platform.ArrayUtilities.DEFAULT_COMPARATOR);\n let stackTop = 0;\n const stackNodes: ProfileNode[] = [];\n let prevId: number = this.profileHead.id;\n let sampleTime;\n let gcParentNode: ProfileNode|null = null;\n\n // Extra slots for gc being put on top,\n // and one at the bottom to allow safe stackTop-1 access.\n const stackDepth = this.maxDepth + 3;\n if (!this.#stackStartTimes) {\n this.#stackStartTimes = new Array(stackDepth);\n }\n const stackStartTimes = this.#stackStartTimes;\n if (!this.#stackChildrenDuration) {\n this.#stackChildrenDuration = new Array(stackDepth);\n }\n const stackChildrenDuration = this.#stackChildrenDuration;\n\n let node;\n let sampleIndex;\n for (sampleIndex = startIndex; sampleIndex < samplesCount; sampleIndex++) {\n sampleTime = timestamps[sampleIndex];\n if (sampleTime >= stopTime) {\n break;\n }\n const id = samples[sampleIndex];\n if (id === prevId) {\n continue;\n }\n node = idToNode.get(id);\n let prevNode: ProfileNode|null = idToNode.get(prevId) || null;\n if (!prevNode) {\n continue;\n }\n\n if (gcNode && node === gcNode) {\n // GC samples have no stack, so we just put GC node on top of the last recorded sample.\n gcParentNode = prevNode;\n openFrameCallback(gcParentNode.depth + 1, gcNode, sampleIndex, sampleTime);\n stackStartTimes[++stackTop] = sampleTime;\n stackChildrenDuration[stackTop] = 0;\n prevId = id;\n continue;\n }\n if (gcNode && prevNode === gcNode && gcParentNode) {\n // end of GC frame\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(\n gcParentNode.depth + 1, gcNode, sampleIndex, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n prevNode = gcParentNode;\n prevId = prevNode.id;\n gcParentNode = null;\n }\n\n // If the depth of this node is greater than the depth of the\n // previous one, new calls happened in between and we need to open\n // them, so track all of them in stackNodes.\n while (node && node.depth > prevNode.depth) {\n stackNodes.push(node);\n node = node.parent;\n }\n\n // If `prevNode` differs from `node`, the current sample was taken\n // after a change in the call stack, meaning that frames in the\n // path of `prevNode` that differ from those in the path of `node`\n // can be closed. So go down to the lowest common ancestor and\n // close current intervals.\n //\n // For example:\n //\n // prevNode node\n // | |\n // v v\n // [---D--]\n // [---C--][--E--]\n // [------B------] <- LCA\n // [------A------]\n //\n // Because a sample was taken with A, B and E in the stack, it\n // means C and D finished and we can close them.\n while (prevNode && prevNode !== node) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(\n prevNode.depth, prevNode, sampleIndex, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n // Track calls to open after previous calls were closed\n // In the example above, this would add E to the tracking stack.\n if (node && node.depth === prevNode.depth) {\n stackNodes.push(node);\n node = node.parent;\n }\n prevNode = prevNode.parent;\n }\n\n // Go up the nodes stack and open new intervals.\n while (stackNodes.length) {\n const currentNode = stackNodes.pop();\n if (!currentNode) {\n break;\n }\n node = currentNode;\n openFrameCallback(currentNode.depth, currentNode, sampleIndex, sampleTime);\n stackStartTimes[++stackTop] = sampleTime;\n stackChildrenDuration[stackTop] = 0;\n }\n\n prevId = id;\n }\n\n // Close remaining intervals.\n sampleTime = timestamps[sampleIndex] || this.profileEndTime;\n if (node && gcParentNode && idToNode.get(prevId) === gcNode) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(\n gcParentNode.depth + 1, node, sampleIndex, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n prevId = gcParentNode.id;\n }\n for (let node = idToNode.get(prevId); node?.parent; node = node.parent) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(node.depth, node, sampleIndex, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n }\n }\n /**\n * Returns the node that corresponds to a given index of a sample.\n */\n nodeByIndex(index: number): ProfileNode|null {\n return this.samples && this.#idToParsedNode.get(this.samples[index]) || null;\n }\n /**\n * Returns the node that corresponds to a given node id.\n */\n nodeById(nodeId: number): ProfileNode|null {\n return this.#idToParsedNode.get(nodeId) || null;\n }\n\n nodes(): ProfileNode[]|null {\n if (!this.#idToParsedNode) {\n return null;\n }\n return [...this.#idToParsedNode.values()];\n }\n}\n\n/** Format used by profiles coming from traces. **/\nexport type ExtendedProfileNode = Protocol.Profiler.ProfileNode&{parent?: number};\nexport type ExtendedProfile = Protocol.Profiler.Profile&{\n nodes: Protocol.Profiler.ProfileNode[] | ExtendedProfileNode[],\n lines?: number[],\n columns?: number[],\n /**\n * A sample can be manually collected with v8::CpuProfiler::collectSample.\n * When this is done an id (trace id) can be passed to the API to\n * identify the collected sample in the resulting CPU profile. We\n * do this for several trace events, to efficiently calculate their\n * stack trace and improve the JS flamechart we build.\n *\n * This property, only present if there's any trace id provided within profileChunks,\n * contains the mapping of the trace ids with the shape traceId -> nodeId.\n */\n traceIds?: Record<string, number>,\n};\n"]}
1
+ {"version":3,"file":"CPUProfileDataModel.js","sourceRoot":"","sources":["../../../../../../front_end/models/cpu_profile/CPUProfileDataModel.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEpE,MAAM,OAAO,cAAe,SAAQ,WAAW;IACpC,EAAE,CAAS;IACX,IAAI,CAAS;IACtB,gEAAgE;IAChE,kEAAkE;IAClE,qEAAqE;IACrE,+DAA+D;IAC/D,yBAAyB;IACzB,aAAa,CAAiD;IACrD,WAAW,CAAc;IAElC,YAAY,IAAmC,EAAE,gBAAwB,CAAC,kBAAkB;QAC1F,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAK;YACjB,mEAAmE;YACnE,mBAAmB;YACnB,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC;YAClC,mEAAmE;YACnE,mBAAmB;YACnB,QAAQ,EAAE,IAAI,CAAC,UAAU,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AAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/E,CAAC;IACD;;OAEG;IACH,QAAQ,CAAC,MAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IAClD,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF","sourcesContent":["// Copyright 2014 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../core/platform/platform.js';\nimport type * as Protocol from '../../generated/protocol.js';\n\nimport {ProfileNode, ProfileTreeModel} from './ProfileTreeModel.js';\n\nexport class CPUProfileNode extends ProfileNode {\n override id: number;\n override self: number;\n // Position ticks are available in profile nodes coming from CDP\n // profiles and not in those coming from tracing. They are used to\n // calculate the line level execution time shown in the Sources panel\n // after recording a profile. For trace CPU profiles we use the\n // `lines` array instead.\n positionTicks: Protocol.Profiler.PositionTickInfo[]|undefined;\n override deoptReason: string|null;\n\n constructor(node: Protocol.Profiler.ProfileNode, samplingInterval: number /* milliseconds */) {\n const callFrame = node.callFrame || ({\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n functionName: node['functionName'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n scriptId: node['scriptId'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n url: node['url'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n lineNumber: node['lineNumber'] - 1,\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n columnNumber: node['columnNumber'] - 1,\n } as Protocol.Runtime.CallFrame);\n super(callFrame);\n this.id = node.id;\n this.self = (node.hitCount || 0) * samplingInterval;\n this.positionTicks = node.positionTicks;\n // Compatibility: legacy backends could provide \"no reason\" for optimized functions.\n this.deoptReason = node.deoptReason && node.deoptReason !== 'no reason' ? node.deoptReason : null;\n }\n}\n\nexport class CPUProfileDataModel extends ProfileTreeModel {\n profileStartTime: number /* milliseconds */;\n profileEndTime: number /* milliseconds */;\n timestamps: number[];\n samples: number[]|undefined;\n /**\n * Contains trace ids assigned to samples, if any. Trace ids are\n * keyed by the sample index in the profile. These are only created\n * for CPU profiles coming from traces.\n */\n traceIds?: Record<string, number>;\n /**\n * Each item in the `lines` array contains the script line executing\n * when the sample in that array position was taken.\n */\n lines?: number[];\n /**\n * Same as `lines` above, but with the script column.\n */\n columns?: number[];\n totalHitCount: number;\n profileHead: CPUProfileNode;\n /**\n * A cache for the nodes we have parsed.\n * Note: \"Parsed\" nodes are different from the \"Protocol\" nodes, the\n * latter being the raw data we receive from the backend.\n */\n #idToParsedNode!: Map<number, ProfileNode>;\n gcNode?: ProfileNode;\n programNode?: ProfileNode;\n idleNode?: ProfileNode;\n #stackStartTimes?: number[];\n #stackChildrenDuration?: number[];\n constructor(profile: ExtendedProfile) {\n super();\n // @ts-expect-error Legacy types\n const isLegacyFormat = Boolean(profile['head']);\n if (isLegacyFormat) {\n // Legacy format contains raw timestamps and start/stop times are in seconds.\n this.profileStartTime = profile.startTime * 1000;\n this.profileEndTime = profile.endTime * 1000;\n // @ts-expect-error Legacy types\n this.timestamps = profile.timestamps;\n this.#compatibilityConversionHeadToNodes(profile);\n } else {\n // Current format encodes timestamps as deltas. Start/stop times are in microseconds.\n this.profileStartTime = profile.startTime / 1000;\n this.profileEndTime = profile.endTime / 1000;\n this.timestamps = this.#convertTimeDeltas(profile);\n }\n this.traceIds = profile.traceIds;\n this.samples = profile.samples;\n\n this.lines = profile.lines;\n this.columns = profile.columns;\n this.totalHitCount = 0;\n this.profileHead = this.#translateProfileTree(profile.nodes);\n this.initialize(this.profileHead);\n this.#extractMetaNodes();\n if (this.samples?.length) {\n this.#sortSamples();\n this.#normalizeTimestamps();\n this.#fixMissingSamples();\n }\n }\n\n #compatibilityConversionHeadToNodes(profile: Protocol.Profiler.Profile): void {\n // @ts-expect-error Legacy types\n if (!profile.head || profile.nodes) {\n return;\n }\n const nodes: Protocol.Profiler.ProfileNode[] = [];\n // @ts-expect-error Legacy types\n convertNodesTree(profile.head);\n profile.nodes = nodes;\n // @ts-expect-error Legacy types\n delete profile.head;\n function convertNodesTree(node: Protocol.Profiler.ProfileNode): number {\n nodes.push(node);\n // @ts-expect-error Legacy types\n node.children = (node.children as Protocol.Profiler.ProfileNode[]).map(convertNodesTree);\n return node.id;\n }\n }\n\n /**\n * Calculate timestamps using timeDeltas. Some CPU profile formats,\n * like the ones contained in traces have timeDeltas instead of\n * timestamps.\n */\n #convertTimeDeltas(profile: Protocol.Profiler.Profile): number[] {\n if (!profile.timeDeltas) {\n return [];\n }\n let lastTimeMicroSec = profile.startTime;\n const timestamps = new Array(profile.timeDeltas.length);\n for (let i = 0; i < profile.timeDeltas.length; ++i) {\n lastTimeMicroSec += profile.timeDeltas[i];\n timestamps[i] = lastTimeMicroSec;\n }\n return timestamps;\n }\n\n /**\n * Creates a Tree of CPUProfileNodes using the Protocol.Profiler.ProfileNodes.\n * As the tree is built, samples of native code (prefixed with \"native \") are\n * filtered out. Samples of filtered nodes are replaced with the parent of the\n * node being filtered.\n *\n * This function supports legacy and new definitions of the CDP Profiler.Profile\n * type.\n */\n #translateProfileTree(nodes: Protocol.Profiler.ProfileNode[]): CPUProfileNode {\n function buildChildrenFromParents(nodes: Protocol.Profiler.ProfileNode[]): void {\n if (nodes[0].children) {\n return;\n }\n nodes[0].children = [];\n for (let i = 1; i < nodes.length; ++i) {\n const node = nodes[i];\n // @ts-expect-error Legacy types\n const parentNode = protocolNodeById.get(node.parent);\n if (!parentNode) {\n continue;\n }\n if (parentNode.children) {\n parentNode.children.push(node.id);\n } else {\n parentNode.children = [node.id];\n }\n }\n }\n\n /**\n * Calculate how many times each node was sampled in the profile, if\n * not available in the profile data.\n */\n function buildHitCountFromSamples(nodes: Protocol.Profiler.ProfileNode[], samples: number[]|undefined): void {\n // If hit count is available, this profile has the new format, so\n // no need to continue.`\n if (typeof (nodes[0].hitCount) === 'number') {\n return;\n }\n if (!samples) {\n throw new Error('Error: Neither hitCount nor samples are present in profile.');\n }\n for (let i = 0; i < nodes.length; ++i) {\n nodes[i].hitCount = 0;\n }\n for (let i = 0; i < samples.length; ++i) {\n const node = protocolNodeById.get(samples[i]);\n if (node?.hitCount === undefined) {\n continue;\n }\n node.hitCount++;\n }\n }\n\n // A cache for the raw nodes received from the traces / CDP.\n const protocolNodeById = new Map<number, Protocol.Profiler.ProfileNode>();\n for (let i = 0; i < nodes.length; ++i) {\n const node = nodes[i];\n protocolNodeById.set(node.id, node);\n }\n\n buildHitCountFromSamples(nodes, this.samples);\n buildChildrenFromParents(nodes);\n this.totalHitCount = nodes.reduce((acc, node) => acc + (node.hitCount || 0), 0);\n const sampleTime = (this.profileEndTime - this.profileStartTime) / this.totalHitCount;\n const root = nodes[0];\n // If a node is filtered out, its samples are replaced with its parent,\n // so we keep track of the which id to use in the samples data.\n const idToUseForRemovedNode = new Map<number, number>([[root.id, root.id]]);\n this.#idToParsedNode = new Map();\n\n const resultRoot = new CPUProfileNode(root, sampleTime);\n this.#idToParsedNode.set(root.id, resultRoot);\n if (!root.children) {\n throw new Error('Missing children for root');\n }\n const parentNodeStack = root.children.map(() => resultRoot);\n const sourceNodeStack = root.children.map(id => protocolNodeById.get(id));\n while (sourceNodeStack.length) {\n let parentNode = parentNodeStack.pop();\n const sourceNode = sourceNodeStack.pop();\n if (!sourceNode || !parentNode) {\n continue;\n }\n if (!sourceNode.children) {\n sourceNode.children = [];\n }\n const targetNode = new CPUProfileNode(sourceNode, sampleTime);\n parentNode.children.push(targetNode);\n parentNode = targetNode;\n\n idToUseForRemovedNode.set(sourceNode.id, parentNode.id);\n parentNodeStack.push.apply(parentNodeStack, sourceNode.children.map(() => parentNode));\n sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children.map(id => protocolNodeById.get(id)));\n this.#idToParsedNode.set(sourceNode.id, targetNode);\n }\n if (this.samples) {\n this.samples = this.samples.map(id => idToUseForRemovedNode.get(id) as number);\n }\n return resultRoot;\n }\n\n /**\n * Sorts the samples array using the timestamps array (there is a one\n * to one matching by index between the two).\n */\n #sortSamples(): void {\n if (!this.timestamps || !this.samples) {\n return;\n }\n\n const timestamps = this.timestamps;\n const samples = this.samples;\n const orderedIndices = timestamps.map((_x, index) => index);\n orderedIndices.sort((a, b) => timestamps[a] - timestamps[b]);\n\n this.timestamps = [];\n this.samples = [];\n\n for (let i = 0; i < orderedIndices.length; i++) {\n const orderedIndex = orderedIndices[i];\n this.timestamps.push(timestamps[orderedIndex]);\n this.samples.push(samples[orderedIndex]);\n }\n }\n\n /**\n * Fills in timestamps and/or time deltas from legacy profiles where\n * they could be missing.\n */\n #normalizeTimestamps(): void {\n if (!this.samples) {\n return;\n }\n let timestamps: number[] = this.timestamps;\n if (!timestamps) {\n // Support loading CPU profiles that are missing timestamps and\n // timedeltas\n const profileStartTime = this.profileStartTime;\n const interval = (this.profileEndTime - profileStartTime) / this.samples.length;\n // Add an extra timestamp used to calculate the last sample duration.\n timestamps = new Array(this.samples.length + 1);\n for (let i = 0; i < timestamps.length; ++i) {\n timestamps[i] = profileStartTime + i * interval;\n }\n this.timestamps = timestamps;\n return;\n }\n\n // Convert samples from micro to milliseconds\n for (let i = 0; i < timestamps.length; ++i) {\n timestamps[i] /= 1000;\n }\n if (this.samples.length === timestamps.length) {\n // Add an extra timestamp used to calculate the last sample duration.\n const lastTimestamp = timestamps.at(-1) || 0;\n const averageIntervalTime = (lastTimestamp - timestamps[0]) / (timestamps.length - 1);\n this.timestamps.push(lastTimestamp + averageIntervalTime);\n }\n this.profileStartTime = timestamps.at(0) || this.profileStartTime;\n this.profileEndTime = timestamps.at(-1) || this.profileEndTime;\n }\n\n /**\n * Some nodes do not refer to JS samples but to V8 system tasks, AKA\n * \"meta\" nodes. This function extracts those nodes from the profile.\n */\n #extractMetaNodes(): void {\n const topLevelNodes = this.profileHead.children;\n for (let i = 0; i < topLevelNodes.length && !(this.gcNode && this.programNode && this.idleNode); i++) {\n const node = topLevelNodes[i];\n if (node.functionName === '(garbage collector)') {\n this.gcNode = node;\n } else if (node.functionName === '(program)') {\n this.programNode = node;\n } else if (node.functionName === '(idle)') {\n this.idleNode = node;\n }\n }\n }\n\n #fixMissingSamples(): void {\n // Sometimes the V8 sampler is not able to parse the JS stack and returns\n // a (program) sample instead. The issue leads to call frames being split\n // apart when they shouldn't.\n // Here's a workaround for that. When there's a single (program) sample\n // between two call stacks sharing the same bottom node, it is replaced\n // with the preceding sample.\n const samples = this.samples;\n if (!samples) {\n return;\n }\n const samplesCount = samples.length;\n if (!this.programNode || samplesCount < 3) {\n return;\n }\n const idToNode = this.#idToParsedNode;\n const programNodeId = this.programNode.id;\n const gcNodeId = this.gcNode ? this.gcNode.id : -1;\n const idleNodeId = this.idleNode ? this.idleNode.id : -1;\n let prevNodeId: number = samples[0];\n let nodeId: number = samples[1];\n for (let sampleIndex = 1; sampleIndex < samplesCount - 1; sampleIndex++) {\n const nextNodeId = samples[sampleIndex + 1];\n const prevNode = idToNode.get(prevNodeId);\n const nextNode = idToNode.get(nextNodeId);\n if (prevNodeId === undefined || nextNodeId === undefined || !prevNode || !nextNode) {\n console.error(`Unexpectedly found undefined nodes: ${prevNodeId} ${nextNodeId}`);\n continue;\n }\n if (nodeId === programNodeId && !isSystemNode(prevNodeId) && !isSystemNode(nextNodeId) &&\n bottomNode(prevNode) === bottomNode(nextNode)) {\n samples[sampleIndex] = prevNodeId;\n }\n prevNodeId = nodeId;\n nodeId = nextNodeId;\n }\n function bottomNode(node: ProfileNode): ProfileNode {\n while (node.parent?.parent) {\n node = node.parent;\n }\n return node;\n }\n function isSystemNode(nodeId: number): boolean {\n return nodeId === programNodeId || nodeId === gcNodeId || nodeId === idleNodeId;\n }\n }\n\n /**\n * Traverses the call tree derived from the samples calling back when a call is opened\n * and when it's closed\n */\n forEachFrame(\n openFrameCallback: (depth: number, node: ProfileNode, sampleIndex: number, timestamp: number) => void,\n closeFrameCallback:\n (depth: number, node: ProfileNode, sampleIndex: number, timestamp: number, dur: number,\n selfTime: number) => void,\n startTime?: number, stopTime?: number): void {\n if (!this.profileHead || !this.samples) {\n return;\n }\n\n startTime = startTime || 0;\n stopTime = stopTime || Infinity;\n const samples = this.samples;\n const timestamps = this.timestamps;\n const idToNode = this.#idToParsedNode;\n const gcNode = this.gcNode;\n const samplesCount = samples.length;\n const startIndex =\n Platform.ArrayUtilities.lowerBound(timestamps, startTime, Platform.ArrayUtilities.DEFAULT_COMPARATOR);\n let stackTop = 0;\n const stackNodes: ProfileNode[] = [];\n let prevId: number = this.profileHead.id;\n let sampleTime;\n let gcParentNode: ProfileNode|null = null;\n\n // Extra slots for gc being put on top,\n // and one at the bottom to allow safe stackTop-1 access.\n const stackDepth = this.maxDepth + 3;\n if (!this.#stackStartTimes) {\n this.#stackStartTimes = new Array(stackDepth);\n }\n const stackStartTimes = this.#stackStartTimes;\n if (!this.#stackChildrenDuration) {\n this.#stackChildrenDuration = new Array(stackDepth);\n }\n const stackChildrenDuration = this.#stackChildrenDuration;\n\n let node;\n let sampleIndex;\n for (sampleIndex = startIndex; sampleIndex < samplesCount; sampleIndex++) {\n sampleTime = timestamps[sampleIndex];\n if (sampleTime >= stopTime) {\n break;\n }\n const id = samples[sampleIndex];\n if (id === prevId) {\n continue;\n }\n node = idToNode.get(id);\n let prevNode: ProfileNode|null = idToNode.get(prevId) || null;\n if (!prevNode) {\n continue;\n }\n\n if (gcNode && node === gcNode) {\n // GC samples have no stack, so we just put GC node on top of the last recorded sample.\n gcParentNode = prevNode;\n openFrameCallback(gcParentNode.depth + 1, gcNode, sampleIndex, sampleTime);\n stackStartTimes[++stackTop] = sampleTime;\n stackChildrenDuration[stackTop] = 0;\n prevId = id;\n continue;\n }\n if (gcNode && prevNode === gcNode && gcParentNode) {\n // end of GC frame\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(\n gcParentNode.depth + 1, gcNode, sampleIndex, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n prevNode = gcParentNode;\n prevId = prevNode.id;\n gcParentNode = null;\n }\n\n // If the depth of this node is greater than the depth of the\n // previous one, new calls happened in between and we need to open\n // them, so track all of them in stackNodes.\n while (node && node.depth > prevNode.depth) {\n stackNodes.push(node);\n node = node.parent;\n }\n\n // If `prevNode` differs from `node`, the current sample was taken\n // after a change in the call stack, meaning that frames in the\n // path of `prevNode` that differ from those in the path of `node`\n // can be closed. So go down to the lowest common ancestor and\n // close current intervals.\n //\n // For example:\n //\n // prevNode node\n // | |\n // v v\n // [---D--]\n // [---C--][--E--]\n // [------B------] <- LCA\n // [------A------]\n //\n // Because a sample was taken with A, B and E in the stack, it\n // means C and D finished and we can close them.\n while (prevNode && prevNode !== node) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(\n prevNode.depth, prevNode, sampleIndex, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n // Track calls to open after previous calls were closed\n // In the example above, this would add E to the tracking stack.\n if (node && node.depth === prevNode.depth) {\n stackNodes.push(node);\n node = node.parent;\n }\n prevNode = prevNode.parent;\n }\n\n // Go up the nodes stack and open new intervals.\n while (stackNodes.length) {\n const currentNode = stackNodes.pop();\n if (!currentNode) {\n break;\n }\n node = currentNode;\n openFrameCallback(currentNode.depth, currentNode, sampleIndex, sampleTime);\n stackStartTimes[++stackTop] = sampleTime;\n stackChildrenDuration[stackTop] = 0;\n }\n\n prevId = id;\n }\n\n // Close remaining intervals.\n sampleTime = timestamps[sampleIndex] || this.profileEndTime;\n if (node && gcParentNode && idToNode.get(prevId) === gcNode) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(\n gcParentNode.depth + 1, node, sampleIndex, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n prevId = gcParentNode.id;\n }\n for (let node = idToNode.get(prevId); node?.parent; node = node.parent) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(node.depth, node, sampleIndex, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n }\n }\n /**\n * Returns the node that corresponds to a given index of a sample.\n */\n nodeByIndex(index: number): ProfileNode|null {\n return this.samples && this.#idToParsedNode.get(this.samples[index]) || null;\n }\n /**\n * Returns the node that corresponds to a given node id.\n */\n nodeById(nodeId: number): ProfileNode|null {\n return this.#idToParsedNode.get(nodeId) || null;\n }\n\n nodes(): ProfileNode[]|null {\n if (!this.#idToParsedNode) {\n return null;\n }\n return [...this.#idToParsedNode.values()];\n }\n}\n\n/** Format used by profiles coming from traces. **/\nexport type ExtendedProfileNode = Protocol.Profiler.ProfileNode&{parent?: number};\nexport type ExtendedProfile = Protocol.Profiler.Profile&{\n nodes: Protocol.Profiler.ProfileNode[] | ExtendedProfileNode[],\n lines?: number[],\n columns?: number[],\n /**\n * A sample can be manually collected with v8::CpuProfiler::collectSample.\n * When this is done an id (trace id) can be passed to the API to\n * identify the collected sample in the resulting CPU profile. We\n * do this for several trace events, to efficiently calculate their\n * stack trace and improve the JS flamechart we build.\n *\n * This property, only present if there's any trace id provided within profileChunks,\n * contains the mapping of the trace ids with the shape traceId -> nodeId.\n */\n traceIds?: Record<string, number>,\n};\n"]}
@@ -20,10 +20,9 @@ export declare class ProfileNode {
20
20
  setOriginalFunctionName(name: string | null): void;
21
21
  }
22
22
  export declare class ProfileTreeModel {
23
+ #private;
23
24
  root: ProfileNode;
24
25
  total: number;
25
26
  maxDepth: number;
26
27
  initialize(root: ProfileNode): void;
27
- private assignDepthsAndParents;
28
- private calculateTotals;
29
28
  }
@@ -46,10 +46,10 @@ export class ProfileTreeModel {
46
46
  maxDepth;
47
47
  initialize(root) {
48
48
  this.root = root;
49
- this.assignDepthsAndParents();
50
- this.total = this.calculateTotals(this.root);
49
+ this.#assignDepthsAndParents();
50
+ this.total = this.#calculateTotals(this.root);
51
51
  }
52
- assignDepthsAndParents() {
52
+ #assignDepthsAndParents() {
53
53
  const root = this.root;
54
54
  root.depth = -1;
55
55
  root.parent = null;
@@ -69,7 +69,7 @@ export class ProfileTreeModel {
69
69
  }
70
70
  }
71
71
  }
72
- calculateTotals(root) {
72
+ #calculateTotals(root) {
73
73
  const nodesToTraverse = [root];
74
74
  const dfsList = [];
75
75
  while (nodesToTraverse.length) {
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileTreeModel.js","sourceRoot":"","sources":["../../../../../../front_end/models/cpu_profile/ProfileTreeModel.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAK7B,MAAM,OAAO,WAAW;IACtB,SAAS,CAA6B;IACtC,OAAO,CAAS;IAChB,IAAI,CAAS;IACb,KAAK,CAAS;IACd,EAAE,CAAS;IACX,MAAM,CAAmB;IACzB,QAAQ,CAAS;IACjB,oBAAoB,GAAgB,IAAI,CAAC;IACzC,KAAK,CAAU;IACf,WAAW,CAAe;IAC1B,YAAY,SAAqC;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,GAAG,SAAS,CAAC,YAAY,IAAI,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,YAAY,EAAE,CAAC;QACnH,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,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AK,GAAG,CAAC,CAAC;YAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC1B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACxB,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;YACjC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;gBAC7B,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;gBACpB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;gBACtB,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,IAAiB;QACvC,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,OAAO,eAAe,CAAC,MAAM,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAI,eAAe,CAAC,GAAG,EAAkB,CAAC;YACpD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAI,OAAO,CAAC,GAAG,EAAkB,CAAC;YAC5C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright 2016 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Platform from '../../core/platform/platform.js';\nimport type * as Protocol from '../../generated/protocol.js';\n\nexport class ProfileNode {\n callFrame: Protocol.Runtime.CallFrame;\n callUID: string;\n self: number;\n total: number;\n id: number;\n parent: ProfileNode|null;\n children: this[];\n originalFunctionName: string|null = null;\n depth!: number;\n deoptReason!: string|null;\n constructor(callFrame: Protocol.Runtime.CallFrame) {\n this.callFrame = callFrame;\n this.callUID = `${callFrame.functionName}@${callFrame.scriptId}:${callFrame.lineNumber}:${callFrame.columnNumber}`;\n this.self = 0;\n this.total = 0;\n this.id = 0;\n this.parent = null;\n this.children = [];\n }\n\n get scriptId(): Protocol.Runtime.ScriptId {\n return String(this.callFrame.scriptId) as Protocol.Runtime.ScriptId;\n }\n\n get url(): Platform.DevToolsPath.UrlString {\n return this.callFrame.url as Platform.DevToolsPath.UrlString;\n }\n\n get lineNumber(): number {\n return this.callFrame.lineNumber;\n }\n\n get columnNumber(): number {\n return this.callFrame.columnNumber;\n }\n\n get functionName(): string {\n return this.originalFunctionName ?? this.callFrame.functionName;\n }\n\n setOriginalFunctionName(name: string|null): void {\n this.originalFunctionName = name;\n }\n}\n\nexport class ProfileTreeModel {\n root!: ProfileNode;\n total!: number;\n maxDepth!: number;\n\n initialize(root: ProfileNode): void {\n this.root = root;\n this.assignDepthsAndParents();\n this.total = this.calculateTotals(this.root);\n }\n\n private assignDepthsAndParents(): void {\n const root = this.root;\n root.depth = -1;\n root.parent = null;\n this.maxDepth = 0;\n const nodesToTraverse = [root];\n while (nodesToTraverse.length) {\n const parent = (nodesToTraverse.pop() as ProfileNode);\n const depth = parent.depth + 1;\n if (depth > this.maxDepth) {\n this.maxDepth = depth;\n }\n const children = parent.children;\n for (const child of children) {\n child.depth = depth;\n child.parent = parent;\n nodesToTraverse.push(child);\n }\n }\n }\n\n private calculateTotals(root: ProfileNode): number {\n const nodesToTraverse = [root];\n const dfsList = [];\n while (nodesToTraverse.length) {\n const node = (nodesToTraverse.pop() as ProfileNode);\n node.total = node.self;\n dfsList.push(node);\n nodesToTraverse.push(...node.children);\n }\n while (dfsList.length > 1) {\n const node = (dfsList.pop() as ProfileNode);\n if (node.parent) {\n node.parent.total += node.total;\n }\n }\n return root.total;\n }\n}\n"]}
1
+ {"version":3,"file":"ProfileTreeModel.js","sourceRoot":"","sources":["../../../../../../front_end/models/cpu_profile/ProfileTreeModel.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAK7B,MAAM,OAAO,WAAW;IACtB,SAAS,CAA6B;IACtC,OAAO,CAAS;IAChB,IAAI,CAAS;IACb,KAAK,CAAS;IACd,EAAE,CAAS;IACX,MAAM,CAAmB;IACzB,QAAQ,CAAS;IACjB,oBAAoB,GAAgB,IAAI,CAAC;IACzC,KAAK,CAAU;IACf,WAAW,CAAe;IAC1B,YAAY,SAAqC;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,GAAG,SAAS,CAAC,YAAY,IAAI,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,YAAY,EAAE,CAAC;QACnH,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAA8B,CAAC;IACtE,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,SAAS,CAAC,GAAsC,CAAC;IAC/D,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;IACnC,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;IACrC,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI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;IAED,gBAAgB,CAAC,IAAiB;QAChC,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,OAAO,eAAe,CAAC,MAAM,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAI,eAAe,CAAC,GAAG,EAAkB,CAAC;YACpD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAI,OAAO,CAAC,GAAG,EAAkB,CAAC;YAC5C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright 2016 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Platform from '../../core/platform/platform.js';\nimport type * as Protocol from '../../generated/protocol.js';\n\nexport class ProfileNode {\n callFrame: Protocol.Runtime.CallFrame;\n callUID: string;\n self: number;\n total: number;\n id: number;\n parent: ProfileNode|null;\n children: this[];\n originalFunctionName: string|null = null;\n depth!: number;\n deoptReason!: string|null;\n constructor(callFrame: Protocol.Runtime.CallFrame) {\n this.callFrame = callFrame;\n this.callUID = `${callFrame.functionName}@${callFrame.scriptId}:${callFrame.lineNumber}:${callFrame.columnNumber}`;\n this.self = 0;\n this.total = 0;\n this.id = 0;\n this.parent = null;\n this.children = [];\n }\n\n get scriptId(): Protocol.Runtime.ScriptId {\n return String(this.callFrame.scriptId) as Protocol.Runtime.ScriptId;\n }\n\n get url(): Platform.DevToolsPath.UrlString {\n return this.callFrame.url as Platform.DevToolsPath.UrlString;\n }\n\n get lineNumber(): number {\n return this.callFrame.lineNumber;\n }\n\n get columnNumber(): number {\n return this.callFrame.columnNumber;\n }\n\n get functionName(): string {\n return this.originalFunctionName ?? this.callFrame.functionName;\n }\n\n setOriginalFunctionName(name: string|null): void {\n this.originalFunctionName = name;\n }\n}\n\nexport class ProfileTreeModel {\n root!: ProfileNode;\n total!: number;\n maxDepth!: number;\n\n initialize(root: ProfileNode): void {\n this.root = root;\n this.#assignDepthsAndParents();\n this.total = this.#calculateTotals(this.root);\n }\n\n #assignDepthsAndParents(): void {\n const root = this.root;\n root.depth = -1;\n root.parent = null;\n this.maxDepth = 0;\n const nodesToTraverse = [root];\n while (nodesToTraverse.length) {\n const parent = (nodesToTraverse.pop() as ProfileNode);\n const depth = parent.depth + 1;\n if (depth > this.maxDepth) {\n this.maxDepth = depth;\n }\n const children = parent.children;\n for (const child of children) {\n child.depth = depth;\n child.parent = parent;\n nodesToTraverse.push(child);\n }\n }\n }\n\n #calculateTotals(root: ProfileNode): number {\n const nodesToTraverse = [root];\n const dfsList = [];\n while (nodesToTraverse.length) {\n const node = (nodesToTraverse.pop() as ProfileNode);\n node.total = node.self;\n dfsList.push(node);\n nodesToTraverse.push(...node.children);\n }\n while (dfsList.length > 1) {\n const node = (dfsList.pop() as ProfileNode);\n if (node.parent) {\n node.parent.total += node.total;\n }\n }\n return root.total;\n }\n}\n"]}
@@ -4,7 +4,6 @@
4
4
  import * as Helpers from './helpers/helpers.js';
5
5
  import * as Types from './types/types.js';
6
6
  export class EventsSerializer {
7
- #modifiedProfileCallByKey = new Map();
8
7
  keyForEvent(event) {
9
8
  if (Types.Events.isProfileCall(event)) {
10
9
  return `${Types.File.EventKeyType.PROFILE_CALL}-${event.pid}-${event.tid}-${Types.Events.SampleIndex(event.sampleIndex)}-${event.nodeId}`;
@@ -67,12 +66,7 @@ export class EventsSerializer {
67
66
  return cluster;
68
67
  }
69
68
  if (EventsSerializer.isSyntheticEventKey(eventValues)) {
70
- const syntheticEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getSyntheticTraces();
71
- const syntheticEvent = syntheticEvents.at(eventValues.rawIndex);
72
- if (!syntheticEvent) {
73
- throw new Error(`Unknown trace event. Attempted to get a synthetic event from an unknown raw event index: ${eventValues.rawIndex}`);
74
- }
75
- return syntheticEvent;
69
+ return Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().syntheticEventForRawEventIndex(eventValues.rawIndex);
76
70
  }
77
71
  if (EventsSerializer.isRawEventKey(eventValues)) {
78
72
  const rawEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents();
@@ -96,10 +90,6 @@ export class EventsSerializer {
96
90
  return key.type === Types.File.EventKeyType.SYNTHETIC_EVENT;
97
91
  }
98
92
  #getModifiedProfileCallByKeyValues(key, parsedTrace) {
99
- const cacheResult = this.#modifiedProfileCallByKey.get(key);
100
- if (cacheResult) {
101
- return cacheResult;
102
- }
103
93
  const profileCallsInThread = parsedTrace.data.Renderer.processes.get(key.processID)?.threads.get(key.threadID)?.profileCalls;
104
94
  if (!profileCallsInThread) {
105
95
  throw new Error(`Unknown profile call serializable key: ${(key)}`);
@@ -110,8 +100,6 @@ export class EventsSerializer {
110
100
  if (!match) {
111
101
  throw new Error(`Unknown profile call serializable key: ${(JSON.stringify(key))}`);
112
102
  }
113
- // Cache to avoid looking up in subsequent calls.
114
- this.#modifiedProfileCallByKey.set(key, match);
115
103
  return match;
116
104
  }
117
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EventsSerializer.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/EventsSerializer.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,MAAM,OAAO,gBAA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,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC;QACpG,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrE,CAAC;QAED,MAAM,KAAK,GAAG,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAoC,EAAE,EAAE;YAChF,OAAO,CAAC,CAAC,WAAW,KAAK,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,QAAQ,CAAC;QACxE,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACrF,CAAC;QACD,iDAAiD;QACjD,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Helpers from './helpers/helpers.js';\nimport type {ParsedTrace} from './ModelImpl.js';\nimport * as Types from './types/types.js';\n\nexport class EventsSerializer {\n #modifiedProfileCallByKey = new Map<Types.File.ProfileCallKeyValues, Types.Events.SyntheticProfileCall>();\n\n keyForEvent(event: Types.Events.Event): Types.File.SerializableKey|null {\n if (Types.Events.isProfileCall(event)) {\n return `${Types.File.EventKeyType.PROFILE_CALL}-${event.pid}-${event.tid}-${\n Types.Events.SampleIndex(event.sampleIndex)}-${event.nodeId}`;\n }\n\n if (Types.Events.isLegacyTimelineFrame(event)) {\n return `${Types.File.EventKeyType.LEGACY_TIMELINE_FRAME}-${event.index}`;\n }\n\n if (Types.Events.isJSSample(event)) {\n return null;\n }\n\n const rawEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents();\n\n if (Types.Events.isSyntheticLayoutShiftCluster(event)) {\n // A cluster has no raw event of its own, so it is keyed by the raw event\n // of its first layout shift.\n const firstShift = event.events.at(0);\n if (!firstShift) {\n return null;\n }\n const firstShiftIndex = rawEvents.indexOf(firstShift.rawSourceEvent);\n if (firstShiftIndex === -1) {\n return null;\n }\n return `${Types.File.EventKeyType.LAYOUT_SHIFT_CLUSTER}-${firstShiftIndex}`;\n }\n\n const isSynthetic = Types.Events.isSyntheticBased(event);\n const index = rawEvents.indexOf(isSynthetic ? event.rawSourceEvent : event);\n if (index === -1) {\n return null;\n }\n\n const key: Types.File.SyntheticEventKey|Types.File.RawEventKey = Types.Events.isSyntheticBased(event) ?\n `${Types.File.EventKeyType.SYNTHETIC_EVENT}-${index}` :\n `${Types.File.EventKeyType.RAW_EVENT}-${index}`;\n if (key.length < 3) {\n return null;\n }\n return key;\n }\n\n eventForKey(key: Types.File.SerializableKey, parsedTrace: ParsedTrace): Types.Events.Event {\n const eventValues = Types.File.traceEventKeyToValues(key);\n\n if (EventsSerializer.isProfileCallKey(eventValues)) {\n return this.#getModifiedProfileCallByKeyValues(eventValues, parsedTrace);\n }\n\n if (EventsSerializer.isLegacyTimelineFrameKey(eventValues)) {\n const event = parsedTrace.data.Frames.frames.at(eventValues.rawIndex);\n if (!event) {\n throw new Error(`Unknown trace event. Could not find frame with index ${eventValues.rawIndex}`);\n }\n return event;\n }\n\n if (EventsSerializer.isLayoutShiftClusterKey(eventValues)) {\n const rawEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents();\n const firstShiftRawEvent = rawEvents.at(eventValues.rawIndex);\n const cluster = parsedTrace.data.LayoutShifts.clusters.find(cluster => {\n const firstShift = cluster.events.at(0);\n return firstShift !== undefined && firstShift.rawSourceEvent === firstShiftRawEvent;\n });\n if (!cluster) {\n throw new Error(\n `Unknown trace event. Could not find layout shift cluster with first shift index ${eventValues.rawIndex}`);\n }\n return cluster;\n }\n\n if (EventsSerializer.isSyntheticEventKey(eventValues)) {\n const syntheticEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getSyntheticTraces();\n const syntheticEvent = syntheticEvents.at(eventValues.rawIndex);\n if (!syntheticEvent) {\n throw new Error(`Unknown trace event. Attempted to get a synthetic event from an unknown raw event index: ${\n eventValues.rawIndex}`);\n }\n return syntheticEvent;\n }\n\n if (EventsSerializer.isRawEventKey(eventValues)) {\n const rawEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents();\n return rawEvents[eventValues.rawIndex];\n }\n throw new Error(`Unknown trace event. Serializable key values: ${(eventValues as unknown[]).join('-')}`);\n }\n\n static isProfileCallKey(key: Types.File.SerializableKeyValues): key is Types.File.ProfileCallKeyValues {\n return key.type === Types.File.EventKeyType.PROFILE_CALL;\n }\n static isLegacyTimelineFrameKey(key: Types.File.SerializableKeyValues):\n key is Types.File.LegacyTimelineFrameKeyValues {\n return key.type === Types.File.EventKeyType.LEGACY_TIMELINE_FRAME;\n }\n\n static isLayoutShiftClusterKey(key: Types.File.SerializableKeyValues): key is Types.File.LayoutShiftClusterKeyValues {\n return key.type === Types.File.EventKeyType.LAYOUT_SHIFT_CLUSTER;\n }\n\n static isRawEventKey(key: Types.File.SerializableKeyValues): key is Types.File.RawEventKeyValues {\n return key.type === Types.File.EventKeyType.RAW_EVENT;\n }\n static isSyntheticEventKey(key: Types.File.SerializableKeyValues): key is Types.File.SyntheticEventKeyValues {\n return key.type === Types.File.EventKeyType.SYNTHETIC_EVENT;\n }\n\n #getModifiedProfileCallByKeyValues(key: Types.File.ProfileCallKeyValues,\n parsedTrace: ParsedTrace): Types.Events.SyntheticProfileCall {\n const cacheResult = this.#modifiedProfileCallByKey.get(key);\n if (cacheResult) {\n return cacheResult;\n }\n const profileCallsInThread =\n parsedTrace.data.Renderer.processes.get(key.processID)?.threads.get(key.threadID)?.profileCalls;\n if (!profileCallsInThread) {\n throw new Error(`Unknown profile call serializable key: ${(key)}`);\n }\n\n const match = profileCallsInThread?.find((e: Types.Events.SyntheticProfileCall) => {\n return e.sampleIndex === key.sampleIndex && e.nodeId === key.protocol;\n });\n if (!match) {\n throw new Error(`Unknown profile call serializable key: ${(JSON.stringify(key))}`);\n }\n // Cache to avoid looking up in subsequent calls.\n this.#modifiedProfileCallByKey.set(key, match);\n return match;\n }\n}\n"]}
1
+ {"version":3,"file":"EventsSerializer.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/EventsSerializer.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,MAAM,OAAO,gBAAgB;IAC3B,WAAW,CAAC,KAAyB;QACnC,IAAI,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACtC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IACpE,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACpE,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,qBAAqB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC3E,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,sBAAsB,C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AAY,CAAC,eAAe,CAAC;IAC9D,CAAC;IAED,kCAAkC,CAAC,GAAoC,EACpC,WAAwB;QACzD,MAAM,oBAAoB,GACtB,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC;QACpG,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrE,CAAC;QAED,MAAM,KAAK,GAAG,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAoC,EAAE,EAAE;YAChF,OAAO,CAAC,CAAC,WAAW,KAAK,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,QAAQ,CAAC;QACxE,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Helpers from './helpers/helpers.js';\nimport type {ParsedTrace} from './ModelImpl.js';\nimport * as Types from './types/types.js';\n\nexport class EventsSerializer {\n keyForEvent(event: Types.Events.Event): Types.File.SerializableKey|null {\n if (Types.Events.isProfileCall(event)) {\n return `${Types.File.EventKeyType.PROFILE_CALL}-${event.pid}-${event.tid}-${\n Types.Events.SampleIndex(event.sampleIndex)}-${event.nodeId}`;\n }\n\n if (Types.Events.isLegacyTimelineFrame(event)) {\n return `${Types.File.EventKeyType.LEGACY_TIMELINE_FRAME}-${event.index}`;\n }\n\n if (Types.Events.isJSSample(event)) {\n return null;\n }\n\n const rawEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents();\n\n if (Types.Events.isSyntheticLayoutShiftCluster(event)) {\n // A cluster has no raw event of its own, so it is keyed by the raw event\n // of its first layout shift.\n const firstShift = event.events.at(0);\n if (!firstShift) {\n return null;\n }\n const firstShiftIndex = rawEvents.indexOf(firstShift.rawSourceEvent);\n if (firstShiftIndex === -1) {\n return null;\n }\n return `${Types.File.EventKeyType.LAYOUT_SHIFT_CLUSTER}-${firstShiftIndex}`;\n }\n\n const isSynthetic = Types.Events.isSyntheticBased(event);\n const index = rawEvents.indexOf(isSynthetic ? event.rawSourceEvent : event);\n if (index === -1) {\n return null;\n }\n\n const key: Types.File.SyntheticEventKey|Types.File.RawEventKey = Types.Events.isSyntheticBased(event) ?\n `${Types.File.EventKeyType.SYNTHETIC_EVENT}-${index}` :\n `${Types.File.EventKeyType.RAW_EVENT}-${index}`;\n if (key.length < 3) {\n return null;\n }\n return key;\n }\n\n eventForKey(key: Types.File.SerializableKey, parsedTrace: ParsedTrace): Types.Events.Event {\n const eventValues = Types.File.traceEventKeyToValues(key);\n\n if (EventsSerializer.isProfileCallKey(eventValues)) {\n return this.#getModifiedProfileCallByKeyValues(eventValues, parsedTrace);\n }\n\n if (EventsSerializer.isLegacyTimelineFrameKey(eventValues)) {\n const event = parsedTrace.data.Frames.frames.at(eventValues.rawIndex);\n if (!event) {\n throw new Error(`Unknown trace event. Could not find frame with index ${eventValues.rawIndex}`);\n }\n return event;\n }\n\n if (EventsSerializer.isLayoutShiftClusterKey(eventValues)) {\n const rawEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents();\n const firstShiftRawEvent = rawEvents.at(eventValues.rawIndex);\n const cluster = parsedTrace.data.LayoutShifts.clusters.find(cluster => {\n const firstShift = cluster.events.at(0);\n return firstShift !== undefined && firstShift.rawSourceEvent === firstShiftRawEvent;\n });\n if (!cluster) {\n throw new Error(\n `Unknown trace event. Could not find layout shift cluster with first shift index ${eventValues.rawIndex}`);\n }\n return cluster;\n }\n\n if (EventsSerializer.isSyntheticEventKey(eventValues)) {\n return Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().syntheticEventForRawEventIndex(\n eventValues.rawIndex);\n }\n\n if (EventsSerializer.isRawEventKey(eventValues)) {\n const rawEvents = Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents();\n return rawEvents[eventValues.rawIndex];\n }\n throw new Error(`Unknown trace event. Serializable key values: ${(eventValues as unknown[]).join('-')}`);\n }\n\n static isProfileCallKey(key: Types.File.SerializableKeyValues): key is Types.File.ProfileCallKeyValues {\n return key.type === Types.File.EventKeyType.PROFILE_CALL;\n }\n static isLegacyTimelineFrameKey(key: Types.File.SerializableKeyValues):\n key is Types.File.LegacyTimelineFrameKeyValues {\n return key.type === Types.File.EventKeyType.LEGACY_TIMELINE_FRAME;\n }\n\n static isLayoutShiftClusterKey(key: Types.File.SerializableKeyValues): key is Types.File.LayoutShiftClusterKeyValues {\n return key.type === Types.File.EventKeyType.LAYOUT_SHIFT_CLUSTER;\n }\n\n static isRawEventKey(key: Types.File.SerializableKeyValues): key is Types.File.RawEventKeyValues {\n return key.type === Types.File.EventKeyType.RAW_EVENT;\n }\n static isSyntheticEventKey(key: Types.File.SerializableKeyValues): key is Types.File.SyntheticEventKeyValues {\n return key.type === Types.File.EventKeyType.SYNTHETIC_EVENT;\n }\n\n #getModifiedProfileCallByKeyValues(key: Types.File.ProfileCallKeyValues,\n parsedTrace: ParsedTrace): Types.Events.SyntheticProfileCall {\n const profileCallsInThread =\n parsedTrace.data.Renderer.processes.get(key.processID)?.threads.get(key.threadID)?.profileCalls;\n if (!profileCallsInThread) {\n throw new Error(`Unknown profile call serializable key: ${(key)}`);\n }\n\n const match = profileCallsInThread?.find((e: Types.Events.SyntheticProfileCall) => {\n return e.sampleIndex === key.sampleIndex && e.nodeId === key.protocol;\n });\n if (!match) {\n throw new Error(`Unknown profile call serializable key: ${(JSON.stringify(key))}`);\n }\n return match;\n }\n}\n"]}
@@ -27,12 +27,16 @@ function createProcessedNavigation(data, frameId, navigation) {
27
27
  return metricScore.event.ts;
28
28
  };
29
29
  const lcpScore = scores.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);
30
+ const navigationId = navigation.args.data?.navigationId;
31
+ const lcpRequest = navigationId ? data.LargestImagePaint?.lcpRequestByNavigationId.get(navigationId) : undefined;
30
32
  return {
31
33
  timestamps: {
32
34
  firstContentfulPaint: getTimestamp(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FCP),
33
35
  largestContentfulPaint: getTimestampOrUndefined(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP),
34
36
  },
35
37
  largestContentfulPaintEvt: lcpScore && Handlers.ModelHandlers.PageLoadMetrics.metricIsLCP(lcpScore) ? lcpScore.event : undefined,
38
+ lcpRequestId: lcpRequest?.args.data.requestId,
39
+ lcpImageUrl: lcpRequest?.args.data.url,
36
40
  };
37
41
  }
38
42
  function createParsedUrl(url) {
@@ -46,6 +50,19 @@ function createParsedUrl(url) {
46
50
  securityOrigin: url.origin,
47
51
  };
48
52
  }
53
+ /**
54
+ * ResourceSendRequest URLs in the trace retain #hash fragments, whereas CDP
55
+ * Network.requestWillBeSent, Page.frameNavigated, initiator.url, documentURL,
56
+ * and V8 script events strip #hash fragments, and NetworkAnalyzer requires
57
+ * request.url not to have a fragment.
58
+ */
59
+ function stripUrlHash(url, rawUrl) {
60
+ if (!rawUrl.includes('#')) {
61
+ return rawUrl;
62
+ }
63
+ url.hash = '';
64
+ return url.href;
65
+ }
49
66
  /**
50
67
  * Returns a map of `pid` -> `tid[]`.
51
68
  */
@@ -141,7 +158,7 @@ function createLanternRequest(parsedTrace, workerThreads, request) {
141
158
  requestId: request.args.data.requestId,
142
159
  connectionId: request.args.data.connectionId ?? 0,
143
160
  connectionReused: request.args.data.connectionReused ?? false,
144
- url: request.args.data.url,
161
+ url: stripUrlHash(url, request.args.data.url),
145
162
  protocol: request.args.data.protocol,
146
163
  parsedURL: createParsedUrl(url),
147
164
  documentURL: request.args.data.requestingFrameUrl,
@@ -283,8 +300,9 @@ function createNetworkRequests(trace, data, startTime = 0, endTime = Number.POSI
283
300
  pushStart: -1,
284
301
  pushEnd: -1,
285
302
  };
286
- redirectedRequest.url = redirect.url;
287
- redirectedRequest.parsedURL = createParsedUrl(redirect.url);
303
+ const redirectUrl = new URL(redirect.url);
304
+ redirectedRequest.url = stripUrlHash(redirectUrl, redirect.url);
305
+ redirectedRequest.parsedURL = createParsedUrl(redirectUrl);
288
306
  // TODO: Trace Engine is not retaining the actual status code.
289
307
  redirectedRequest.statusCode = 302;
290
308
  redirectedRequest.resourceType = undefined;
@@ -352,15 +370,23 @@ function createGraph(requests, trace, data, url) {
352
370
  // url defines the initial request that the Lantern graph starts at (the root node) and the
353
371
  // main document request. These are equal if there are no redirects.
354
372
  if (!url) {
373
+ if (!requests.length) {
374
+ throw new Lantern.Core.LanternError('No network requests found in trace');
375
+ }
376
+ const followRedirects = (request) => {
377
+ while (request.redirectDestination) {
378
+ request = request.redirectDestination;
379
+ }
380
+ return request;
381
+ };
382
+ const isMainFrameDoc = (r) => r.frameId === data.Meta.mainFrameId && followRedirects(r).resourceType === 'Document';
383
+ const isAnyDoc = (r) => followRedirects(r).resourceType === 'Document';
384
+ const initialRequest = requests.find(isMainFrameDoc) ?? requests.find(isAnyDoc) ?? requests[0];
385
+ const lastDocChainStart = requests.findLast(isMainFrameDoc) ?? requests.findLast(isAnyDoc) ?? requests[0];
355
386
  url = {
356
- requestedUrl: requests[0].url,
357
- mainDocumentUrl: '',
387
+ requestedUrl: initialRequest.url,
388
+ mainDocumentUrl: followRedirects(lastDocChainStart).url,
358
389
  };
359
- let request = requests[0];
360
- while (request.redirectDestination) {
361
- request = request.redirectDestination;
362
- }
363
- url.mainDocumentUrl = request.url;
364
390
  }
365
391
  return Lantern.Graph.PageDependencyGraph.createGraph(mainThreadEvents, requests, url);
366
392
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LanternComputationData.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/LanternComputationData.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAI7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAKhD,SAAS,yBAAyB,CAC9B,IAAgC,EAAE,OAAe,EACjD,UAAwC;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,iCAAiC,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,gDAAgD,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,uBAAuB,GACzB,CAAC,MAAyD,EAAgC,EAAE;QAC1F,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QACD,OAAO,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;IAC9B,CAAC,CAAC;IACN,MAAM,YAAY,GAAG,CAAC,MAAyD,EAAsB,EAAE;QACrG,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;QACnE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Content":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Protocol from '../../generated/protocol.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Lantern from './lantern/lantern.js';\nimport type * as Types from './types/types.js';\n\ntype NetworkRequest = Lantern.Types.NetworkRequest<Types.Events.SyntheticNetworkRequest>;\n\nfunction createProcessedNavigation(\n data: Handlers.Types.HandlerData, frameId: string,\n navigation: Types.Events.NavigationStart): Lantern.Types.Simulation.ProcessedNavigation {\n const scoresByNav = data.PageLoadMetrics.metricScoresByFrameId.get(frameId);\n if (!scoresByNav) {\n throw new Lantern.Core.LanternError('missing metric scores for frame');\n }\n\n const scores = scoresByNav.get(navigation);\n if (!scores) {\n throw new Lantern.Core.LanternError('missing metric scores for specified navigation');\n }\n\n const getTimestampOrUndefined =\n (metric: Handlers.ModelHandlers.PageLoadMetrics.MetricName): Types.Timing.Micro|undefined => {\n const metricScore = scores.get(metric);\n if (!metricScore?.event) {\n return;\n }\n return metricScore.event.ts;\n };\n const getTimestamp = (metric: Handlers.ModelHandlers.PageLoadMetrics.MetricName): Types.Timing.Micro => {\n const metricScore = scores.get(metric);\n if (!metricScore?.event) {\n throw new Lantern.Core.LanternError(`missing metric: ${metric}`);\n }\n return metricScore.event.ts;\n };\n const lcpScore = scores.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);\n return {\n timestamps: {\n firstContentfulPaint: getTimestamp(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FCP),\n largestContentfulPaint: getTimestampOrUndefined(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP),\n },\n largestContentfulPaintEvt:\n lcpScore && Handlers.ModelHandlers.PageLoadMetrics.metricIsLCP(lcpScore) ? lcpScore.event : undefined,\n };\n}\n\nfunction createParsedUrl(url: URL|string): Lantern.Types.ParsedURL {\n if (typeof url === 'string') {\n url = new URL(url);\n }\n return {\n scheme: url.protocol.split(':')[0],\n // Intentional, DevTools uses different terminology\n host: url.hostname,\n securityOrigin: url.origin,\n };\n}\n\n/**\n * Returns a map of `pid` -> `tid[]`.\n */\nfunction findWorkerThreads(trace: Lantern.Types.Trace): Map<number, number[]> {\n // TODO: WorkersHandler in Trace Engine needs to be updated to also include `pid` (only had `tid`).\n const workerThreads = new Map();\n const workerCreationEvents = ['ServiceWorker thread', 'DedicatedWorker thread'];\n\n for (const event of trace.traceEvents) {\n if (event.name !== 'thread_name' || !event.args.name) {\n continue;\n }\n if (!workerCreationEvents.includes(event.args.name)) {\n continue;\n }\n\n const tids = workerThreads.get(event.pid);\n if (tids) {\n tids.push(event.tid);\n } else {\n workerThreads.set(event.pid, [event.tid]);\n }\n }\n\n return workerThreads;\n}\n\nfunction createLanternRequest(\n parsedTrace: Readonly<Handlers.Types.HandlerData>, workerThreads: Map<number, number[]>,\n request: Types.Events.SyntheticNetworkRequest): NetworkRequest|undefined {\n if (request.args.data.hasResponse && request.args.data.connectionId === undefined) {\n throw new Lantern.Core.LanternError('Trace is too old');\n }\n\n let url;\n try {\n url = new URL(request.args.data.url);\n } catch {\n return;\n }\n\n const timing = request.args.data.timing ? {\n // These two timings are not included in the trace.\n workerFetchStart: -1,\n workerRespondWithSettled: -1,\n receiveHeadersStart: -1,\n ...request.args.data.timing,\n } :\n undefined;\n\n const networkRequestTime = timing ? timing.requestTime * 1000 : request.args.data.syntheticData.downloadStart / 1000;\n\n let fromWorker = false;\n const tids = workerThreads.get(request.pid);\n if (tids?.includes(request.tid)) {\n fromWorker = true;\n }\n\n // Trace Engine collects worker thread ids in a different manner than `workerThreads` does.\n // AFAIK these should be equivalent, but in case they are not let's also check this for now.\n if (parsedTrace.Workers.workerIdByThread.has(request.tid)) {\n fromWorker = true;\n }\n\n // `initiator` in the trace does not contain the stack trace for JS-initiated\n // requests. Instead, that is stored in the `stackTrace` property of the SyntheticNetworkRequest.\n // There are some minor differences in the fields, accounted for here.\n // Most importantly, there seems to be fewer frames in the trace than the equivalent\n // events over the CDP. This results in less accuracy in determining the initiator request,\n // which means less edges in the graph, which mean worse results.\n // TODO: Should fix in Chromium.\n const initiator: Lantern.Types.NetworkRequest['initiator'] =\n request.args.data.initiator ?? {type: Protocol.Network.InitiatorType.Other};\n if (request.args.data.stackTrace) {\n const callFrames = request.args.data.stackTrace.map(f => {\n return {\n scriptId: String(f.scriptId) as Protocol.Runtime.ScriptId,\n url: f.url,\n lineNumber: f.lineNumber - 1,\n columnNumber: f.columnNumber - 1,\n functionName: f.functionName,\n };\n });\n initiator.stack = {callFrames};\n // Note: there is no `parent` to set ...\n }\n\n let resourceType = request.args.data.resourceType;\n if (request.args.data.initiator?.fetchType === 'xmlhttprequest') {\n // @ts-expect-error yes XHR is a valid ResourceType. TypeScript const enums are so unhelpful.\n resourceType = 'XHR';\n } else if (request.args.data.initiator?.fetchType === 'fetch') {\n // @ts-expect-error yes Fetch is a valid ResourceType. TypeScript const enums are so unhelpful.\n resourceType = 'Fetch';\n }\n\n // NetworkRequestsHandler defaults missing `renderBlocking` to 'non_blocking',\n // so only populate `renderBlocking` when it was explicitly set on the raw\n // ResourceSendRequest event or updated via PreloadRenderBlockingStatusChange.\n const hasExplicitRenderBlocking = request.rawSourceEvent.args.data.renderBlocking !== undefined ||\n request.args.data.renderBlocking !== 'non_blocking';\n const renderBlocking = hasExplicitRenderBlocking ? request.args.data.renderBlocking : undefined;\n\n return {\n rawRequest: request,\n requestId: request.args.data.requestId,\n connectionId: request.args.data.connectionId ?? 0,\n connectionReused: request.args.data.connectionReused ?? false,\n url: request.args.data.url,\n protocol: request.args.data.protocol,\n parsedURL: createParsedUrl(url),\n documentURL: request.args.data.requestingFrameUrl,\n rendererStartTime: request.ts / 1000,\n networkRequestTime,\n responseHeadersEndTime: request.args.data.syntheticData.downloadStart / 1000,\n networkEndTime: request.args.data.syntheticData.finishTime / 1000,\n transferSize: request.args.data.encodedDataLength,\n resourceSize: request.args.data.decodedBodyLength ?? 0,\n fromDiskCache: request.args.data.syntheticData.isDiskCached,\n fromMemoryCache: request.args.data.syntheticData.isMemoryCached,\n isLinkPreload: request.args.data.isLinkPreload,\n finished: request.args.data.finished,\n failed: request.args.data.failed,\n statusCode: request.args.data.statusCode,\n initiator,\n timing,\n resourceType,\n mimeType: request.args.data.mimeType,\n priority: request.args.data.priority,\n renderBlocking,\n frameId: request.args.data.frame,\n fromWorker,\n serverResponseTime: request.args.data.lrServerResponseTime,\n };\n}\n\n/**\n * @param request The request to find the initiator of\n */\nfunction chooseInitiatorRequest(request: NetworkRequest, requestsByURL: Map<string, NetworkRequest[]>): NetworkRequest|\n null {\n if (request.redirectSource) {\n return request.redirectSource;\n }\n\n const initiatorURL = Lantern.Graph.PageDependencyGraph.getNetworkInitiators(request)[0];\n let candidates = requestsByURL.get(initiatorURL) || [];\n // The (valid) initiator must come before the initiated request.\n candidates = candidates.filter(c => {\n return c.responseHeadersEndTime <= request.rendererStartTime && c.finished && !c.failed;\n });\n if (candidates.length > 1) {\n // Disambiguate based on prefetch. Prefetch requests have type 'Other' and cannot\n // initiate requests, so we drop them here.\n const nonPrefetchCandidates =\n candidates.filter(cand => cand.resourceType !== Lantern.Types.NetworkRequestTypes.Other);\n if (nonPrefetchCandidates.length) {\n candidates = nonPrefetchCandidates;\n }\n }\n if (candidates.length > 1) {\n // Disambiguate based on frame. It's likely that the initiator comes from the same frame.\n const sameFrameCandidates = candidates.filter(cand => cand.frameId === request.frameId);\n if (sameFrameCandidates.length) {\n candidates = sameFrameCandidates;\n }\n }\n if (candidates.length > 1 && request.initiator.type === 'parser') {\n // Filter to just Documents when initiator type is parser.\n const documentCandidates =\n candidates.filter(cand => cand.resourceType === Lantern.Types.NetworkRequestTypes.Document);\n if (documentCandidates.length) {\n candidates = documentCandidates;\n }\n }\n if (candidates.length > 1) {\n // If all real loads came from successful preloads (url preloaded and\n // loads came from the cache), filter to link rel=preload request(s).\n const linkPreloadCandidates = candidates.filter(c => c.isLinkPreload);\n if (linkPreloadCandidates.length) {\n const nonPreloadCandidates = candidates.filter(c => !c.isLinkPreload);\n const allPreloaded = nonPreloadCandidates.every(c => c.fromDiskCache || c.fromMemoryCache);\n if (nonPreloadCandidates.length && allPreloaded) {\n candidates = linkPreloadCandidates;\n }\n }\n }\n\n // Only return an initiator if the result is unambiguous.\n return candidates.length === 1 ? candidates[0] : null;\n}\n\nfunction linkInitiators(lanternRequests: NetworkRequest[]): void {\n const requestsByURL = new Map<string, NetworkRequest[]>();\n for (const request of lanternRequests) {\n const requests = requestsByURL.get(request.url) || [];\n requests.push(request);\n requestsByURL.set(request.url, requests);\n }\n\n for (const request of lanternRequests) {\n const initiatorRequest = chooseInitiatorRequest(request, requestsByURL);\n if (initiatorRequest) {\n request.initiatorRequest = initiatorRequest;\n }\n }\n}\n\nfunction createNetworkRequests(trace: Lantern.Types.Trace, data: Handlers.Types.HandlerData, startTime = 0,\n endTime: number = Number.POSITIVE_INFINITY): NetworkRequest[] {\n const workerThreads = findWorkerThreads(trace);\n\n const lanternRequestsNoRedirects: NetworkRequest[] = [];\n for (const request of data.NetworkRequests.byTime) {\n if (request.ts >= startTime && request.ts < endTime) {\n const lanternRequest = createLanternRequest(data, workerThreads, request);\n if (lanternRequest) {\n lanternRequestsNoRedirects.push(lanternRequest);\n }\n }\n }\n\n const lanternRequests: NetworkRequest[] = [];\n\n // Trace Engine consolidates all redirects into a single request object, but lantern needs\n // an entry for each redirected request.\n for (const request of [...lanternRequestsNoRedirects]) {\n if (!request.rawRequest) {\n continue;\n }\n\n const redirects = request.rawRequest.args.data.redirects;\n if (!redirects.length) {\n lanternRequests.push(request);\n continue;\n }\n\n const requestChain = [];\n for (const redirect of redirects) {\n const redirectedRequest = structuredClone(request);\n\n redirectedRequest.networkRequestTime = redirect.ts / 1000;\n redirectedRequest.rendererStartTime = redirectedRequest.networkRequestTime;\n\n redirectedRequest.networkEndTime = (redirect.ts + redirect.dur) / 1000;\n redirectedRequest.responseHeadersEndTime = redirectedRequest.networkEndTime;\n\n redirectedRequest.timing = {\n requestTime: redirectedRequest.networkRequestTime / 1000,\n receiveHeadersStart: redirectedRequest.responseHeadersEndTime - redirectedRequest.networkRequestTime,\n receiveHeadersEnd: redirectedRequest.responseHeadersEndTime - redirectedRequest.networkRequestTime,\n proxyStart: -1,\n proxyEnd: -1,\n dnsStart: -1,\n dnsEnd: -1,\n connectStart: -1,\n connectEnd: -1,\n sslStart: -1,\n sslEnd: -1,\n sendStart: -1,\n sendEnd: -1,\n workerStart: -1,\n workerReady: -1,\n workerFetchStart: -1,\n workerRespondWithSettled: -1,\n pushStart: -1,\n pushEnd: -1,\n };\n\n redirectedRequest.url = redirect.url;\n redirectedRequest.parsedURL = createParsedUrl(redirect.url);\n // TODO: Trace Engine is not retaining the actual status code.\n redirectedRequest.statusCode = 302;\n redirectedRequest.resourceType = undefined;\n // TODO: Trace Engine is not retaining transfer size of redirected request.\n redirectedRequest.transferSize = 400;\n requestChain.push(redirectedRequest);\n lanternRequests.push(redirectedRequest);\n }\n if (requestChain.length) {\n request.rendererStartTime = requestChain[requestChain.length - 1].networkEndTime;\n }\n requestChain.push(request);\n lanternRequests.push(request);\n\n for (let i = 0; i < requestChain.length; i++) {\n const request = requestChain[i];\n if (i > 0) {\n request.redirectSource = requestChain[i - 1];\n request.redirects = requestChain.slice(0, i);\n }\n if (i !== requestChain.length - 1) {\n request.redirectDestination = requestChain[i + 1];\n }\n }\n\n // Apply the `:redirect` requestId convention: only redirects[0].requestId is the actual\n // requestId, all the rest have n occurrences of `:redirect` as a suffix.\n for (let i = 1; i < requestChain.length; i++) {\n requestChain[i].requestId = `${requestChain[i - 1].requestId}:redirect`;\n }\n }\n\n linkInitiators(lanternRequests);\n\n return lanternRequests;\n}\n\nfunction collectMainThreadEvents(\n trace: Lantern.Types.Trace, data: Handlers.Types.HandlerData): Lantern.Types.TraceEvent[] {\n const Meta = data.Meta;\n const mainFramePids = Meta.mainFrameNavigations.length ? new Set(Meta.mainFrameNavigations.map(nav => nav.pid)) :\n Meta.topLevelRendererIds;\n\n const rendererPidToTid = new Map();\n for (const pid of mainFramePids) {\n const threads = Meta.threadsInProcess.get(pid) ?? [];\n\n let found = false;\n for (const [tid, thread] of threads) {\n if (thread.args.name === 'CrRendererMain') {\n rendererPidToTid.set(pid, tid);\n found = true;\n break;\n }\n }\n\n if (found) {\n continue;\n }\n\n // `CrRendererMain` can be missing if chrome is launched with the `--single-process` flag.\n // In this case, page tasks will be run in the browser thread.\n for (const [tid, thread] of threads) {\n if (thread.args.name === 'CrBrowserMain') {\n rendererPidToTid.set(pid, tid);\n found = true;\n break;\n }\n }\n }\n\n return trace.traceEvents.filter(e => rendererPidToTid.get(e.pid) === e.tid);\n}\n\nfunction createGraph(\n requests: Lantern.Types.NetworkRequest[], trace: Lantern.Types.Trace, data: Handlers.Types.HandlerData,\n url?: Lantern.Types.Simulation.URL): Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest> {\n const mainThreadEvents = collectMainThreadEvents(trace, data);\n\n // url defines the initial request that the Lantern graph starts at (the root node) and the\n // main document request. These are equal if there are no redirects.\n if (!url) {\n url = {\n requestedUrl: requests[0].url,\n mainDocumentUrl: '',\n };\n\n let request = requests[0];\n while (request.redirectDestination) {\n request = request.redirectDestination;\n }\n url.mainDocumentUrl = request.url;\n }\n\n return Lantern.Graph.PageDependencyGraph.createGraph(mainThreadEvents, requests, url);\n}\n\nexport {\n createGraph,\n createNetworkRequests,\n createProcessedNavigation,\n};\n"]}
1
+ {"version":3,"file":"LanternComputationData.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/LanternComputationData.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAI7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAKhD,SAAS,yBAAyB,CAC9B,IAAgC,EAAE,OAAe,EACjD,UAAwC;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAA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,OAAO,CAAC,mBAAmB,EAAE,CAAC;gBACnC,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;YACxC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;QACF,MAAM,cAAc,GAAG,CAAC,CAA+B,EAAW,EAAE,CAChE,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,UAAU,CAAC;QAC1F,MAAM,QAAQ,GAAG,CAAC,CAA+B,EAAW,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,UAAU,CAAC;QAE9G,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC/F,MAAM,iBAAiB,GAAG,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE1G,GAAG,GAAG;YACJ,YAAY,EAAE,cAAc,CAAC,GAAG;YAChC,eAAe,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC,GAAG;SACxD,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,gBAAgB,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;AACxF,CAAC;AAED,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,yBAAyB,GAC1B,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Protocol from '../../generated/protocol.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Lantern from './lantern/lantern.js';\nimport type * as Types from './types/types.js';\n\ntype NetworkRequest = Lantern.Types.NetworkRequest<Types.Events.SyntheticNetworkRequest>;\n\nfunction createProcessedNavigation(\n data: Handlers.Types.HandlerData, frameId: string,\n navigation: Types.Events.NavigationStart): Lantern.Types.Simulation.ProcessedNavigation {\n const scoresByNav = data.PageLoadMetrics.metricScoresByFrameId.get(frameId);\n if (!scoresByNav) {\n throw new Lantern.Core.LanternError('missing metric scores for frame');\n }\n\n const scores = scoresByNav.get(navigation);\n if (!scores) {\n throw new Lantern.Core.LanternError('missing metric scores for specified navigation');\n }\n\n const getTimestampOrUndefined =\n (metric: Handlers.ModelHandlers.PageLoadMetrics.MetricName): Types.Timing.Micro|undefined => {\n const metricScore = scores.get(metric);\n if (!metricScore?.event) {\n return;\n }\n return metricScore.event.ts;\n };\n const getTimestamp = (metric: Handlers.ModelHandlers.PageLoadMetrics.MetricName): Types.Timing.Micro => {\n const metricScore = scores.get(metric);\n if (!metricScore?.event) {\n throw new Lantern.Core.LanternError(`missing metric: ${metric}`);\n }\n return metricScore.event.ts;\n };\n const lcpScore = scores.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);\n const navigationId = navigation.args.data?.navigationId;\n const lcpRequest = navigationId ? data.LargestImagePaint?.lcpRequestByNavigationId.get(navigationId) : undefined;\n return {\n timestamps: {\n firstContentfulPaint: getTimestamp(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FCP),\n largestContentfulPaint: getTimestampOrUndefined(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP),\n },\n largestContentfulPaintEvt:\n lcpScore && Handlers.ModelHandlers.PageLoadMetrics.metricIsLCP(lcpScore) ? lcpScore.event : undefined,\n lcpRequestId: lcpRequest?.args.data.requestId,\n lcpImageUrl: lcpRequest?.args.data.url,\n };\n}\n\nfunction createParsedUrl(url: URL|string): Lantern.Types.ParsedURL {\n if (typeof url === 'string') {\n url = new URL(url);\n }\n return {\n scheme: url.protocol.split(':')[0],\n // Intentional, DevTools uses different terminology\n host: url.hostname,\n securityOrigin: url.origin,\n };\n}\n\n/**\n * ResourceSendRequest URLs in the trace retain #hash fragments, whereas CDP\n * Network.requestWillBeSent, Page.frameNavigated, initiator.url, documentURL,\n * and V8 script events strip #hash fragments, and NetworkAnalyzer requires\n * request.url not to have a fragment.\n */\nfunction stripUrlHash(url: URL, rawUrl: string): string {\n if (!rawUrl.includes('#')) {\n return rawUrl;\n }\n url.hash = '';\n return url.href;\n}\n\n/**\n * Returns a map of `pid` -> `tid[]`.\n */\nfunction findWorkerThreads(trace: Lantern.Types.Trace): Map<number, number[]> {\n // TODO: WorkersHandler in Trace Engine needs to be updated to also include `pid` (only had `tid`).\n const workerThreads = new Map();\n const workerCreationEvents = ['ServiceWorker thread', 'DedicatedWorker thread'];\n\n for (const event of trace.traceEvents) {\n if (event.name !== 'thread_name' || !event.args.name) {\n continue;\n }\n if (!workerCreationEvents.includes(event.args.name)) {\n continue;\n }\n\n const tids = workerThreads.get(event.pid);\n if (tids) {\n tids.push(event.tid);\n } else {\n workerThreads.set(event.pid, [event.tid]);\n }\n }\n\n return workerThreads;\n}\n\nfunction createLanternRequest(\n parsedTrace: Readonly<Handlers.Types.HandlerData>, workerThreads: Map<number, number[]>,\n request: Types.Events.SyntheticNetworkRequest): NetworkRequest|undefined {\n if (request.args.data.hasResponse && request.args.data.connectionId === undefined) {\n throw new Lantern.Core.LanternError('Trace is too old');\n }\n\n let url;\n try {\n url = new URL(request.args.data.url);\n } catch {\n return;\n }\n\n const timing = request.args.data.timing ? {\n // These two timings are not included in the trace.\n workerFetchStart: -1,\n workerRespondWithSettled: -1,\n receiveHeadersStart: -1,\n ...request.args.data.timing,\n } :\n undefined;\n\n const networkRequestTime = timing ? timing.requestTime * 1000 : request.args.data.syntheticData.downloadStart / 1000;\n\n let fromWorker = false;\n const tids = workerThreads.get(request.pid);\n if (tids?.includes(request.tid)) {\n fromWorker = true;\n }\n\n // Trace Engine collects worker thread ids in a different manner than `workerThreads` does.\n // AFAIK these should be equivalent, but in case they are not let's also check this for now.\n if (parsedTrace.Workers.workerIdByThread.has(request.tid)) {\n fromWorker = true;\n }\n\n // `initiator` in the trace does not contain the stack trace for JS-initiated\n // requests. Instead, that is stored in the `stackTrace` property of the SyntheticNetworkRequest.\n // There are some minor differences in the fields, accounted for here.\n // Most importantly, there seems to be fewer frames in the trace than the equivalent\n // events over the CDP. This results in less accuracy in determining the initiator request,\n // which means less edges in the graph, which mean worse results.\n // TODO: Should fix in Chromium.\n const initiator: Lantern.Types.NetworkRequest['initiator'] =\n request.args.data.initiator ?? {type: Protocol.Network.InitiatorType.Other};\n if (request.args.data.stackTrace) {\n const callFrames = request.args.data.stackTrace.map(f => {\n return {\n scriptId: String(f.scriptId) as Protocol.Runtime.ScriptId,\n url: f.url,\n lineNumber: f.lineNumber - 1,\n columnNumber: f.columnNumber - 1,\n functionName: f.functionName,\n };\n });\n initiator.stack = {callFrames};\n // Note: there is no `parent` to set ...\n }\n\n let resourceType = request.args.data.resourceType;\n if (request.args.data.initiator?.fetchType === 'xmlhttprequest') {\n // @ts-expect-error yes XHR is a valid ResourceType. TypeScript const enums are so unhelpful.\n resourceType = 'XHR';\n } else if (request.args.data.initiator?.fetchType === 'fetch') {\n // @ts-expect-error yes Fetch is a valid ResourceType. TypeScript const enums are so unhelpful.\n resourceType = 'Fetch';\n }\n\n // NetworkRequestsHandler defaults missing `renderBlocking` to 'non_blocking',\n // so only populate `renderBlocking` when it was explicitly set on the raw\n // ResourceSendRequest event or updated via PreloadRenderBlockingStatusChange.\n const hasExplicitRenderBlocking = request.rawSourceEvent.args.data.renderBlocking !== undefined ||\n request.args.data.renderBlocking !== 'non_blocking';\n const renderBlocking = hasExplicitRenderBlocking ? request.args.data.renderBlocking : undefined;\n\n return {\n rawRequest: request,\n requestId: request.args.data.requestId,\n connectionId: request.args.data.connectionId ?? 0,\n connectionReused: request.args.data.connectionReused ?? false,\n url: stripUrlHash(url, request.args.data.url),\n protocol: request.args.data.protocol,\n parsedURL: createParsedUrl(url),\n documentURL: request.args.data.requestingFrameUrl,\n rendererStartTime: request.ts / 1000,\n networkRequestTime,\n responseHeadersEndTime: request.args.data.syntheticData.downloadStart / 1000,\n networkEndTime: request.args.data.syntheticData.finishTime / 1000,\n transferSize: request.args.data.encodedDataLength,\n resourceSize: request.args.data.decodedBodyLength ?? 0,\n fromDiskCache: request.args.data.syntheticData.isDiskCached,\n fromMemoryCache: request.args.data.syntheticData.isMemoryCached,\n isLinkPreload: request.args.data.isLinkPreload,\n finished: request.args.data.finished,\n failed: request.args.data.failed,\n statusCode: request.args.data.statusCode,\n initiator,\n timing,\n resourceType,\n mimeType: request.args.data.mimeType,\n priority: request.args.data.priority,\n renderBlocking,\n frameId: request.args.data.frame,\n fromWorker,\n serverResponseTime: request.args.data.lrServerResponseTime,\n };\n}\n\n/**\n * @param request The request to find the initiator of\n */\nfunction chooseInitiatorRequest(request: NetworkRequest, requestsByURL: Map<string, NetworkRequest[]>): NetworkRequest|\n null {\n if (request.redirectSource) {\n return request.redirectSource;\n }\n\n const initiatorURL = Lantern.Graph.PageDependencyGraph.getNetworkInitiators(request)[0];\n let candidates = requestsByURL.get(initiatorURL) || [];\n // The (valid) initiator must come before the initiated request.\n candidates = candidates.filter(c => {\n return c.responseHeadersEndTime <= request.rendererStartTime && c.finished && !c.failed;\n });\n if (candidates.length > 1) {\n // Disambiguate based on prefetch. Prefetch requests have type 'Other' and cannot\n // initiate requests, so we drop them here.\n const nonPrefetchCandidates =\n candidates.filter(cand => cand.resourceType !== Lantern.Types.NetworkRequestTypes.Other);\n if (nonPrefetchCandidates.length) {\n candidates = nonPrefetchCandidates;\n }\n }\n if (candidates.length > 1) {\n // Disambiguate based on frame. It's likely that the initiator comes from the same frame.\n const sameFrameCandidates = candidates.filter(cand => cand.frameId === request.frameId);\n if (sameFrameCandidates.length) {\n candidates = sameFrameCandidates;\n }\n }\n if (candidates.length > 1 && request.initiator.type === 'parser') {\n // Filter to just Documents when initiator type is parser.\n const documentCandidates =\n candidates.filter(cand => cand.resourceType === Lantern.Types.NetworkRequestTypes.Document);\n if (documentCandidates.length) {\n candidates = documentCandidates;\n }\n }\n if (candidates.length > 1) {\n // If all real loads came from successful preloads (url preloaded and\n // loads came from the cache), filter to link rel=preload request(s).\n const linkPreloadCandidates = candidates.filter(c => c.isLinkPreload);\n if (linkPreloadCandidates.length) {\n const nonPreloadCandidates = candidates.filter(c => !c.isLinkPreload);\n const allPreloaded = nonPreloadCandidates.every(c => c.fromDiskCache || c.fromMemoryCache);\n if (nonPreloadCandidates.length && allPreloaded) {\n candidates = linkPreloadCandidates;\n }\n }\n }\n\n // Only return an initiator if the result is unambiguous.\n return candidates.length === 1 ? candidates[0] : null;\n}\n\nfunction linkInitiators(lanternRequests: NetworkRequest[]): void {\n const requestsByURL = new Map<string, NetworkRequest[]>();\n for (const request of lanternRequests) {\n const requests = requestsByURL.get(request.url) || [];\n requests.push(request);\n requestsByURL.set(request.url, requests);\n }\n\n for (const request of lanternRequests) {\n const initiatorRequest = chooseInitiatorRequest(request, requestsByURL);\n if (initiatorRequest) {\n request.initiatorRequest = initiatorRequest;\n }\n }\n}\n\nfunction createNetworkRequests(trace: Lantern.Types.Trace, data: Handlers.Types.HandlerData, startTime = 0,\n endTime: number = Number.POSITIVE_INFINITY): NetworkRequest[] {\n const workerThreads = findWorkerThreads(trace);\n\n const lanternRequestsNoRedirects: NetworkRequest[] = [];\n for (const request of data.NetworkRequests.byTime) {\n if (request.ts >= startTime && request.ts < endTime) {\n const lanternRequest = createLanternRequest(data, workerThreads, request);\n if (lanternRequest) {\n lanternRequestsNoRedirects.push(lanternRequest);\n }\n }\n }\n\n const lanternRequests: NetworkRequest[] = [];\n\n // Trace Engine consolidates all redirects into a single request object, but lantern needs\n // an entry for each redirected request.\n for (const request of [...lanternRequestsNoRedirects]) {\n if (!request.rawRequest) {\n continue;\n }\n\n const redirects = request.rawRequest.args.data.redirects;\n if (!redirects.length) {\n lanternRequests.push(request);\n continue;\n }\n\n const requestChain = [];\n for (const redirect of redirects) {\n const redirectedRequest = structuredClone(request);\n\n redirectedRequest.networkRequestTime = redirect.ts / 1000;\n redirectedRequest.rendererStartTime = redirectedRequest.networkRequestTime;\n\n redirectedRequest.networkEndTime = (redirect.ts + redirect.dur) / 1000;\n redirectedRequest.responseHeadersEndTime = redirectedRequest.networkEndTime;\n\n redirectedRequest.timing = {\n requestTime: redirectedRequest.networkRequestTime / 1000,\n receiveHeadersStart: redirectedRequest.responseHeadersEndTime - redirectedRequest.networkRequestTime,\n receiveHeadersEnd: redirectedRequest.responseHeadersEndTime - redirectedRequest.networkRequestTime,\n proxyStart: -1,\n proxyEnd: -1,\n dnsStart: -1,\n dnsEnd: -1,\n connectStart: -1,\n connectEnd: -1,\n sslStart: -1,\n sslEnd: -1,\n sendStart: -1,\n sendEnd: -1,\n workerStart: -1,\n workerReady: -1,\n workerFetchStart: -1,\n workerRespondWithSettled: -1,\n pushStart: -1,\n pushEnd: -1,\n };\n\n const redirectUrl = new URL(redirect.url);\n redirectedRequest.url = stripUrlHash(redirectUrl, redirect.url);\n redirectedRequest.parsedURL = createParsedUrl(redirectUrl);\n // TODO: Trace Engine is not retaining the actual status code.\n redirectedRequest.statusCode = 302;\n redirectedRequest.resourceType = undefined;\n // TODO: Trace Engine is not retaining transfer size of redirected request.\n redirectedRequest.transferSize = 400;\n requestChain.push(redirectedRequest);\n lanternRequests.push(redirectedRequest);\n }\n if (requestChain.length) {\n request.rendererStartTime = requestChain[requestChain.length - 1].networkEndTime;\n }\n requestChain.push(request);\n lanternRequests.push(request);\n\n for (let i = 0; i < requestChain.length; i++) {\n const request = requestChain[i];\n if (i > 0) {\n request.redirectSource = requestChain[i - 1];\n request.redirects = requestChain.slice(0, i);\n }\n if (i !== requestChain.length - 1) {\n request.redirectDestination = requestChain[i + 1];\n }\n }\n\n // Apply the `:redirect` requestId convention: only redirects[0].requestId is the actual\n // requestId, all the rest have n occurrences of `:redirect` as a suffix.\n for (let i = 1; i < requestChain.length; i++) {\n requestChain[i].requestId = `${requestChain[i - 1].requestId}:redirect`;\n }\n }\n\n linkInitiators(lanternRequests);\n\n return lanternRequests;\n}\n\nfunction collectMainThreadEvents(\n trace: Lantern.Types.Trace, data: Handlers.Types.HandlerData): Lantern.Types.TraceEvent[] {\n const Meta = data.Meta;\n const mainFramePids = Meta.mainFrameNavigations.length ? new Set(Meta.mainFrameNavigations.map(nav => nav.pid)) :\n Meta.topLevelRendererIds;\n\n const rendererPidToTid = new Map();\n for (const pid of mainFramePids) {\n const threads = Meta.threadsInProcess.get(pid) ?? [];\n\n let found = false;\n for (const [tid, thread] of threads) {\n if (thread.args.name === 'CrRendererMain') {\n rendererPidToTid.set(pid, tid);\n found = true;\n break;\n }\n }\n\n if (found) {\n continue;\n }\n\n // `CrRendererMain` can be missing if chrome is launched with the `--single-process` flag.\n // In this case, page tasks will be run in the browser thread.\n for (const [tid, thread] of threads) {\n if (thread.args.name === 'CrBrowserMain') {\n rendererPidToTid.set(pid, tid);\n found = true;\n break;\n }\n }\n }\n\n return trace.traceEvents.filter(e => rendererPidToTid.get(e.pid) === e.tid);\n}\n\nfunction createGraph(\n requests: Lantern.Types.NetworkRequest[], trace: Lantern.Types.Trace, data: Handlers.Types.HandlerData,\n url?: Lantern.Types.Simulation.URL): Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest> {\n const mainThreadEvents = collectMainThreadEvents(trace, data);\n\n // url defines the initial request that the Lantern graph starts at (the root node) and the\n // main document request. These are equal if there are no redirects.\n if (!url) {\n if (!requests.length) {\n throw new Lantern.Core.LanternError('No network requests found in trace');\n }\n\n const followRedirects = (request: Lantern.Types.NetworkRequest): Lantern.Types.NetworkRequest => {\n while (request.redirectDestination) {\n request = request.redirectDestination;\n }\n return request;\n };\n const isMainFrameDoc = (r: Lantern.Types.NetworkRequest): boolean =>\n r.frameId === data.Meta.mainFrameId && followRedirects(r).resourceType === 'Document';\n const isAnyDoc = (r: Lantern.Types.NetworkRequest): boolean => followRedirects(r).resourceType === 'Document';\n\n const initialRequest = requests.find(isMainFrameDoc) ?? requests.find(isAnyDoc) ?? requests[0];\n const lastDocChainStart = requests.findLast(isMainFrameDoc) ?? requests.findLast(isAnyDoc) ?? requests[0];\n\n url = {\n requestedUrl: initialRequest.url,\n mainDocumentUrl: followRedirects(lastDocChainStart).url,\n };\n }\n\n return Lantern.Graph.PageDependencyGraph.createGraph(mainThreadEvents, requests, url);\n}\n\nexport {\n createGraph,\n createNetworkRequests,\n createProcessedNavigation,\n};\n"]}
@@ -93,8 +93,6 @@ export class Model extends EventTarget {
93
93
  throw new Error('processor did not parse trace');
94
94
  }
95
95
  const file = this.#storeAndCreateParsedTraceFile(syntheticEventsManager, traceEvents, metadata, this.#processor.data, this.#processor.insights);
96
- // Reclaim memory used by the temporary event-to-index lookup map now that trace parsing is complete.
97
- syntheticEventsManager.clearRegistrationIndex();
98
96
  // We only push the file onto this.#traces here once we know it's valid
99
97
  // and there's been no errors in the parsing.
100
98
  this.#traces.push(file);