@paulirish/trace_engine 0.0.60 → 0.0.62

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 (302) hide show
  1. package/.tmp/tsbuildinfo/analyze-trace.d.mts.map +1 -1
  2. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  3. package/analyze-inspector-issues.mjs +1 -1
  4. package/analyze-trace.mjs +1 -2
  5. package/core/platform/ArrayUtilities.d.ts +2 -0
  6. package/core/platform/ArrayUtilities.js +11 -1
  7. package/core/platform/ArrayUtilities.js.map +1 -1
  8. package/core/platform/HostRuntime.d.ts +4 -0
  9. package/core/platform/HostRuntime.js +25 -0
  10. package/core/platform/HostRuntime.js.map +1 -0
  11. package/core/platform/KeyboardUtilities.d.ts +6 -2
  12. package/core/platform/KeyboardUtilities.js.map +1 -1
  13. package/core/platform/StringUtilities.d.ts +2 -0
  14. package/core/platform/StringUtilities.js +64 -13
  15. package/core/platform/StringUtilities.js.map +1 -1
  16. package/core/platform/api/HostRuntime.d.ts +36 -0
  17. package/core/platform/api/HostRuntime.js +5 -0
  18. package/core/platform/api/HostRuntime.js.map +1 -0
  19. package/core/platform/api/api-tsconfig.json +43 -0
  20. package/core/platform/api/api.d.ts +2 -0
  21. package/core/platform/api/api.js +6 -0
  22. package/core/platform/api/api.js.map +1 -0
  23. package/core/platform/api/api_node_typecheck-tsconfig.json +48 -0
  24. package/core/platform/api/bundle-tsconfig.json +1 -0
  25. package/core/platform/api/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
  26. package/core/platform/browser/HostRuntime.d.ts +2 -0
  27. package/core/platform/browser/HostRuntime.js +64 -0
  28. package/core/platform/browser/HostRuntime.js.map +1 -0
  29. package/core/platform/browser/browser-tsconfig.json +48 -0
  30. package/core/platform/browser/browser.d.ts +2 -0
  31. package/core/platform/browser/browser.js +6 -0
  32. package/core/platform/browser/browser.js.map +1 -0
  33. package/core/platform/browser/bundle-tsconfig.json +1 -0
  34. package/core/platform/browser/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
  35. package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  36. package/core/platform/node/HostRuntime.d.ts +2 -0
  37. package/core/platform/node/HostRuntime.js +73 -0
  38. package/core/platform/node/HostRuntime.js.map +1 -0
  39. package/core/platform/node/bundle-tsconfig.json +1 -0
  40. package/core/platform/node/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
  41. package/core/platform/node/node-tsconfig.json +52 -0
  42. package/core/platform/node/node.d.ts +2 -0
  43. package/core/platform/node/node.js +6 -0
  44. package/core/platform/node/node.js.map +1 -0
  45. package/core/platform/platform-tsconfig.json +17 -5
  46. package/core/platform/platform.d.ts +2 -2
  47. package/core/platform/platform.js +2 -2
  48. package/core/platform/platform.js.map +1 -1
  49. package/core/platform/platform_node_typecheck-tsconfig.json +74 -0
  50. package/generated/protocol.d.ts +1517 -592
  51. package/locales/af.json +83 -38
  52. package/locales/am.json +83 -38
  53. package/locales/ar.json +86 -41
  54. package/locales/as.json +83 -38
  55. package/locales/az.json +83 -38
  56. package/locales/be.json +81 -36
  57. package/locales/bg.json +81 -36
  58. package/locales/bn.json +83 -38
  59. package/locales/bs.json +82 -37
  60. package/locales/ca.json +81 -36
  61. package/locales/cs.json +81 -36
  62. package/locales/cy.json +83 -38
  63. package/locales/da.json +83 -38
  64. package/locales/de.json +81 -36
  65. package/locales/el.json +82 -37
  66. package/locales/en-GB.json +83 -38
  67. package/locales/en-US.json +104 -35
  68. package/locales/en-XL.json +104 -35
  69. package/locales/es-419.json +81 -36
  70. package/locales/es.json +82 -37
  71. package/locales/et.json +83 -38
  72. package/locales/eu.json +81 -36
  73. package/locales/fa.json +84 -39
  74. package/locales/fi.json +81 -36
  75. package/locales/fil.json +83 -38
  76. package/locales/fr-CA.json +82 -37
  77. package/locales/fr.json +168 -123
  78. package/locales/gl.json +82 -37
  79. package/locales/gu.json +82 -37
  80. package/locales/he.json +96 -51
  81. package/locales/hi.json +82 -37
  82. package/locales/hr.json +81 -36
  83. package/locales/hu.json +82 -37
  84. package/locales/hy.json +82 -37
  85. package/locales/id.json +83 -38
  86. package/locales/is.json +82 -37
  87. package/locales/it.json +81 -36
  88. package/locales/ja.json +81 -36
  89. package/locales/ka.json +83 -38
  90. package/locales/kk.json +81 -36
  91. package/locales/km.json +83 -38
  92. package/locales/kn.json +82 -37
  93. package/locales/ko.json +82 -37
  94. package/locales/ky.json +81 -36
  95. package/locales/lo.json +82 -37
  96. package/locales/lt.json +81 -36
  97. package/locales/lv.json +81 -36
  98. package/locales/mk.json +84 -39
  99. package/locales/ml.json +82 -37
  100. package/locales/mn.json +82 -37
  101. package/locales/mr.json +83 -38
  102. package/locales/ms.json +81 -36
  103. package/locales/my.json +82 -37
  104. package/locales/ne.json +82 -37
  105. package/locales/nl.json +82 -37
  106. package/locales/no.json +81 -36
  107. package/locales/or.json +81 -36
  108. package/locales/pa.json +81 -36
  109. package/locales/pl.json +81 -36
  110. package/locales/pt-PT.json +81 -36
  111. package/locales/pt.json +83 -38
  112. package/locales/ro.json +82 -37
  113. package/locales/ru.json +81 -36
  114. package/locales/si.json +81 -36
  115. package/locales/sk.json +81 -36
  116. package/locales/sl.json +81 -36
  117. package/locales/sq.json +82 -37
  118. package/locales/sr-Latn.json +82 -37
  119. package/locales/sr.json +82 -37
  120. package/locales/sv.json +84 -39
  121. package/locales/sw.json +83 -38
  122. package/locales/ta.json +82 -37
  123. package/locales/te.json +82 -37
  124. package/locales/th.json +82 -37
  125. package/locales/tr.json +81 -36
  126. package/locales/uk.json +81 -36
  127. package/locales/ur.json +82 -37
  128. package/locales/uz.json +82 -37
  129. package/locales/vi.json +83 -38
  130. package/locales/zh-HK.json +81 -36
  131. package/locales/zh-TW.json +84 -39
  132. package/locales/zh.json +84 -39
  133. package/locales/zu.json +82 -37
  134. package/models/cpu_profile/CPUProfileDataModel.d.ts +9 -0
  135. package/models/cpu_profile/CPUProfileDataModel.js +9 -7
  136. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
  137. package/models/cpu_profile/ProfileTreeModel.d.ts +3 -2
  138. package/models/cpu_profile/ProfileTreeModel.js +6 -7
  139. package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
  140. package/models/cpu_profile/cpu_profile-tsconfig.json +4 -3
  141. package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  142. package/models/trace/EntityMapper.d.ts +1 -0
  143. package/models/trace/EntityMapper.js +10 -0
  144. package/models/trace/EntityMapper.js.map +1 -1
  145. package/models/trace/EventsSerializer.js +10 -2
  146. package/models/trace/EventsSerializer.js.map +1 -1
  147. package/models/trace/LanternComputationData.d.ts +1 -1
  148. package/models/trace/LanternComputationData.js +3 -8
  149. package/models/trace/LanternComputationData.js.map +1 -1
  150. package/models/trace/ModelImpl.d.ts +1 -0
  151. package/models/trace/ModelImpl.js +9 -6
  152. package/models/trace/ModelImpl.js.map +1 -1
  153. package/models/trace/Processor.js +23 -23
  154. package/models/trace/Processor.js.map +1 -1
  155. package/models/trace/Styles.js +13 -5
  156. package/models/trace/Styles.js.map +1 -1
  157. package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  158. package/models/trace/extras/Initiators.d.ts +12 -0
  159. package/models/trace/extras/Initiators.js +47 -0
  160. package/models/trace/extras/Initiators.js.map +1 -0
  161. package/models/trace/extras/TraceTree.js +13 -5
  162. package/models/trace/extras/TraceTree.js.map +1 -1
  163. package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  164. package/models/trace/extras/extras-tsconfig.json +11 -3
  165. package/models/trace/extras/extras.d.ts +0 -3979
  166. package/models/trace/extras/extras.js +0 -3979
  167. package/models/trace/extras/extras.js.map +1 -1
  168. package/models/trace/handlers/LargestImagePaintHandler.js +2 -2
  169. package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -1
  170. package/models/trace/handlers/LayoutShiftsHandler.js +1 -1
  171. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  172. package/models/trace/handlers/MetaHandler.d.ts +12 -1
  173. package/models/trace/handlers/MetaHandler.js +10 -1
  174. package/models/trace/handlers/MetaHandler.js.map +1 -1
  175. package/models/trace/handlers/NetworkRequestsHandler.d.ts +8 -1
  176. package/models/trace/handlers/NetworkRequestsHandler.js +22 -4
  177. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  178. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +13 -3
  179. package/models/trace/handlers/PageLoadMetricsHandler.js +71 -27
  180. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
  181. package/models/trace/handlers/SamplesHandler.js +59 -6
  182. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  183. package/models/trace/handlers/ScriptsHandler.js +24 -0
  184. package/models/trace/handlers/ScriptsHandler.js.map +1 -1
  185. package/models/trace/handlers/UserTimingsHandler.d.ts +1 -1
  186. package/models/trace/handlers/UserTimingsHandler.js +1 -1
  187. package/models/trace/handlers/UserTimingsHandler.js.map +1 -1
  188. package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  189. package/models/trace/handlers/handlers-tsconfig.json +13 -3
  190. package/models/trace/helpers/Network.js +1 -1
  191. package/models/trace/helpers/Network.js.map +1 -1
  192. package/models/trace/helpers/SamplesIntegrator.js +1 -8
  193. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  194. package/models/trace/helpers/Timing.d.ts +1 -1
  195. package/models/trace/helpers/Timing.js +9 -2
  196. package/models/trace/helpers/Timing.js.map +1 -1
  197. package/models/trace/helpers/Trace.d.ts +1 -0
  198. package/models/trace/helpers/Trace.js +12 -5
  199. package/models/trace/helpers/Trace.js.map +1 -1
  200. package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  201. package/models/trace/helpers/helpers-tsconfig.json +7 -3
  202. package/models/trace/insights/CLSCulprits.d.ts +1 -1
  203. package/models/trace/insights/CLSCulprits.js +2 -1
  204. package/models/trace/insights/CLSCulprits.js.map +1 -1
  205. package/models/trace/insights/Cache.d.ts +1 -1
  206. package/models/trace/insights/Cache.js +2 -1
  207. package/models/trace/insights/Cache.js.map +1 -1
  208. package/models/trace/insights/CharacterSet.d.ts +49 -0
  209. package/models/trace/insights/CharacterSet.js +132 -0
  210. package/models/trace/insights/CharacterSet.js.map +1 -0
  211. package/models/trace/insights/Common.d.ts +2 -2
  212. package/models/trace/insights/Common.js +1 -6
  213. package/models/trace/insights/Common.js.map +1 -1
  214. package/models/trace/insights/DOMSize.d.ts +1 -1
  215. package/models/trace/insights/DOMSize.js +2 -1
  216. package/models/trace/insights/DOMSize.js.map +1 -1
  217. package/models/trace/insights/DocumentLatency.d.ts +1 -1
  218. package/models/trace/insights/DocumentLatency.js +2 -1
  219. package/models/trace/insights/DocumentLatency.js.map +1 -1
  220. package/models/trace/insights/DuplicatedJavaScript.d.ts +1 -1
  221. package/models/trace/insights/DuplicatedJavaScript.js +2 -1
  222. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
  223. package/models/trace/insights/FontDisplay.d.ts +1 -1
  224. package/models/trace/insights/FontDisplay.js +2 -1
  225. package/models/trace/insights/FontDisplay.js.map +1 -1
  226. package/models/trace/insights/ForcedReflow.d.ts +2 -2
  227. package/models/trace/insights/ForcedReflow.js +3 -2
  228. package/models/trace/insights/ForcedReflow.js.map +1 -1
  229. package/models/trace/insights/INPBreakdown.d.ts +1 -1
  230. package/models/trace/insights/INPBreakdown.js +2 -1
  231. package/models/trace/insights/INPBreakdown.js.map +1 -1
  232. package/models/trace/insights/ImageDelivery.d.ts +1 -1
  233. package/models/trace/insights/ImageDelivery.js +2 -1
  234. package/models/trace/insights/ImageDelivery.js.map +1 -1
  235. package/models/trace/insights/LCPBreakdown.d.ts +2 -2
  236. package/models/trace/insights/LCPBreakdown.js +4 -3
  237. package/models/trace/insights/LCPBreakdown.js.map +1 -1
  238. package/models/trace/insights/LCPDiscovery.d.ts +8 -4
  239. package/models/trace/insights/LCPDiscovery.js +18 -11
  240. package/models/trace/insights/LCPDiscovery.js.map +1 -1
  241. package/models/trace/insights/LegacyJavaScript.d.ts +1 -1
  242. package/models/trace/insights/LegacyJavaScript.js +2 -1
  243. package/models/trace/insights/LegacyJavaScript.js.map +1 -1
  244. package/models/trace/insights/Models.d.ts +1 -0
  245. package/models/trace/insights/Models.js +1 -0
  246. package/models/trace/insights/Models.js.map +1 -1
  247. package/models/trace/insights/ModernHTTP.d.ts +1 -1
  248. package/models/trace/insights/ModernHTTP.js +2 -1
  249. package/models/trace/insights/ModernHTTP.js.map +1 -1
  250. package/models/trace/insights/NetworkDependencyTree.d.ts +1 -1
  251. package/models/trace/insights/NetworkDependencyTree.js +6 -4
  252. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  253. package/models/trace/insights/RenderBlocking.d.ts +2 -2
  254. package/models/trace/insights/RenderBlocking.js +8 -7
  255. package/models/trace/insights/RenderBlocking.js.map +1 -1
  256. package/models/trace/insights/SlowCSSSelector.d.ts +1 -1
  257. package/models/trace/insights/SlowCSSSelector.js +2 -1
  258. package/models/trace/insights/SlowCSSSelector.js.map +1 -1
  259. package/models/trace/insights/ThirdParties.js +2 -1
  260. package/models/trace/insights/ThirdParties.js.map +1 -1
  261. package/models/trace/insights/Viewport.d.ts +1 -1
  262. package/models/trace/insights/Viewport.js +2 -1
  263. package/models/trace/insights/Viewport.js.map +1 -1
  264. package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  265. package/models/trace/insights/insights-tsconfig.json +26 -3
  266. package/models/trace/insights/types.d.ts +17 -6
  267. package/models/trace/insights/types.js +1 -0
  268. package/models/trace/insights/types.js.map +1 -1
  269. package/models/trace/lantern/core/core-tsconfig.json +4 -3
  270. package/models/trace/lantern/core/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  271. package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  272. package/models/trace/lantern/graph/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  273. package/models/trace/lantern/graph/graph-tsconfig.json +4 -3
  274. package/models/trace/lantern/lantern-tsconfig.json +4 -3
  275. package/models/trace/lantern/metrics/FirstContentfulPaint.js +6 -6
  276. package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +1 -1
  277. package/models/trace/lantern/metrics/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  278. package/models/trace/lantern/metrics/metrics-tsconfig.json +4 -3
  279. package/models/trace/lantern/simulation/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  280. package/models/trace/lantern/simulation/simulation-tsconfig.json +4 -3
  281. package/models/trace/lantern/types/Lantern.d.ts +7 -7
  282. package/models/trace/lantern/types/Lantern.js.map +1 -1
  283. package/models/trace/lantern/types/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  284. package/models/trace/lantern/types/types-tsconfig.json +4 -3
  285. package/models/trace/trace-tsconfig.json +7 -3
  286. package/models/trace/types/Configuration.d.ts +1 -4
  287. package/models/trace/types/Configuration.js +0 -1
  288. package/models/trace/types/Configuration.js.map +1 -1
  289. package/models/trace/types/File.d.ts +8 -0
  290. package/models/trace/types/File.js.map +1 -1
  291. package/models/trace/types/TraceEvents.d.ts +97 -15
  292. package/models/trace/types/TraceEvents.js +44 -11
  293. package/models/trace/types/TraceEvents.js.map +1 -1
  294. package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
  295. package/models/trace/types/types-tsconfig.json +10 -3
  296. package/package.json +1 -1
  297. package/test/test-trace-engine.mjs +8 -9
  298. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts +0 -4
  299. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts.map +0 -1
  300. package/core/platform/DOMUtilities.d.ts +0 -16
  301. package/core/platform/DOMUtilities.js +0 -123
  302. package/core/platform/DOMUtilities.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"UserTimingsHandler.js","sourceRoot":"","sources":["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CAAC,CAAC;IACrE,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,WAAW,CAAC,CAAC;IAChF,eAAe,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IACnG,eAAe,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACrG,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,cAAc,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,eAAe,CAA8C;QACnH,mBAAmB,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,mBAAmB,CACpC;QAC1C,gBAAgB,EAAE,qBAAqB;QACvC,eAAe;QACf,qBAAqB;KACtB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2022 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 * as Types from '../types/types.js';\n\n/**\n * IMPORTANT!\n * See UserTimings.md in this directory for some handy documentation on\n * UserTimings and the trace events we parse currently.\n **/\nlet syntheticEvents: Array<Types.Events.SyntheticEventPair<Types.Events.PairableAsync>> = [];\n\n// There are two events dispatched for performance.measure calls: one to\n// represent the measured timing in the tracing clock (which we type as\n// PerformanceMeasure) and another one for the call itself (which we\n// type as UserTimingMeasure). The two events corresponding to the same\n// call are linked together by a common trace_id. The reason two events\n// are dispatched is because the first was originally added with the\n// implementation of the performance.measure API and it uses an\n// overridden timestamp and duration. To prevent breaking potential deps\n// created since then, a second event was added instead of changing the\n// params of the first.\nlet measureTraceByTraceId = new Map<number, Types.Events.UserTimingMeasure>();\nlet performanceMeasureEvents: Types.Events.PerformanceMeasure[] = [];\nlet performanceMarkEvents: Types.Events.PerformanceMark[] = [];\n\nlet consoleTimings: Array<Types.Events.ConsoleTimeBegin|Types.Events.ConsoleTimeEnd> = [];\n\nlet timestampEvents: Types.Events.ConsoleTimeStamp[] = [];\n\nexport interface UserTimingsData {\n /**\n * Events triggered with the performance.measure() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure\n */\n performanceMeasures: readonly Types.Events.SyntheticUserTimingPair[];\n /**\n * Events triggered with the performance.mark() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark\n */\n performanceMarks: readonly Types.Events.PerformanceMark[];\n /**\n * Events triggered with the console.time(), console.timeEnd() and\n * console.timeLog() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/console/time\n */\n consoleTimings: readonly Types.Events.SyntheticConsoleTimingPair[];\n /**\n * Events triggered with the console.timeStamp() API\n * https://developer.mozilla.org/en-US/docs/Web/API/console/timeStamp\n */\n timestampEvents: readonly Types.Events.ConsoleTimeStamp[];\n /**\n * Events triggered to trace the call to performance.measure itself,\n * cached by trace_id.\n */\n measureTraceByTraceId: Map<number, Types.Events.UserTimingMeasure>;\n}\n\nexport function reset(): void {\n syntheticEvents = [];\n performanceMeasureEvents = [];\n performanceMarkEvents = [];\n consoleTimings = [];\n timestampEvents = [];\n measureTraceByTraceId = new Map();\n}\n\nconst resourceTimingNames = [\n 'workerStart',\n 'redirectStart',\n 'redirectEnd',\n 'fetchStart',\n 'domainLookupStart',\n 'domainLookupEnd',\n 'connectStart',\n 'connectEnd',\n 'secureConnectionStart',\n 'requestStart',\n 'responseStart',\n 'responseEnd',\n];\nconst navTimingNames = [\n 'navigationStart',\n 'unloadEventStart',\n 'unloadEventEnd',\n 'redirectStart',\n 'redirectEnd',\n 'fetchStart',\n 'commitNavigationEnd',\n 'domainLookupStart',\n 'domainLookupEnd',\n 'connectStart',\n 'connectEnd',\n 'secureConnectionStart',\n 'requestStart',\n 'responseStart',\n 'responseEnd',\n 'domLoading',\n 'domInteractive',\n 'domContentLoadedEventStart',\n 'domContentLoadedEventEnd',\n 'domComplete',\n 'loadEventStart',\n 'loadEventEnd',\n];\n// These are events dispatched under the blink.user_timing category\n// but that the user didn't add. Filter them out so that they do not\n// Appear in the timings track (they still appear in the main thread\n// flame chart).\nconst ignoredNames = [...resourceTimingNames, ...navTimingNames];\n\nfunction getEventTimings(event: Types.Events.SyntheticEventPair|Types.Events.ConsoleTimeStamp):\n {start: Types.Timing.Micro, end: Types.Timing.Micro} {\n if ('dur' in event) {\n // It's a SyntheticEventPair.\n return {start: event.ts, end: Types.Timing.Micro(event.ts + (event.dur ?? 0))};\n }\n\n if (Types.Events.isConsoleTimeStamp(event)) {\n const {start, end} = event.args.data || {};\n if (typeof start === 'number' && typeof end === 'number') {\n return {start: Types.Timing.Micro(start), end: Types.Timing.Micro(end)};\n }\n }\n\n // A ConsoleTimeStamp without start/end is just a point in time, so dur is 0.\n return {start: event.ts, end: event.ts};\n}\n\nfunction getEventTrack(event: Types.Events.SyntheticEventPair|Types.Events.ConsoleTimeStamp): string|undefined {\n if (event.cat === 'blink.user_timing') {\n // This is a SyntheticUserTimingPair\n const detailString =\n ((event as Types.Events.SyntheticUserTimingPair).args.data.beginEvent.args as {detail?: string})?.detail;\n if (detailString) {\n const details = Helpers.Trace.parseDevtoolsDetails(detailString, 'devtools');\n if (details && 'track' in details) {\n return details.track;\n }\n }\n } else if (Types.Events.isConsoleTimeStamp(event)) {\n const track = event.args.data?.track;\n return typeof track === 'string' ? track : undefined;\n }\n\n // SyntheticConsoleTimingPair does not have track info.\n return undefined;\n}\n\n/**\n * Similar to the default {@see Helpers.Trace.eventTimeComparator}\n * but with a twist:\n * In case of equal start and end times, put the second event (within a\n * track) first.\n *\n * Explanation:\n * User timing entries come as trace events dispatched when\n * performance.measure/mark is called. The trace events buffered in\n * devtools frontend are sorted by the start time. If their start time\n * is the same, then the event for the first call will appear first.\n *\n * When entries are meant to be stacked, the corresponding\n * performance.measure calls usually are done in bottom-up direction:\n * calls for children first and for parent later (because the call\n * is usually done when the measured task is over). This means that\n * when two user timing events have the same start and end time, usually\n * the second event is the parent of the first. Hence the switch.\n *\n */\nexport function userTimingComparator<T extends Types.Events.SyntheticEventPair|Types.Events.ConsoleTimeStamp>(\n a: T, b: T, originalArray: readonly T[]): number {\n const {start: aStart, end: aEnd} = getEventTimings(a);\n const {start: bStart, end: bEnd} = getEventTimings(b);\n const timeDifference = Helpers.Trace.compareBeginAndEnd(aStart, bStart, aEnd, bEnd);\n if (timeDifference) {\n return timeDifference;\n }\n\n // Never re-order entries across different tracks.\n const aTrack = getEventTrack(a);\n const bTrack = getEventTrack(b);\n if (aTrack !== bTrack) {\n return 0; // Preserve current positions.\n }\n\n // Prefer the event located in a further position in the original array.\n const aIndex = originalArray.indexOf(a);\n const bIndex = originalArray.indexOf(b);\n return bIndex - aIndex;\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (ignoredNames.includes(event.name)) {\n return;\n }\n if (Types.Events.isUserTimingMeasure(event)) {\n measureTraceByTraceId.set(event.args.traceId, event);\n }\n if (Types.Events.isPerformanceMeasure(event)) {\n performanceMeasureEvents.push(event);\n return;\n }\n if (Types.Events.isPerformanceMark(event)) {\n performanceMarkEvents.push(event);\n }\n if (Types.Events.isConsoleTime(event)) {\n consoleTimings.push(event);\n }\n if (Types.Events.isConsoleTimeStamp(event)) {\n timestampEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n const asyncEvents = [...performanceMeasureEvents, ...consoleTimings];\n syntheticEvents = Helpers.Trace.createMatchedSortedSyntheticEvents(asyncEvents);\n syntheticEvents = syntheticEvents.sort((a, b) => userTimingComparator(a, b, [...syntheticEvents]));\n timestampEvents = timestampEvents.sort((a, b) => userTimingComparator(a, b, [...timestampEvents]));\n}\n\nexport function data(): UserTimingsData {\n return {\n consoleTimings: syntheticEvents.filter(e => e.cat === 'blink.console') as Types.Events.SyntheticConsoleTimingPair[],\n performanceMeasures: syntheticEvents.filter(e => e.cat === 'blink.user_timing') as\n Types.Events.SyntheticUserTimingPair[],\n performanceMarks: performanceMarkEvents,\n timestampEvents,\n measureTraceByTraceId,\n };\n}\n"]}
1
+ {"version":3,"file":"UserTimingsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/UserTimingsHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C;;;;IAII;AACJ,IAAI,eAAe,GAAuE,EAAE,CAAC;AAE7F,wEAAwE;AACxE,uEAAuE;AACvE,oEAAoE;AACpE,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,+DAA+D;AAC/D,wEAAwE;AACxE,uEAAuE;AACvE,uBAAuB;AACvB,IAAI,qBAAqB,GAAG,IAAI,GAAG,EAA0C,CAAC;AAC9E,IAAI,wBAAwB,GAAsC,EAAE,CAAC;AACrE,IAAI,qBAAqB,GAAmC,EAAE,CAAC;AAE/D,IAAI,cAAc,GAAqE,EAAE,CAAC;AAE1F,IAAI,eAAe,GAAoC,EAAE,CAAC;AA+B1D,MAAM,UAAU,KAAK;IACnB,eAAe,GAAG,EAAE,CAAC;IACrB,wBAAwB,GAAG,EAAE,CAAC;IAC9B,qBAAqB,GAAG,EAAE,CAAC;IAC3B,cAAc,GAAG,EAAE,CAAC;IACpB,eAAe,GAAG,EAAE,CAAC;IACrB,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,mBAAmB,GAAG;IAC1B,aAAa;IACb,eAAe;IACf,aAAa;IACb,YAAY;IACZ,mBAAmB;IACnB,iBAAiB;IACjB,cAAc;IACd,YAAY;IACZ,uBAAuB;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C7B,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,WAAW,GAAG,CAAC,GAAG,wBAAwB,EAAE,GAAG,cAAc,CAAC,CAAC;IACrE,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,WAAW,CAAC,CAAC;IAChF,eAAe,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IACnG,eAAe,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACrG,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,cAAc,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,eAAe,CAA8C;QACnH,mBAAmB,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,mBAAmB,CACpC;QAC1C,gBAAgB,EAAE,qBAAqB;QACvC,eAAe;QACf,qBAAqB;KACtB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2022 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 * as Types from '../types/types.js';\n\n/**\n * IMPORTANT!\n * See UserTimings.md in this directory for some handy documentation on\n * UserTimings and the trace events we parse currently.\n **/\nlet syntheticEvents: Array<Types.Events.SyntheticEventPair<Types.Events.PairableAsync>> = [];\n\n// There are two events dispatched for performance.measure calls: one to\n// represent the measured timing in the tracing clock (which we type as\n// PerformanceMeasure) and another one for the call itself (which we\n// type as UserTimingMeasure). The two events corresponding to the same\n// call are linked together by a common trace_id. The reason two events\n// are dispatched is because the first was originally added with the\n// implementation of the performance.measure API and it uses an\n// overridden timestamp and duration. To prevent breaking potential deps\n// created since then, a second event was added instead of changing the\n// params of the first.\nlet measureTraceByTraceId = new Map<number, Types.Events.UserTimingMeasure>();\nlet performanceMeasureEvents: Types.Events.PerformanceMeasure[] = [];\nlet performanceMarkEvents: Types.Events.PerformanceMark[] = [];\n\nlet consoleTimings: Array<Types.Events.ConsoleTimeBegin|Types.Events.ConsoleTimeEnd> = [];\n\nlet timestampEvents: Types.Events.ConsoleTimeStamp[] = [];\n\nexport interface UserTimingsData {\n /**\n * Events triggered with the performance.measure() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure\n */\n performanceMeasures: readonly Types.Events.SyntheticUserTimingPair[];\n /**\n * Events triggered with the performance.mark() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark\n */\n performanceMarks: readonly Types.Events.PerformanceMark[];\n /**\n * Events triggered with the console.time(), console.timeEnd() and\n * console.timeLog() API.\n * https://developer.mozilla.org/en-US/docs/Web/API/console/time\n */\n consoleTimings: readonly Types.Events.SyntheticConsoleTimingPair[];\n /**\n * Events triggered with the console.timeStamp() API\n * https://developer.mozilla.org/en-US/docs/Web/API/console/timeStamp\n */\n timestampEvents: readonly Types.Events.ConsoleTimeStamp[];\n /**\n * Events triggered to trace the call to performance.measure itself,\n * cached by trace_id.\n */\n measureTraceByTraceId: Map<number, Types.Events.UserTimingMeasure>;\n}\n\nexport function reset(): void {\n syntheticEvents = [];\n performanceMeasureEvents = [];\n performanceMarkEvents = [];\n consoleTimings = [];\n timestampEvents = [];\n measureTraceByTraceId = new Map();\n}\n\nconst resourceTimingNames = [\n 'workerStart',\n 'redirectStart',\n 'redirectEnd',\n 'fetchStart',\n 'domainLookupStart',\n 'domainLookupEnd',\n 'connectStart',\n 'connectEnd',\n 'secureConnectionStart',\n 'requestStart',\n 'responseStart',\n 'responseEnd',\n];\nconst navTimingNames = [\n 'navigationStart',\n 'unloadEventStart',\n 'unloadEventEnd',\n 'redirectStart',\n 'redirectEnd',\n 'fetchStart',\n 'commitNavigationEnd',\n 'domainLookupStart',\n 'domainLookupEnd',\n 'connectStart',\n 'connectEnd',\n 'secureConnectionStart',\n 'requestStart',\n 'responseStart',\n 'responseEnd',\n 'domLoading',\n 'domInteractive',\n 'domContentLoadedEventStart',\n 'domContentLoadedEventEnd',\n 'domComplete',\n 'loadEventStart',\n 'loadEventEnd',\n];\n// These are events dispatched under the blink.user_timing category\n// but that the user didn't add. Filter them out so that they do not\n// Appear in the timings track (they still appear in the main thread\n// flame chart).\nconst ignoredNames = [...resourceTimingNames, ...navTimingNames];\n\nfunction getEventTimings(event: Types.Events.SyntheticEventPair|Types.Events.ConsoleTimeStamp):\n {start: Types.Timing.Micro, end: Types.Timing.Micro} {\n if ('dur' in event) {\n // It's a SyntheticEventPair.\n return {start: event.ts, end: Types.Timing.Micro(event.ts + (event.dur ?? 0))};\n }\n\n if (Types.Events.isConsoleTimeStamp(event)) {\n const {start, end} = event.args.data || {};\n if (typeof start === 'number' && typeof end === 'number') {\n return {start: Types.Timing.Micro(start), end: Types.Timing.Micro(end)};\n }\n }\n\n // A ConsoleTimeStamp without start/end is just a point in time, so dur is 0.\n return {start: event.ts, end: event.ts};\n}\n\nfunction getEventTrack(event: Types.Events.SyntheticEventPair|Types.Events.ConsoleTimeStamp): string|undefined {\n if (event.cat === 'blink.user_timing') {\n // This is a SyntheticUserTimingPair\n const detailString =\n ((event as Types.Events.SyntheticUserTimingPair).args.data.beginEvent.args as {detail?: string})?.detail;\n if (detailString) {\n const details = Helpers.Trace.parseDevtoolsDetails(detailString, 'devtools');\n if (details && 'track' in details) {\n return details.track;\n }\n }\n } else if (Types.Events.isConsoleTimeStamp(event)) {\n const track = event.args.data?.track;\n return typeof track === 'string' ? track : undefined;\n }\n\n // SyntheticConsoleTimingPair does not have track info.\n return undefined;\n}\n\n/**\n * Similar to the default {@link Helpers.Trace.eventTimeComparator}\n * but with a twist:\n * In case of equal start and end times, put the second event (within a\n * track) first.\n *\n * Explanation:\n * User timing entries come as trace events dispatched when\n * performance.measure/mark is called. The trace events buffered in\n * devtools frontend are sorted by the start time. If their start time\n * is the same, then the event for the first call will appear first.\n *\n * When entries are meant to be stacked, the corresponding\n * performance.measure calls usually are done in bottom-up direction:\n * calls for children first and for parent later (because the call\n * is usually done when the measured task is over). This means that\n * when two user timing events have the same start and end time, usually\n * the second event is the parent of the first. Hence the switch.\n *\n */\nexport function userTimingComparator<T extends Types.Events.SyntheticEventPair|Types.Events.ConsoleTimeStamp>(\n a: T, b: T, originalArray: readonly T[]): number {\n const {start: aStart, end: aEnd} = getEventTimings(a);\n const {start: bStart, end: bEnd} = getEventTimings(b);\n const timeDifference = Helpers.Trace.compareBeginAndEnd(aStart, bStart, aEnd, bEnd);\n if (timeDifference) {\n return timeDifference;\n }\n\n // Never re-order entries across different tracks.\n const aTrack = getEventTrack(a);\n const bTrack = getEventTrack(b);\n if (aTrack !== bTrack) {\n return 0; // Preserve current positions.\n }\n\n // Prefer the event located in a further position in the original array.\n const aIndex = originalArray.indexOf(a);\n const bIndex = originalArray.indexOf(b);\n return bIndex - aIndex;\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (ignoredNames.includes(event.name)) {\n return;\n }\n if (Types.Events.isUserTimingMeasure(event)) {\n measureTraceByTraceId.set(event.args.traceId, event);\n }\n if (Types.Events.isPerformanceMeasure(event)) {\n performanceMeasureEvents.push(event);\n return;\n }\n if (Types.Events.isPerformanceMark(event)) {\n performanceMarkEvents.push(event);\n }\n if (Types.Events.isConsoleTime(event)) {\n consoleTimings.push(event);\n }\n if (Types.Events.isConsoleTimeStamp(event)) {\n timestampEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n const asyncEvents = [...performanceMeasureEvents, ...consoleTimings];\n syntheticEvents = Helpers.Trace.createMatchedSortedSyntheticEvents(asyncEvents);\n syntheticEvents = syntheticEvents.sort((a, b) => userTimingComparator(a, b, [...syntheticEvents]));\n timestampEvents = timestampEvents.sort((a, b) => userTimingComparator(a, b, [...timestampEvents]));\n}\n\nexport function data(): UserTimingsData {\n return {\n consoleTimings: syntheticEvents.filter(e => e.cat === 'blink.console') as Types.Events.SyntheticConsoleTimingPair[],\n performanceMeasures: syntheticEvents.filter(e => e.cat === 'blink.user_timing') as\n Types.Events.SyntheticUserTimingPair[],\n performanceMarks: performanceMarkEvents,\n timestampEvents,\n measureTraceByTraceId,\n };\n}\n"]}
@@ -8,13 +8,13 @@
8
8
  "forceConsistentCasingInFileNames": true,
9
9
  "inlineSources": true,
10
10
  "lib": [
11
+ "dom",
12
+ "dom.iterable",
11
13
  "ES2023",
12
14
  "ES2024.Promise",
13
15
  "ESNext.Iterator",
14
16
  "ESNext.Collection",
15
- "ESNext.Array",
16
- "dom",
17
- "dom.iterable"
17
+ "ESNext.Array"
18
18
  ],
19
19
  "module": "esnext",
20
20
  "noEmitOnError": true,
@@ -31,6 +31,7 @@
31
31
  "target": "ES2023",
32
32
  "tsBuildInfoFile": "devtools_entrypoint-bundle-typescript-tsconfig.json.tsbuildinfo",
33
33
  "typeRoots": [],
34
+ "types": [],
34
35
  "useUnknownInCatchVariables": false
35
36
  },
36
37
  "files": [
@@ -8,13 +8,13 @@
8
8
  "forceConsistentCasingInFileNames": true,
9
9
  "inlineSources": true,
10
10
  "lib": [
11
+ "dom",
12
+ "dom.iterable",
11
13
  "ES2023",
12
14
  "ES2024.Promise",
13
15
  "ESNext.Iterator",
14
16
  "ESNext.Collection",
15
- "ESNext.Array",
16
- "dom",
17
- "dom.iterable"
17
+ "ESNext.Array"
18
18
  ],
19
19
  "module": "esnext",
20
20
  "noEmitOnError": true,
@@ -31,6 +31,7 @@
31
31
  "target": "ES2023",
32
32
  "tsBuildInfoFile": "handlers-tsconfig.json.tsbuildinfo",
33
33
  "typeRoots": [],
34
+ "types": [],
34
35
  "useUnknownInCatchVariables": false
35
36
  },
36
37
  "files": [
@@ -73,12 +74,21 @@
73
74
  "../../../../../../../node_modules/@types/filesystem/index.d.ts"
74
75
  ],
75
76
  "references": [
77
+ {
78
+ "path": "../../../core/common/bundle-tsconfig.json"
79
+ },
76
80
  {
77
81
  "path": "../../../core/platform/bundle-tsconfig.json"
78
82
  },
83
+ {
84
+ "path": "../../../core/sdk/bundle-tsconfig.json"
85
+ },
79
86
  {
80
87
  "path": "../../../generated/generated-tsconfig.json"
81
88
  },
89
+ {
90
+ "path": "../../../generated/protocol-tsconfig.json"
91
+ },
82
92
  {
83
93
  "path": "../../../third_party/third-party-web/bundle-tsconfig.json"
84
94
  },
@@ -6,7 +6,7 @@
6
6
  // browser.
7
7
  // 3. Therefore, from a developer's point of view, there is nothing more they
8
8
  // can do if they've put `async` on, and within the context of Insights, we
9
- // shouldn't report an async script as render blocking.
9
+ // shouldn't report an async script as render-blocking.
10
10
  // In the future we may want to consider suggesting the use of `defer` over
11
11
  // `async`, as it doesn't have this concern, but for now we'll allow `async`
12
12
  // and not report it as an issue.
@@ -1 +1 @@
1
- {"version":3,"file":"Network.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Network.ts"],"names":[],"mappings":"AAMA,6DAA6D;AAC7D,oCAAoC;AACpC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,cAAc;AACd,6EAA6E;AAC7E,8EAA8E;AAC9E,0DAA0D;AAC1D,2EAA2E;AAC3E,4EAA4E;AAC5E,iCAAiC;AACjC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAiB;IACzD,cAAc;IACd,mCAAmC;IACnC,sBAAsB;CACvB,CAAC,CAAC;AAEH,MAAM,UAAU,4CAA4C,CAAC,KAA8B;IACzF,OAAO,CAAC,0BAA0B,CAAC,GAAG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AE,CAAC;YACZ,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;oBACnB,mBAAmB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;gBAC1C,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,UAAU;gBACb,mBAAmB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;gBACvC,MAAM;YACR,KAAK,UAAU;gBACb,mBAAmB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;gBACvC,MAAM;YACR,KAAK,iBAAiB;gBACpB,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;gBAC9C,MAAM;YACR,KAAK,SAAS;gBACZ,mBAAmB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;gBACtC,MAAM;YACR;gBACE,4BAA4B;gBAC5B,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,MAAM,wBAAwB,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CAAC,KAA8B;IAC/E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;QACvD,sEAAsE;QACtE,6DAA6D;QAC7D,8FAA8F;QAC9F,OAAO,wBAAwB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,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.\nimport * as Protocol from '../../../generated/protocol.js';\nimport type {RenderBlocking, SyntheticNetworkRequest} from '../types/TraceEvents.js';\n\n// Important: we purposefully treat `potentially_blocking` as\n// non-render-blocking here because:\n// 1. An async script can run on the main thread at any point, including before\n// the page is loaded\n// 2. An async script will never block the parsing and rendering process of the\n// browser.\n// 3. Therefore, from a developer's point of view, there is nothing more they\n// can do if they've put `async` on, and within the context of Insights, we\n// shouldn't report an async script as render blocking.\n// In the future we may want to consider suggesting the use of `defer` over\n// `async`, as it doesn't have this concern, but for now we'll allow `async`\n// and not report it as an issue.\nconst NON_RENDER_BLOCKING_VALUES = new Set<RenderBlocking>([\n 'non_blocking',\n 'dynamically_injected_non_blocking',\n 'potentially_blocking',\n]);\n\nexport function isSyntheticNetworkRequestEventRenderBlocking(event: SyntheticNetworkRequest): boolean {\n return !NON_RENDER_BLOCKING_VALUES.has(event.args.data.renderBlocking);\n}\n\nconst HIGH_NETWORK_PRIORITIES = new Set<Protocol.Network.ResourcePriority>([\n Protocol.Network.ResourcePriority.VeryHigh,\n Protocol.Network.ResourcePriority.High,\n Protocol.Network.ResourcePriority.Medium,\n]);\n\nexport function isSyntheticNetworkRequestHighPriority(event: SyntheticNetworkRequest): boolean {\n return HIGH_NETWORK_PRIORITIES.has(event.args.data.priority);\n}\n\nexport interface CacheControl {\n 'max-age'?: number;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'must-revalidate'?: boolean;\n // eslint-disable-next-line @stylistic/quote-props\n 'private'?: boolean;\n}\n\nexport const CACHEABLE_STATUS_CODES = new Set([200, 203, 206]);\n\n/** @type {Set<LH.Crdp.Network.ResourceType>} */\nexport const STATIC_RESOURCE_TYPES = new Set([\n Protocol.Network.ResourceType.Font,\n Protocol.Network.ResourceType.Image,\n Protocol.Network.ResourceType.Media,\n Protocol.Network.ResourceType.Script,\n Protocol.Network.ResourceType.Stylesheet,\n]);\n\nexport const NON_NETWORK_SCHEMES = [\n 'blob', // @see https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL\n 'data', // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\n 'intent', // @see https://developer.chrome.com/docs/multidevice/android/intents/\n 'file', // @see https://en.wikipedia.org/wiki/File_URI_scheme\n 'filesystem', // @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystem\n 'chrome-extension',\n];\n\n/**\n * Parses Cache-Control directives based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control\n * eg. 'no-cache, no-store, max-age=0, no-transform, private' will return\n * {no-cache: true, no-store: true, max-age: 0, no-transform: true, private: true}\n */\nexport function parseCacheControl(header: string|null): CacheControl|null {\n if (!header) {\n return null;\n }\n\n const directives = header.split(',').map(directive => directive.trim());\n const cacheControlOptions: CacheControl = {};\n\n for (const directive of directives) {\n const [key, value] = directive.split('=').map(part => part.trim());\n\n switch (key) {\n case 'max-age': {\n const maxAge = parseInt(value, 10);\n if (!isNaN(maxAge)) {\n cacheControlOptions['max-age'] = maxAge;\n }\n break;\n }\n case 'no-cache':\n cacheControlOptions['no-cache'] = true;\n break;\n case 'no-store':\n cacheControlOptions['no-store'] = true;\n break;\n case 'must-revalidate':\n cacheControlOptions['must-revalidate'] = true;\n break;\n case 'private':\n cacheControlOptions['private'] = true;\n break;\n default:\n // Ignore unknown directives\n break;\n }\n }\n\n return cacheControlOptions;\n}\n\nconst SECURE_LOCALHOST_DOMAINS = ['localhost', '127.0.0.1'];\n\n/**\n * Is the host localhost-enough to satisfy the \"secure context\" definition\n * https://github.com/GoogleChrome/lighthouse/pull/11766#discussion_r582340683\n */\nexport function isSyntheticNetworkRequestLocalhost(event: SyntheticNetworkRequest): boolean {\n try {\n const hostname = new URL(event.args.data.url).hostname;\n // Any hostname terminating in `.localhost` is considered to be local.\n // https://w3c.github.io/webappsec-secure-contexts/#localhost\n // This method doesn't consider IPs that resolve to loopback, IPv6 or other loopback edgecases\n return SECURE_LOCALHOST_DOMAINS.includes(hostname) || hostname.endsWith('.localhost');\n } catch {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"Network.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Network.ts"],"names":[],"mappings":"AAMA,6DAA6D;AAC7D,oCAAoC;AACpC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,cAAc;AACd,6EAA6E;AAC7E,8EAA8E;AAC9E,0DAA0D;AAC1D,2EAA2E;AAC3E,4EAA4E;AAC5E,iCAAiC;AACjC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAiB;IACzD,cAAc;IACd,mCAAmC;IACnC,sBAAsB;CACvB,CAAC,CAAC;AAEH,MAAM,UAAU,4CAA4C,CAAC,KAA8B;IACzF,OAAO,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAoC;;;;CAI1E,CAAC,CAAC;AAEH,MAAM,UAAU,qCAAqC,CAAC,KAA8B;IAClF,OAAO,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAWD,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE/D,gDAAgD;AAChD,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;;;;;;CAM5C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM,EAAS,4EAA4E;IAC3F,MAAM,EAAS,kFAAkF;IACjG,QAAQ,EAAO,sEAAsE;IACrF,MAAM,EAAS,qDAAqD;IACpE,YAAY,EAAG,mEAAmE;IAClF,kBAAkB;CACnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAmB;IACnD,IAA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AACH,MAAM,UAAU,kCAAkC,CAAC,KAA8B;IAC/E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;QACvD,sEAAsE;QACtE,6DAA6D;QAC7D,8FAA8F;QAC9F,OAAO,wBAAwB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,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.\nimport * as Protocol from '../../../generated/protocol.js';\nimport type {RenderBlocking, SyntheticNetworkRequest} from '../types/TraceEvents.js';\n\n// Important: we purposefully treat `potentially_blocking` as\n// non-render-blocking here because:\n// 1. An async script can run on the main thread at any point, including before\n// the page is loaded\n// 2. An async script will never block the parsing and rendering process of the\n// browser.\n// 3. Therefore, from a developer's point of view, there is nothing more they\n// can do if they've put `async` on, and within the context of Insights, we\n// shouldn't report an async script as render-blocking.\n// In the future we may want to consider suggesting the use of `defer` over\n// `async`, as it doesn't have this concern, but for now we'll allow `async`\n// and not report it as an issue.\nconst NON_RENDER_BLOCKING_VALUES = new Set<RenderBlocking>([\n 'non_blocking',\n 'dynamically_injected_non_blocking',\n 'potentially_blocking',\n]);\n\nexport function isSyntheticNetworkRequestEventRenderBlocking(event: SyntheticNetworkRequest): boolean {\n return !NON_RENDER_BLOCKING_VALUES.has(event.args.data.renderBlocking);\n}\n\nconst HIGH_NETWORK_PRIORITIES = new Set<Protocol.Network.ResourcePriority>([\n Protocol.Network.ResourcePriority.VeryHigh,\n Protocol.Network.ResourcePriority.High,\n Protocol.Network.ResourcePriority.Medium,\n]);\n\nexport function isSyntheticNetworkRequestHighPriority(event: SyntheticNetworkRequest): boolean {\n return HIGH_NETWORK_PRIORITIES.has(event.args.data.priority);\n}\n\nexport interface CacheControl {\n 'max-age'?: number;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'must-revalidate'?: boolean;\n // eslint-disable-next-line @stylistic/quote-props\n 'private'?: boolean;\n}\n\nexport const CACHEABLE_STATUS_CODES = new Set([200, 203, 206]);\n\n/** @type {Set<LH.Crdp.Network.ResourceType>} */\nexport const STATIC_RESOURCE_TYPES = new Set([\n Protocol.Network.ResourceType.Font,\n Protocol.Network.ResourceType.Image,\n Protocol.Network.ResourceType.Media,\n Protocol.Network.ResourceType.Script,\n Protocol.Network.ResourceType.Stylesheet,\n]);\n\nexport const NON_NETWORK_SCHEMES = [\n 'blob', // @see https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL\n 'data', // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\n 'intent', // @see https://developer.chrome.com/docs/multidevice/android/intents/\n 'file', // @see https://en.wikipedia.org/wiki/File_URI_scheme\n 'filesystem', // @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystem\n 'chrome-extension',\n];\n\n/**\n * Parses Cache-Control directives based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control\n * eg. 'no-cache, no-store, max-age=0, no-transform, private' will return\n * {no-cache: true, no-store: true, max-age: 0, no-transform: true, private: true}\n */\nexport function parseCacheControl(header: string|null): CacheControl|null {\n if (!header) {\n return null;\n }\n\n const directives = header.split(',').map(directive => directive.trim());\n const cacheControlOptions: CacheControl = {};\n\n for (const directive of directives) {\n const [key, value] = directive.split('=').map(part => part.trim());\n\n switch (key) {\n case 'max-age': {\n const maxAge = parseInt(value, 10);\n if (!isNaN(maxAge)) {\n cacheControlOptions['max-age'] = maxAge;\n }\n break;\n }\n case 'no-cache':\n cacheControlOptions['no-cache'] = true;\n break;\n case 'no-store':\n cacheControlOptions['no-store'] = true;\n break;\n case 'must-revalidate':\n cacheControlOptions['must-revalidate'] = true;\n break;\n case 'private':\n cacheControlOptions['private'] = true;\n break;\n default:\n // Ignore unknown directives\n break;\n }\n }\n\n return cacheControlOptions;\n}\n\nconst SECURE_LOCALHOST_DOMAINS = ['localhost', '127.0.0.1'];\n\n/**\n * Is the host localhost-enough to satisfy the \"secure context\" definition\n * https://github.com/GoogleChrome/lighthouse/pull/11766#discussion_r582340683\n */\nexport function isSyntheticNetworkRequestLocalhost(event: SyntheticNetworkRequest): boolean {\n try {\n const hostname = new URL(event.args.data.url).hostname;\n // Any hostname terminating in `.localhost` is considered to be local.\n // https://w3c.github.io/webappsec-secure-contexts/#localhost\n // This method doesn't consider IPs that resolve to loopback, IPv6 or other loopback edgecases\n return SECURE_LOCALHOST_DOMAINS.includes(hostname) || hostname.endsWith('.localhost');\n } catch {\n return false;\n }\n}\n"]}
@@ -438,20 +438,13 @@ export class SamplesIntegrator {
438
438
  if (showAllEvents) {
439
439
  return;
440
440
  }
441
- let previousNativeFrameName = null;
442
441
  let j = 0;
443
442
  for (let i = 0; i < stack.length; ++i) {
444
443
  const frame = stack[i].callFrame;
445
444
  const nativeRuntimeFrame = _a.isNativeRuntimeFrame(frame);
446
- if (nativeRuntimeFrame &&
447
- !_a.showNativeName(frame.functionName, engineConfig.includeRuntimeCallStats)) {
445
+ if (nativeRuntimeFrame) {
448
446
  continue;
449
447
  }
450
- const nativeFrameName = nativeRuntimeFrame ? _a.nativeGroup(frame.functionName) : null;
451
- if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {
452
- continue;
453
- }
454
- previousNativeFrameName = nativeFrameName;
455
448
  stack[j++] = stack[i];
456
449
  }
457
450
  stack.length = j;
@@ -1 +1 @@
1
- {"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAA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YAC/B,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;YAC9B,GAAG;YACH,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACzC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;YAC5D,IAAI,EAAE,EAAC,IAAI,EAAE,EAAC,UAAU,EAAE,OAAO,EAAC,EAAC;YACnC,kCAAkC;YAClC,EAAE,EAAE,KAA+B;SACpC,CAAC;QAEF,OAAO;YACL,WAAW,EAAE,CAAC,eAAe,CAAC;YAC9B,QAAQ,EAAE;gBACR,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW;aAC9C;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,8BAA8B,CAAC,WAA0C;QAC9E,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;QAClF,MAAM,OAAO,GAAG,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QACnD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;;AAED,WAAiB,iBAAiB;IAChC,IAAY,YAGX;IAHD,WAAY,YAAY;QACtB,mCAAmB,CAAA;QACnB,+BAAe,CAAA;IACjB,CAAC,EAHW,YAAY,GAAZ,8BAAY,KAAZ,8BAAY,QAGvB;AACH,CAAC,EALgB,iBAAiB,KAAjB,iBAAiB,QAKjC","sourcesContent":["// Copyright 2023 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 Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {milliToMicro} from './Timing.js';\nimport {extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficient (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of running the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.Events.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.Events.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.Events.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.Events.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is useful in\n * cases where we can be missing the start of JS invocation events if\n * we start tracing half-way through.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.Events.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n #profileId: Types.Events.ProfileID;\n\n /**\n * Keeps track of the individual samples from the CPU Profile.\n * Only used with Debug Mode experiment enabled.\n */\n jsSampleEvents: Types.Events.SyntheticJSSample[] = [];\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, profileId: Types.Events.ProfileID,\n pid: Types.Events.ProcessID, tid: Types.Events.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.defaults();\n this.#profileId = profileId;\n }\n\n buildProfileCalls(traceEvents: Types.Events.Event[]): Types.Events.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n sortTraceEventsInPlace(this.jsSampleEvents);\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.Events.Event): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.Events.SyntheticProfileCall, parent?: Types.Events.Event): void {\n if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.Events.Event): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.Events.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n if (!samples) {\n return [];\n }\n const calls: Types.Events.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));\n if (!node) {\n continue;\n }\n const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);\n calls.push(call);\n\n if (this.#engineConfig.debugMode) {\n const traceId = this.#profileModel.traceIds?.[i];\n this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));\n }\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n /**\n * Given a synthetic profile call, returns an array of profile calls\n * representing the stack trace that profile call belongs to based on\n * its nodeId. The input profile call will be at the top of the\n * returned stack (last position), meaning that any other frames that\n * were effectively above it are omitted.\n * @param profileCall\n * @param overrideTimeStamp a custom timestamp to use for the returned\n * profile calls. If not defined, the timestamp of the input\n * profileCall is used instead. This param is useful for example when\n * creating the profile calls for a sample with a trace id, since the\n * timestamp of the corresponding trace event should be used instead\n * of the sample's.\n */\n\n #makeProfileCallsForStack(profileCall: Types.Events.SyntheticProfileCall, overrideTimeStamp?: Types.Timing.Micro):\n Types.Events.SyntheticProfileCall[] {\n let node = this.#profileModel.nodeById(profileCall.nodeId);\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const callFrames = new Array<Types.Events.SyntheticProfileCall>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = callFrames.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection call frame on top of the stack.\n callFrames[i--] = profileCall;\n }\n\n // Many of these ProfileCalls will be GC'd later when we estimate the frame\n // durations\n while (node) {\n callFrames[i--] = makeProfileCall(\n node, profileCall.profileId, profileCall.sampleIndex, overrideTimeStamp ?? profileCall.ts, this.#processId,\n this.#threadId);\n node = node.parent;\n }\n return callFrames;\n }\n\n #getStackForSampleTraceId(traceId: number, timestamp: Types.Timing.Micro): Types.Events.SyntheticProfileCall[]|null {\n const nodeId = this.#profileModel.traceIds?.[traceId];\n const node = nodeId && this.#profileModel.nodeById(nodeId);\n const maybeCallForTraceId =\n node && makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);\n if (!maybeCallForTraceId) {\n return null;\n }\n if (this.#engineConfig.debugMode) {\n this.jsSampleEvents.push(this.#makeJSSampleEvent(maybeCallForTraceId, timestamp, traceId));\n }\n return this.#makeProfileCallsForStack(maybeCallForTraceId);\n }\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.Events.Event): void {\n let stackTrace = this.#currentJSStack;\n if (Types.Events.isProfileCall(event)) {\n stackTrace = this.#makeProfileCallsForStack(event);\n }\n const traceId = extractSampleTraceId(event);\n const maybeCallForTraceId = traceId && this.#getStackForSampleTraceId(traceId, event.ts);\n if (maybeCallForTraceId) {\n stackTrace = maybeCallForTraceId;\n }\n\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n this.#truncateJSStack(i, event.ts);\n\n for (; i < stackTrace.length; ++i) {\n const call = stackTrace[i];\n if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id ||\n call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.Micro): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n #makeJSSampleEvent(call: Types.Events.SyntheticProfileCall, timestamp: Types.Timing.Micro, traceId?: number):\n Types.Events.SyntheticJSSample {\n const JSSampleEvent: Types.Events.SyntheticJSSample = {\n name: Types.Events.Name.JS_SAMPLE,\n cat: 'devtools.timeline',\n args: {\n data: {traceId, stackTrace: this.#makeProfileCallsForStack(call).map(e => e.callFrame)},\n },\n ph: Types.Events.Phase.INSTANT,\n ts: timestamp,\n dur: Types.Timing.Micro(0),\n pid: this.#processId,\n tid: this.#threadId,\n };\n return JSSampleEvent;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): SamplesIntegrator.NativeGroups|null {\n if (nativeName.startsWith('Parse')) {\n return SamplesIntegrator.NativeGroups.PARSE;\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return SamplesIntegrator.NativeGroups.COMPILE;\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames(stack: Types.Events.SyntheticProfileCall[], engineConfig: Types.Configuration.Configuration):\n void {\n const showAllEvents = engineConfig.showAllEvents;\n if (showAllEvents) {\n return;\n }\n let previousNativeFrameName: string|null = null;\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame &&\n !SamplesIntegrator.showNativeName(frame.functionName, engineConfig.includeRuntimeCallStats)) {\n continue;\n }\n const nativeFrameName = nativeRuntimeFrame ? SamplesIntegrator.nativeGroup(frame.functionName) : null;\n if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {\n continue;\n }\n previousNativeFrameName = nativeFrameName;\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n\n static createFakeTraceFromCpuProfile(profile: Protocol.Profiler.Profile, tid: Types.Events.ThreadID):\n Types.File.TraceFile {\n if (!profile) {\n return {traceEvents: [], metadata: {}};\n }\n // The |Name.CPU_PROFILE| will let MetaHandler to set |traceIsGeneric| to false\n // The start time and duration is important here because we'll use them to determine the traceBounds\n // We use the start and end time of the profile (which is longer than all samples), so the Performance\n // panel won't truncate this time period.\n const cpuProfileEvent: Types.Events.SyntheticCpuProfile = {\n cat: 'disabled-by-default-devtools.timeline',\n name: Types.Events.Name.CPU_PROFILE,\n ph: Types.Events.Phase.COMPLETE,\n pid: Types.Events.ProcessID(1),\n tid,\n ts: Types.Timing.Micro(profile.startTime),\n dur: Types.Timing.Micro(profile.endTime - profile.startTime),\n args: {data: {cpuProfile: profile}},\n // Create an arbitrary profile id.\n id: '0x1' as Types.Events.ProfileID,\n };\n\n return {\n traceEvents: [cpuProfileEvent],\n metadata: {\n dataOrigin: Types.File.DataOrigin.CPU_PROFILE,\n }\n };\n }\n\n static extractCpuProfileFromFakeTrace(traceEvents: readonly Types.Events.Event[]): Protocol.Profiler.Profile {\n const profileEvent = traceEvents.find(e => Types.Events.isSyntheticCpuProfile(e));\n const profile = profileEvent?.args.data.cpuProfile;\n if (!profile) {\n throw new Error('Missing cpuProfile data');\n }\n return profile;\n }\n}\n\nexport namespace SamplesIntegrator {\n export enum NativeGroups {\n COMPILE = 'Compile',\n PARSE = 'Parse',\n }\n}\n"]}
1
+ {"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACH,wBAAwB,GAAwC,EAAE,CAAC;IACnE;;;;;;OAMG;IACH,eAAe,GAAwC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AAK,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;QAClF,MAAM,OAAO,GAAG,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QACnD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;;AAED,WAAiB,iBAAiB;IAChC,IAAY,YAGX;IAHD,WAAY,YAAY;QACtB,mCAAmB,CAAA;QACnB,+BAAe,CAAA;IACjB,CAAC,EAHW,YAAY,GAAZ,8BAAY,KAAZ,8BAAY,QAGvB;AACH,CAAC,EALgB,iBAAiB,KAAjB,iBAAiB,QAKjC","sourcesContent":["// Copyright 2023 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 Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {milliToMicro} from './Timing.js';\nimport {extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficient (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of running the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.Events.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.Events.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.Events.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.Events.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is useful in\n * cases where we can be missing the start of JS invocation events if\n * we start tracing half-way through.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.Events.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n #profileId: Types.Events.ProfileID;\n\n /**\n * Keeps track of the individual samples from the CPU Profile.\n * Only used with Debug Mode experiment enabled.\n */\n jsSampleEvents: Types.Events.SyntheticJSSample[] = [];\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, profileId: Types.Events.ProfileID,\n pid: Types.Events.ProcessID, tid: Types.Events.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.defaults();\n this.#profileId = profileId;\n }\n\n buildProfileCalls(traceEvents: Types.Events.Event[]): Types.Events.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n sortTraceEventsInPlace(this.jsSampleEvents);\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.Events.Event): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.Events.SyntheticProfileCall, parent?: Types.Events.Event): void {\n if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.Events.Event): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.Events.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n if (!samples) {\n return [];\n }\n const calls: Types.Events.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));\n if (!node) {\n continue;\n }\n const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);\n calls.push(call);\n\n if (this.#engineConfig.debugMode) {\n const traceId = this.#profileModel.traceIds?.[i];\n this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));\n }\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n /**\n * Given a synthetic profile call, returns an array of profile calls\n * representing the stack trace that profile call belongs to based on\n * its nodeId. The input profile call will be at the top of the\n * returned stack (last position), meaning that any other frames that\n * were effectively above it are omitted.\n * @param profileCall\n * @param overrideTimeStamp a custom timestamp to use for the returned\n * profile calls. If not defined, the timestamp of the input\n * profileCall is used instead. This param is useful for example when\n * creating the profile calls for a sample with a trace id, since the\n * timestamp of the corresponding trace event should be used instead\n * of the sample's.\n */\n\n #makeProfileCallsForStack(profileCall: Types.Events.SyntheticProfileCall, overrideTimeStamp?: Types.Timing.Micro):\n Types.Events.SyntheticProfileCall[] {\n let node = this.#profileModel.nodeById(profileCall.nodeId);\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const callFrames = new Array<Types.Events.SyntheticProfileCall>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = callFrames.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection call frame on top of the stack.\n callFrames[i--] = profileCall;\n }\n\n // Many of these ProfileCalls will be GC'd later when we estimate the frame\n // durations\n while (node) {\n callFrames[i--] = makeProfileCall(\n node, profileCall.profileId, profileCall.sampleIndex, overrideTimeStamp ?? profileCall.ts, this.#processId,\n this.#threadId);\n node = node.parent;\n }\n return callFrames;\n }\n\n #getStackForSampleTraceId(traceId: number, timestamp: Types.Timing.Micro): Types.Events.SyntheticProfileCall[]|null {\n const nodeId = this.#profileModel.traceIds?.[traceId];\n const node = nodeId && this.#profileModel.nodeById(nodeId);\n const maybeCallForTraceId =\n node && makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);\n if (!maybeCallForTraceId) {\n return null;\n }\n if (this.#engineConfig.debugMode) {\n this.jsSampleEvents.push(this.#makeJSSampleEvent(maybeCallForTraceId, timestamp, traceId));\n }\n return this.#makeProfileCallsForStack(maybeCallForTraceId);\n }\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.Events.Event): void {\n let stackTrace = this.#currentJSStack;\n if (Types.Events.isProfileCall(event)) {\n stackTrace = this.#makeProfileCallsForStack(event);\n }\n const traceId = extractSampleTraceId(event);\n const maybeCallForTraceId = traceId && this.#getStackForSampleTraceId(traceId, event.ts);\n if (maybeCallForTraceId) {\n stackTrace = maybeCallForTraceId;\n }\n\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n this.#truncateJSStack(i, event.ts);\n\n for (; i < stackTrace.length; ++i) {\n const call = stackTrace[i];\n if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id ||\n call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.Micro): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n #makeJSSampleEvent(call: Types.Events.SyntheticProfileCall, timestamp: Types.Timing.Micro, traceId?: number):\n Types.Events.SyntheticJSSample {\n const JSSampleEvent: Types.Events.SyntheticJSSample = {\n name: Types.Events.Name.JS_SAMPLE,\n cat: 'devtools.timeline',\n args: {\n data: {traceId, stackTrace: this.#makeProfileCallsForStack(call).map(e => e.callFrame)},\n },\n ph: Types.Events.Phase.INSTANT,\n ts: timestamp,\n dur: Types.Timing.Micro(0),\n pid: this.#processId,\n tid: this.#threadId,\n };\n return JSSampleEvent;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): SamplesIntegrator.NativeGroups|null {\n if (nativeName.startsWith('Parse')) {\n return SamplesIntegrator.NativeGroups.PARSE;\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return SamplesIntegrator.NativeGroups.COMPILE;\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames(stack: Types.Events.SyntheticProfileCall[], engineConfig: Types.Configuration.Configuration):\n void {\n const showAllEvents = engineConfig.showAllEvents;\n if (showAllEvents) {\n return;\n }\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame) {\n continue;\n }\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n\n static createFakeTraceFromCpuProfile(profile: Protocol.Profiler.Profile, tid: Types.Events.ThreadID):\n Types.File.TraceFile {\n if (!profile) {\n return {traceEvents: [], metadata: {}};\n }\n // The |Name.CPU_PROFILE| will let MetaHandler to set |traceIsGeneric| to false\n // The start time and duration is important here because we'll use them to determine the traceBounds\n // We use the start and end time of the profile (which is longer than all samples), so the Performance\n // panel won't truncate this time period.\n const cpuProfileEvent: Types.Events.SyntheticCpuProfile = {\n cat: 'disabled-by-default-devtools.timeline',\n name: Types.Events.Name.CPU_PROFILE,\n ph: Types.Events.Phase.COMPLETE,\n pid: Types.Events.ProcessID(1),\n tid,\n ts: Types.Timing.Micro(profile.startTime),\n dur: Types.Timing.Micro(profile.endTime - profile.startTime),\n args: {data: {cpuProfile: profile}},\n // Create an arbitrary profile id.\n id: '0x1' as Types.Events.ProfileID,\n };\n\n return {\n traceEvents: [cpuProfileEvent],\n metadata: {\n dataOrigin: Types.File.DataOrigin.CPU_PROFILE,\n }\n };\n }\n\n static extractCpuProfileFromFakeTrace(traceEvents: readonly Types.Events.Event[]): Protocol.Profiler.Profile {\n const profileEvent = traceEvents.find(e => Types.Events.isSyntheticCpuProfile(e));\n const profile = profileEvent?.args.data.cpuProfile;\n if (!profile) {\n throw new Error('Missing cpuProfile data');\n }\n return profile;\n }\n}\n\nexport namespace SamplesIntegrator {\n export enum NativeGroups {\n COMPILE = 'Compile',\n PARSE = 'Parse',\n }\n}\n"]}
@@ -4,7 +4,7 @@ export declare const secondsToMilli: (value: Types.Timing.Seconds) => Types.Timi
4
4
  export declare const secondsToMicro: (value: Types.Timing.Seconds) => Types.Timing.Micro;
5
5
  export declare const microToMilli: (value: Types.Timing.Micro) => Types.Timing.Milli;
6
6
  export declare const microToSeconds: (value: Types.Timing.Micro) => Types.Timing.Seconds;
7
- export declare function timeStampForEventAdjustedByClosestNavigation(event: Types.Events.Event, traceBounds: Types.Timing.TraceWindowMicro, navigationsByNavigationId: Map<string, Types.Events.NavigationStart>, navigationsByFrameId: Map<string, Types.Events.NavigationStart[]>): Types.Timing.Micro;
7
+ export declare function timeStampForEventAdjustedByClosestNavigation(event: Types.Events.Event, traceBounds: Types.Timing.TraceWindowMicro, navigationsByNavigationId: Map<string, Types.Events.NavigationStart>, softNavigationsById: Map<number, Types.Events.SoftNavigationStart>, navigationsByFrameId: Map<string, Types.Events.NavigationStart[]>): Types.Timing.Micro;
8
8
  /**
9
9
  * Expands the trace window by a provided percentage or, if it the expanded window is smaller than 1 millisecond, expands it to 1 millisecond.
10
10
  * If the expanded window is outside of the max trace window, cut the overflowing bound to the max trace window bound.
@@ -9,9 +9,16 @@ export const secondsToMilli = (value) => Types.Timing.Milli(value * 1000);
9
9
  export const secondsToMicro = (value) => milliToMicro(secondsToMilli(value));
10
10
  export const microToMilli = (value) => Types.Timing.Milli(value / 1000);
11
11
  export const microToSeconds = (value) => Types.Timing.Seconds(value / 1000 / 1000);
12
- export function timeStampForEventAdjustedByClosestNavigation(event, traceBounds, navigationsByNavigationId, navigationsByFrameId) {
12
+ export function timeStampForEventAdjustedByClosestNavigation(event, traceBounds, navigationsByNavigationId, softNavigationsById, navigationsByFrameId) {
13
13
  let eventTimeStamp = event.ts - traceBounds.min;
14
- if (event.args?.data?.navigationId) {
14
+ if (event.name === Types.Events.Name.MARK_LCP_CANDIDATE_FOR_SOFT_NAVIGATION &&
15
+ event.args?.data?.performanceTimelineNavigationId) {
16
+ const navigationForEvent = softNavigationsById.get(event.args.data.performanceTimelineNavigationId);
17
+ if (navigationForEvent) {
18
+ eventTimeStamp = event.ts - navigationForEvent.ts;
19
+ }
20
+ }
21
+ else if (event.args?.data?.navigationId) {
15
22
  const navigationForEvent = navigationsByNavigationId.get(event.args.data.navigationId);
16
23
  if (navigationForEvent) {
17
24
  eventTimeStamp = event.ts - navigationForEvent.ts;
@@ -1 +1 @@
1
- {"version":3,"file":"Timing.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Timing.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,YAAY,CAAC;AAEtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAyB,EAAsB,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAEhH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA2B,EAAsB,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAEpH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA2B,EAAsB,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AAEvH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAyB,EAAsB,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAEhH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAyB,EAAwB,EAAE,CAC9E,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AAE9C,MAAM,UAAU,4CAA4C,CACxD,KAAyB,EACzB,WAA0C,EAC1C,yBAAoE,EACpE,oBAAiE;IAEnE,IAAI,cAAc,GAAG,KAAK,CAAC,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC;IAChD,IAAI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AG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAqC,EAAE,SAA6B;IACtG,OAAO,SAAS,IAAI,MAAM,CAAC,GAAG,IAAI,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC;AAC5D,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAA4B;IACjE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAiC,EAAE,EAAiC;IAC/F,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC;AAChD,CAAC","sourcesContent":["// Copyright 2022 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 * as Types from '../types/types.js';\n\nimport {getNavigationForTraceEvent} from './Trace.js';\n\nexport const milliToMicro = (value: Types.Timing.Milli): Types.Timing.Micro => Types.Timing.Micro(value * 1000);\n\nexport const secondsToMilli = (value: Types.Timing.Seconds): Types.Timing.Milli => Types.Timing.Milli(value * 1000);\n\nexport const secondsToMicro = (value: Types.Timing.Seconds): Types.Timing.Micro => milliToMicro(secondsToMilli(value));\n\nexport const microToMilli = (value: Types.Timing.Micro): Types.Timing.Milli => Types.Timing.Milli(value / 1000);\n\nexport const microToSeconds = (value: Types.Timing.Micro): Types.Timing.Seconds =>\n Types.Timing.Seconds(value / 1000 / 1000);\n\nexport function timeStampForEventAdjustedByClosestNavigation(\n event: Types.Events.Event,\n traceBounds: Types.Timing.TraceWindowMicro,\n navigationsByNavigationId: Map<string, Types.Events.NavigationStart>,\n navigationsByFrameId: Map<string, Types.Events.NavigationStart[]>,\n ): Types.Timing.Micro {\n let eventTimeStamp = event.ts - traceBounds.min;\n if (event.args?.data?.navigationId) {\n const navigationForEvent = navigationsByNavigationId.get(event.args.data.navigationId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n } else if (event.args?.data?.frame) {\n const navigationForEvent = getNavigationForTraceEvent(event, event.args.data.frame, navigationsByFrameId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n }\n return Types.Timing.Micro(eventTimeStamp);\n}\n\n/**\n * Expands the trace window by a provided percentage or, if it the expanded window is smaller than 1 millisecond, expands it to 1 millisecond.\n * If the expanded window is outside of the max trace window, cut the overflowing bound to the max trace window bound.\n **/\nexport function expandWindowByPercentOrToOneMillisecond(\n annotationWindow: Types.Timing.TraceWindowMicro, maxTraceWindow: Types.Timing.TraceWindowMicro,\n percentage: number): Types.Timing.TraceWindowMicro {\n // Expand min and max of the window by half of the provided percentage. That way, in total, the window will be expanded by the provided percentage.\n let newMin = annotationWindow.min - annotationWindow.range * (percentage / 100) / 2;\n let newMax = annotationWindow.max + annotationWindow.range * (percentage / 100) / 2;\n\n if (newMax - newMin < 1_000) {\n const rangeMiddle = (annotationWindow.min + annotationWindow.max) / 2;\n newMin = rangeMiddle - 500;\n newMax = rangeMiddle + 500;\n }\n\n newMin = Math.max(newMin, maxTraceWindow.min);\n newMax = Math.min(newMax, maxTraceWindow.max);\n\n const expandedWindow: Types.Timing.TraceWindowMicro = {\n min: Types.Timing.Micro(newMin),\n max: Types.Timing.Micro(newMax),\n range: Types.Timing.Micro(newMax - newMin),\n };\n\n return expandedWindow;\n}\n\nexport interface EventTimingsData<ValueType extends Types.Timing.Micro|Types.Timing.Milli|Types.Timing.Seconds, > {\n startTime: ValueType;\n endTime: ValueType;\n duration: ValueType;\n}\n\nexport function eventTimingsMicroSeconds(event: Types.Events.Event): EventTimingsData<Types.Timing.Micro> {\n return {\n startTime: event.ts,\n endTime: (event.ts + (event.dur ?? 0)) as Types.Timing.Micro,\n duration: (event.dur || 0) as Types.Timing.Micro,\n };\n}\nexport function eventTimingsMilliSeconds(event: Types.Events.Event): EventTimingsData<Types.Timing.Milli> {\n return {\n startTime: (event.ts / 1000) as Types.Timing.Milli,\n endTime: (event.ts + (event.dur ?? 0)) / 1000 as Types.Timing.Milli,\n duration: (event.dur || 0) / 1000 as Types.Timing.Milli,\n };\n}\n\nexport function traceWindowMilliSeconds(bounds: Types.Timing.TraceWindowMicro): Types.Timing.TraceWindowMilli {\n return {\n min: microToMilli(bounds.min),\n max: microToMilli(bounds.max),\n range: microToMilli(bounds.range),\n };\n}\n\nexport function traceWindowMicroSecondsToMilliSeconds(bounds: Types.Timing.TraceWindowMicro):\n Types.Timing.TraceWindowMilli {\n return {\n min: microToMilli(bounds.min),\n max: microToMilli(bounds.max),\n range: microToMilli(bounds.range),\n };\n}\n\nexport function traceWindowFromMilliSeconds(\n min: Types.Timing.Milli, max: Types.Timing.Milli): Types.Timing.TraceWindowMicro {\n const traceWindow: Types.Timing.TraceWindowMicro = {\n min: milliToMicro(min),\n max: milliToMicro(max),\n range: Types.Timing.Micro(milliToMicro(max) - milliToMicro(min)),\n };\n return traceWindow;\n}\n\nexport function traceWindowFromMicroSeconds(\n min: Types.Timing.Micro, max: Types.Timing.Micro): Types.Timing.TraceWindowMicro {\n const traceWindow: Types.Timing.TraceWindowMicro = {\n min,\n max,\n range: (max - min) as Types.Timing.Micro,\n };\n return traceWindow;\n}\n\nexport function traceWindowFromEvent(event: Types.Events.Event): Types.Timing.TraceWindowMicro {\n return {\n min: event.ts,\n max: event.ts + (event.dur ?? 0) as Types.Timing.Micro,\n range: event.dur ?? 0 as Types.Timing.Micro,\n };\n}\n\nexport function traceWindowFromOverlay(overlay: Types.Overlays.Overlay): Types.Timing.TraceWindowMicro|null {\n switch (overlay.type) {\n case 'ENTRY_LABEL':\n case 'ENTRY_OUTLINE':\n case 'ENTRY_SELECTED': {\n return traceWindowFromEvent(overlay.entry);\n }\n\n case 'TIMESPAN_BREAKDOWN': {\n const windows = overlay.sections.map(s => s.bounds);\n if (overlay.entry) {\n windows.push(traceWindowFromEvent(overlay.entry));\n }\n return combineTraceWindowsMicro(windows);\n }\n\n case 'CANDY_STRIPED_TIME_RANGE':\n case 'TIME_RANGE': {\n return structuredClone(overlay.bounds);\n }\n\n case 'ENTRIES_LINK': {\n const from = traceWindowFromEvent(overlay.entryFrom);\n if (!overlay.entryTo) {\n return from;\n }\n\n const to = traceWindowFromEvent(overlay.entryTo);\n return combineTraceWindowsMicro([from, to]);\n }\n\n case 'TIMESTAMP_MARKER':\n return traceWindowFromMicroSeconds(overlay.timestamp, overlay.timestamp);\n case 'TIMINGS_MARKER':\n return traceWindowFromMicroSeconds(overlay.adjustedTimestamp, overlay.adjustedTimestamp);\n case 'BOTTOM_INFO_BAR':\n return null;\n\n default:\n Platform.TypeScriptUtilities.assertNever(overlay, `Unexpected overlay ${overlay}`);\n }\n}\n\n/**\n * Combines (as in a union) multiple windows into one.\n */\nexport function combineTraceWindowsMicro(windows: Types.Timing.TraceWindowMicro[]): Types.Timing.TraceWindowMicro|null {\n if (!windows.length) {\n return null;\n }\n\n const result: Types.Timing.TraceWindowMicro = structuredClone(windows[0]);\n for (const bounds of windows.slice(1)) {\n result.min = Math.min(result.min, bounds.min) as Types.Timing.Micro;\n result.max = Math.max(result.max, bounds.max) as Types.Timing.Micro;\n }\n\n result.range = result.max - result.min as Types.Timing.Micro;\n\n return result;\n}\n\nexport interface BoundsIncludeTimeRange {\n timeRange: Types.Timing.TraceWindowMicro;\n bounds: Types.Timing.TraceWindowMicro;\n}\n\n/**\n * Checks to see if the timeRange is within the bounds. By \"within\" we mean\n * \"has any overlap\":\n * |------------------------|\n * == no overlap (entirely before)\n * ========= overlap\n * ========= overlap\n * ========= overlap\n * ==== no overlap (entirely after)\n * ============================== overlap (time range is larger than bounds)\n * |------------------------|\n */\nexport function boundsIncludeTimeRange(data: BoundsIncludeTimeRange): boolean {\n const {min: visibleMin, max: visibleMax} = data.bounds;\n const {min: rangeMin, max: rangeMax} = data.timeRange;\n\n return visibleMin <= rangeMax && visibleMax >= rangeMin;\n}\n\n/** Checks to see if the event is within or overlaps the bounds */\nexport function eventIsInBounds(event: Types.Events.Event, bounds: Types.Timing.TraceWindowMicro): boolean {\n const startTime = event.ts;\n return startTime <= bounds.max && bounds.min < (startTime + (event.dur ?? 0));\n}\n\nexport function timestampIsInBounds(bounds: Types.Timing.TraceWindowMicro, timestamp: Types.Timing.Micro): boolean {\n return timestamp >= bounds.min && timestamp <= bounds.max;\n}\n\nexport interface WindowFitsInsideBounds {\n window: Types.Timing.TraceWindowMicro;\n bounds: Types.Timing.TraceWindowMicro;\n}\n\n/**\n * Returns true if the window fits entirely within the bounds.\n * Note that if the window is equivalent to the bounds, that is considered to fit\n */\nexport function windowFitsInsideBounds(data: WindowFitsInsideBounds): boolean {\n return data.window.min >= data.bounds.min && data.window.max <= data.bounds.max;\n}\n\nexport function windowsEqual(w1: Types.Timing.TraceWindowMicro, w2: Types.Timing.TraceWindowMicro): boolean {\n return w1.min === w2.min && w1.max === w2.max;\n}\n"]}
1
+ {"version":3,"file":"Timing.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Timing.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,YAAY,CAAC;AAEtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAyB,EAAsB,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;AAEhH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA2B,EAAsB,EAAE,CAAC,KAAK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AC5D,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAA4B;IACjE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAiC,EAAE,EAAiC;IAC/F,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC;AAChD,CAAC","sourcesContent":["// Copyright 2022 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 * as Types from '../types/types.js';\n\nimport {getNavigationForTraceEvent} from './Trace.js';\n\nexport const milliToMicro = (value: Types.Timing.Milli): Types.Timing.Micro => Types.Timing.Micro(value * 1000);\n\nexport const secondsToMilli = (value: Types.Timing.Seconds): Types.Timing.Milli => Types.Timing.Milli(value * 1000);\n\nexport const secondsToMicro = (value: Types.Timing.Seconds): Types.Timing.Micro => milliToMicro(secondsToMilli(value));\n\nexport const microToMilli = (value: Types.Timing.Micro): Types.Timing.Milli => Types.Timing.Milli(value / 1000);\n\nexport const microToSeconds = (value: Types.Timing.Micro): Types.Timing.Seconds =>\n Types.Timing.Seconds(value / 1000 / 1000);\n\nexport function timeStampForEventAdjustedByClosestNavigation(\n event: Types.Events.Event,\n traceBounds: Types.Timing.TraceWindowMicro,\n navigationsByNavigationId: Map<string, Types.Events.NavigationStart>,\n softNavigationsById: Map<number, Types.Events.SoftNavigationStart>,\n navigationsByFrameId: Map<string, Types.Events.NavigationStart[]>,\n ): Types.Timing.Micro {\n let eventTimeStamp = event.ts - traceBounds.min;\n if (event.name === Types.Events.Name.MARK_LCP_CANDIDATE_FOR_SOFT_NAVIGATION &&\n event.args?.data?.performanceTimelineNavigationId) {\n const navigationForEvent = softNavigationsById.get(event.args.data.performanceTimelineNavigationId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n } else if (event.args?.data?.navigationId) {\n const navigationForEvent = navigationsByNavigationId.get(event.args.data.navigationId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n } else if (event.args?.data?.frame) {\n const navigationForEvent = getNavigationForTraceEvent(event, event.args.data.frame, navigationsByFrameId);\n if (navigationForEvent) {\n eventTimeStamp = event.ts - navigationForEvent.ts;\n }\n }\n return Types.Timing.Micro(eventTimeStamp);\n}\n\n/**\n * Expands the trace window by a provided percentage or, if it the expanded window is smaller than 1 millisecond, expands it to 1 millisecond.\n * If the expanded window is outside of the max trace window, cut the overflowing bound to the max trace window bound.\n **/\nexport function expandWindowByPercentOrToOneMillisecond(\n annotationWindow: Types.Timing.TraceWindowMicro, maxTraceWindow: Types.Timing.TraceWindowMicro,\n percentage: number): Types.Timing.TraceWindowMicro {\n // Expand min and max of the window by half of the provided percentage. That way, in total, the window will be expanded by the provided percentage.\n let newMin = annotationWindow.min - annotationWindow.range * (percentage / 100) / 2;\n let newMax = annotationWindow.max + annotationWindow.range * (percentage / 100) / 2;\n\n if (newMax - newMin < 1_000) {\n const rangeMiddle = (annotationWindow.min + annotationWindow.max) / 2;\n newMin = rangeMiddle - 500;\n newMax = rangeMiddle + 500;\n }\n\n newMin = Math.max(newMin, maxTraceWindow.min);\n newMax = Math.min(newMax, maxTraceWindow.max);\n\n const expandedWindow: Types.Timing.TraceWindowMicro = {\n min: Types.Timing.Micro(newMin),\n max: Types.Timing.Micro(newMax),\n range: Types.Timing.Micro(newMax - newMin),\n };\n\n return expandedWindow;\n}\n\nexport interface EventTimingsData<ValueType extends Types.Timing.Micro|Types.Timing.Milli|Types.Timing.Seconds, > {\n startTime: ValueType;\n endTime: ValueType;\n duration: ValueType;\n}\n\nexport function eventTimingsMicroSeconds(event: Types.Events.Event): EventTimingsData<Types.Timing.Micro> {\n return {\n startTime: event.ts,\n endTime: (event.ts + (event.dur ?? 0)) as Types.Timing.Micro,\n duration: (event.dur || 0) as Types.Timing.Micro,\n };\n}\nexport function eventTimingsMilliSeconds(event: Types.Events.Event): EventTimingsData<Types.Timing.Milli> {\n return {\n startTime: (event.ts / 1000) as Types.Timing.Milli,\n endTime: (event.ts + (event.dur ?? 0)) / 1000 as Types.Timing.Milli,\n duration: (event.dur || 0) / 1000 as Types.Timing.Milli,\n };\n}\n\nexport function traceWindowMilliSeconds(bounds: Types.Timing.TraceWindowMicro): Types.Timing.TraceWindowMilli {\n return {\n min: microToMilli(bounds.min),\n max: microToMilli(bounds.max),\n range: microToMilli(bounds.range),\n };\n}\n\nexport function traceWindowMicroSecondsToMilliSeconds(bounds: Types.Timing.TraceWindowMicro):\n Types.Timing.TraceWindowMilli {\n return {\n min: microToMilli(bounds.min),\n max: microToMilli(bounds.max),\n range: microToMilli(bounds.range),\n };\n}\n\nexport function traceWindowFromMilliSeconds(\n min: Types.Timing.Milli, max: Types.Timing.Milli): Types.Timing.TraceWindowMicro {\n const traceWindow: Types.Timing.TraceWindowMicro = {\n min: milliToMicro(min),\n max: milliToMicro(max),\n range: Types.Timing.Micro(milliToMicro(max) - milliToMicro(min)),\n };\n return traceWindow;\n}\n\nexport function traceWindowFromMicroSeconds(\n min: Types.Timing.Micro, max: Types.Timing.Micro): Types.Timing.TraceWindowMicro {\n const traceWindow: Types.Timing.TraceWindowMicro = {\n min,\n max,\n range: (max - min) as Types.Timing.Micro,\n };\n return traceWindow;\n}\n\nexport function traceWindowFromEvent(event: Types.Events.Event): Types.Timing.TraceWindowMicro {\n return {\n min: event.ts,\n max: event.ts + (event.dur ?? 0) as Types.Timing.Micro,\n range: event.dur ?? 0 as Types.Timing.Micro,\n };\n}\n\nexport function traceWindowFromOverlay(overlay: Types.Overlays.Overlay): Types.Timing.TraceWindowMicro|null {\n switch (overlay.type) {\n case 'ENTRY_LABEL':\n case 'ENTRY_OUTLINE':\n case 'ENTRY_SELECTED': {\n return traceWindowFromEvent(overlay.entry);\n }\n\n case 'TIMESPAN_BREAKDOWN': {\n const windows = overlay.sections.map(s => s.bounds);\n if (overlay.entry) {\n windows.push(traceWindowFromEvent(overlay.entry));\n }\n return combineTraceWindowsMicro(windows);\n }\n\n case 'CANDY_STRIPED_TIME_RANGE':\n case 'TIME_RANGE': {\n return structuredClone(overlay.bounds);\n }\n\n case 'ENTRIES_LINK': {\n const from = traceWindowFromEvent(overlay.entryFrom);\n if (!overlay.entryTo) {\n return from;\n }\n\n const to = traceWindowFromEvent(overlay.entryTo);\n return combineTraceWindowsMicro([from, to]);\n }\n\n case 'TIMESTAMP_MARKER':\n return traceWindowFromMicroSeconds(overlay.timestamp, overlay.timestamp);\n case 'TIMINGS_MARKER':\n return traceWindowFromMicroSeconds(overlay.adjustedTimestamp, overlay.adjustedTimestamp);\n case 'BOTTOM_INFO_BAR':\n return null;\n\n default:\n Platform.TypeScriptUtilities.assertNever(overlay, `Unexpected overlay ${overlay}`);\n }\n}\n\n/**\n * Combines (as in a union) multiple windows into one.\n */\nexport function combineTraceWindowsMicro(windows: Types.Timing.TraceWindowMicro[]): Types.Timing.TraceWindowMicro|null {\n if (!windows.length) {\n return null;\n }\n\n const result: Types.Timing.TraceWindowMicro = structuredClone(windows[0]);\n for (const bounds of windows.slice(1)) {\n result.min = Math.min(result.min, bounds.min) as Types.Timing.Micro;\n result.max = Math.max(result.max, bounds.max) as Types.Timing.Micro;\n }\n\n result.range = result.max - result.min as Types.Timing.Micro;\n\n return result;\n}\n\nexport interface BoundsIncludeTimeRange {\n timeRange: Types.Timing.TraceWindowMicro;\n bounds: Types.Timing.TraceWindowMicro;\n}\n\n/**\n * Checks to see if the timeRange is within the bounds. By \"within\" we mean\n * \"has any overlap\":\n * |------------------------|\n * == no overlap (entirely before)\n * ========= overlap\n * ========= overlap\n * ========= overlap\n * ==== no overlap (entirely after)\n * ============================== overlap (time range is larger than bounds)\n * |------------------------|\n */\nexport function boundsIncludeTimeRange(data: BoundsIncludeTimeRange): boolean {\n const {min: visibleMin, max: visibleMax} = data.bounds;\n const {min: rangeMin, max: rangeMax} = data.timeRange;\n\n return visibleMin <= rangeMax && visibleMax >= rangeMin;\n}\n\n/** Checks to see if the event is within or overlaps the bounds */\nexport function eventIsInBounds(event: Types.Events.Event, bounds: Types.Timing.TraceWindowMicro): boolean {\n const startTime = event.ts;\n return startTime <= bounds.max && bounds.min < (startTime + (event.dur ?? 0));\n}\n\nexport function timestampIsInBounds(bounds: Types.Timing.TraceWindowMicro, timestamp: Types.Timing.Micro): boolean {\n return timestamp >= bounds.min && timestamp <= bounds.max;\n}\n\nexport interface WindowFitsInsideBounds {\n window: Types.Timing.TraceWindowMicro;\n bounds: Types.Timing.TraceWindowMicro;\n}\n\n/**\n * Returns true if the window fits entirely within the bounds.\n * Note that if the window is equivalent to the bounds, that is considered to fit\n */\nexport function windowFitsInsideBounds(data: WindowFitsInsideBounds): boolean {\n return data.window.min >= data.bounds.min && data.window.max <= data.bounds.max;\n}\n\nexport function windowsEqual(w1: Types.Timing.TraceWindowMicro, w2: Types.Timing.TraceWindowMicro): boolean {\n return w1.min === w2.min && w1.max === w2.max;\n}\n"]}
@@ -83,6 +83,7 @@ export declare function getZeroIndexedStackTraceInEventPayload(event: Types.Even
83
83
  * Same as getZeroIndexedStackTraceInEventPayload, but only returns the top call frame.
84
84
  */
85
85
  export declare function getStackTraceTopCallFrameInEventPayload(event: Types.Events.Event): Types.Events.CallFrame | null;
86
+ export declare function rawCallFrameForEntry(entry: Types.Events.Event): Protocol.Runtime.CallFrame | null;
86
87
  /**
87
88
  * Given a 1-based call frame creates a 0-based one.
88
89
  */
@@ -58,7 +58,7 @@ export function stackTraceInEvent(event) {
58
58
  return null;
59
59
  }
60
60
  export function extractOriginFromTrace(firstNavigationURL) {
61
- const url = new URL(firstNavigationURL);
61
+ const url = URL.parse(firstNavigationURL);
62
62
  if (url) {
63
63
  // We do this to save some space in the toolbar - seeing the `www` is less
64
64
  // useful than seeing `foo.com` if it's truncated at narrow widths
@@ -501,6 +501,16 @@ export function getStackTraceTopCallFrameInEventPayload(event) {
501
501
  }
502
502
  }
503
503
  }
504
+ export function rawCallFrameForEntry(entry) {
505
+ if (Types.Events.isProfileCall(entry)) {
506
+ return entry.callFrame;
507
+ }
508
+ const topCallFrame = getStackTraceTopCallFrameInEventPayload(entry);
509
+ if (topCallFrame) {
510
+ return topCallFrame;
511
+ }
512
+ return null;
513
+ }
504
514
  /**
505
515
  * Given a 1-based call frame creates a 0-based one.
506
516
  */
@@ -521,10 +531,7 @@ export function makeZeroBasedCallFrame(callFrame) {
521
531
  **/
522
532
  function getRawLineAndColumnNumbersForEvent(event) {
523
533
  if (!event.args?.data) {
524
- return {
525
- lineNumber: undefined,
526
- columnNumber: undefined,
527
- };
534
+ return {};
528
535
  }
529
536
  let lineNumber = undefined;
530
537
  let columnNumber = undefined;