@paulirish/trace_engine 0.0.65 → 0.0.66

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 (432) hide show
  1. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  2. package/core/platform/ArrayUtilities.d.ts +5 -0
  3. package/core/platform/ArrayUtilities.js +14 -0
  4. package/core/platform/ArrayUtilities.js.map +1 -1
  5. package/core/platform/HostRuntime.d.ts +1 -0
  6. package/core/platform/HostRuntime.js +1 -1
  7. package/core/platform/HostRuntime.js.map +1 -1
  8. package/core/platform/KeyboardUtilities.js +12 -0
  9. package/core/platform/KeyboardUtilities.js.map +1 -1
  10. package/core/platform/MimeType.js +13 -0
  11. package/core/platform/MimeType.js.map +1 -1
  12. package/core/platform/Size.d.ts +12 -0
  13. package/core/platform/Size.js +36 -0
  14. package/core/platform/Size.js.map +1 -0
  15. package/core/platform/StringUtilities.d.ts +49 -0
  16. package/core/platform/StringUtilities.js +141 -4
  17. package/core/platform/StringUtilities.js.map +1 -1
  18. package/core/platform/TypescriptUtilities.d.ts +0 -6
  19. package/core/platform/TypescriptUtilities.js +0 -8
  20. package/core/platform/TypescriptUtilities.js.map +1 -1
  21. package/core/platform/api/HostRuntime.d.ts +25 -0
  22. package/core/platform/api/HostRuntime.js.map +1 -1
  23. package/core/platform/api/api-tsconfig.json +26 -11
  24. package/core/platform/api/api-tsconfig.ref.json +26 -0
  25. package/core/platform/browser/HostRuntime.js +90 -0
  26. package/core/platform/browser/HostRuntime.js.map +1 -1
  27. package/core/platform/browser/browser-tsconfig.json +22 -11
  28. package/core/platform/browser/browser-tsconfig.ref.json +27 -0
  29. package/core/platform/browser/bundle-tsconfig.json +59 -1
  30. package/core/platform/browser/bundle-tsconfig.ref.json +27 -0
  31. package/core/platform/bundle-tsconfig.json +59 -1
  32. package/core/platform/bundle-tsconfig.ref.json +27 -0
  33. package/core/platform/foundation_unittests-tsconfig.json +73 -0
  34. package/core/platform/foundation_unittests-tsconfig.ref.json +40 -0
  35. package/core/platform/foundation_unittests_node_typecheck-tsconfig.json +70 -0
  36. package/core/platform/node/HostRuntime.js +47 -2
  37. package/core/platform/node/HostRuntime.js.map +1 -1
  38. package/core/platform/node/bundle-tsconfig.json +59 -1
  39. package/core/platform/node/bundle-tsconfig.ref.json +27 -0
  40. package/core/platform/node/node-tsconfig.json +16 -9
  41. package/core/platform/node/node-tsconfig.ref.json +27 -0
  42. package/core/platform/platform-tsconfig.json +25 -13
  43. package/core/platform/platform-tsconfig.ref.json +49 -0
  44. package/core/platform/platform.d.ts +2 -1
  45. package/core/platform/platform.js +2 -1
  46. package/core/platform/platform.js.map +1 -1
  47. package/core/platform/platform_node_typecheck-tsconfig.json +18 -14
  48. package/core/platform/platform_node_typecheck.stamp +0 -0
  49. package/generated/protocol.d.ts +782 -685
  50. package/generated/protocol.js +3300 -1
  51. package/locales/af.json +154 -133
  52. package/locales/am.json +156 -135
  53. package/locales/ar.json +157 -136
  54. package/locales/as.json +156 -135
  55. package/locales/az.json +156 -135
  56. package/locales/be.json +153 -132
  57. package/locales/bg.json +154 -133
  58. package/locales/bn.json +156 -135
  59. package/locales/bs.json +152 -131
  60. package/locales/ca.json +157 -136
  61. package/locales/cs.json +148 -127
  62. package/locales/cy.json +155 -134
  63. package/locales/da.json +153 -132
  64. package/locales/de.json +152 -131
  65. package/locales/el.json +153 -132
  66. package/locales/en-GB.json +160 -139
  67. package/locales/en-US.json +153 -141
  68. package/locales/en-XL.json +153 -141
  69. package/locales/es-419.json +150 -129
  70. package/locales/es.json +149 -128
  71. package/locales/et.json +124 -103
  72. package/locales/eu.json +151 -130
  73. package/locales/fa.json +155 -134
  74. package/locales/fi.json +151 -130
  75. package/locales/fil.json +154 -133
  76. package/locales/fr-CA.json +154 -133
  77. package/locales/fr.json +150 -129
  78. package/locales/gl.json +153 -132
  79. package/locales/gu.json +156 -135
  80. package/locales/he.json +160 -139
  81. package/locales/hi.json +156 -135
  82. package/locales/hr.json +154 -133
  83. package/locales/hu.json +111 -90
  84. package/locales/hy.json +147 -126
  85. package/locales/id.json +153 -132
  86. package/locales/is.json +149 -128
  87. package/locales/it.json +153 -132
  88. package/locales/ja.json +150 -129
  89. package/locales/ka.json +159 -138
  90. package/locales/kk.json +62 -41
  91. package/locales/km.json +157 -136
  92. package/locales/kn.json +159 -138
  93. package/locales/ko.json +42 -21
  94. package/locales/ky.json +155 -134
  95. package/locales/lo.json +154 -133
  96. package/locales/lt.json +152 -131
  97. package/locales/lv.json +93 -72
  98. package/locales/mk.json +154 -133
  99. package/locales/ml.json +153 -132
  100. package/locales/mn.json +150 -129
  101. package/locales/mr.json +152 -131
  102. package/locales/ms.json +153 -132
  103. package/locales/my.json +156 -135
  104. package/locales/ne.json +152 -131
  105. package/locales/nl.json +149 -128
  106. package/locales/no.json +152 -131
  107. package/locales/or.json +152 -131
  108. package/locales/pa.json +154 -133
  109. package/locales/pl.json +153 -132
  110. package/locales/pt-PT.json +152 -131
  111. package/locales/pt.json +157 -136
  112. package/locales/ro.json +149 -128
  113. package/locales/ru.json +73 -52
  114. package/locales/si.json +156 -135
  115. package/locales/sk.json +153 -132
  116. package/locales/sl.json +149 -128
  117. package/locales/sq.json +150 -129
  118. package/locales/sr-Latn.json +151 -130
  119. package/locales/sr.json +151 -130
  120. package/locales/sv.json +152 -131
  121. package/locales/sw.json +160 -139
  122. package/locales/ta.json +156 -135
  123. package/locales/te.json +157 -136
  124. package/locales/th.json +111 -90
  125. package/locales/tr.json +153 -132
  126. package/locales/uk.json +149 -128
  127. package/locales/ur.json +151 -130
  128. package/locales/uz.json +151 -130
  129. package/locales/vi.json +162 -141
  130. package/locales/zh-HK.json +150 -129
  131. package/locales/zh-TW.json +154 -133
  132. package/locales/zh.json +152 -131
  133. package/locales/zu.json +159 -138
  134. package/models/cpu_profile/bundle-tsconfig.json +59 -1
  135. package/models/cpu_profile/bundle-tsconfig.ref.json +27 -0
  136. package/models/cpu_profile/cpu_profile-tsconfig.json +24 -13
  137. package/models/cpu_profile/cpu_profile-tsconfig.ref.json +31 -0
  138. package/models/cpu_profile/cpu_profile_node_typecheck-tsconfig.json +60 -0
  139. package/models/cpu_profile/cpu_profile_node_typecheck.stamp +0 -0
  140. package/models/{trace/devtools_entrypoint-bundle-typescript-tsconfig.json → cpu_profile/foundation_unittests-tsconfig.json} +27 -30
  141. package/models/cpu_profile/foundation_unittests-tsconfig.ref.json +30 -0
  142. package/models/cpu_profile/foundation_unittests_node_typecheck-tsconfig.json +60 -0
  143. package/models/trace/EntityMapper.js +1 -1
  144. package/models/trace/EntityMapper.js.map +1 -1
  145. package/models/trace/LanternComputationData.js +7 -0
  146. package/models/trace/LanternComputationData.js.map +1 -1
  147. package/models/trace/ModelImpl.d.ts +1 -5
  148. package/models/trace/ModelImpl.js +11 -0
  149. package/models/trace/ModelImpl.js.map +1 -1
  150. package/models/trace/Name.js +5 -5
  151. package/models/trace/Name.js.map +1 -1
  152. package/models/trace/Processor.d.ts +2 -6
  153. package/models/trace/Processor.js +77 -15
  154. package/models/trace/Processor.js.map +1 -1
  155. package/models/trace/Styles.js +128 -116
  156. package/models/trace/Styles.js.map +1 -1
  157. package/models/trace/bundle-tsconfig.json +77 -1
  158. package/models/trace/bundle-tsconfig.ref.json +45 -0
  159. package/models/trace/extras/StackTraceForEvent.d.ts +1 -1
  160. package/models/trace/extras/StackTraceForEvent.js.map +1 -1
  161. package/models/trace/extras/ThirdParties.js +7 -7
  162. package/models/trace/extras/ThirdParties.js.map +1 -1
  163. package/models/trace/extras/TraceTree.js +2 -2
  164. package/models/trace/extras/TraceTree.js.map +1 -1
  165. package/models/trace/extras/bundle-tsconfig.json +59 -1
  166. package/models/trace/extras/bundle-tsconfig.ref.json +27 -0
  167. package/models/trace/extras/extras-tsconfig.json +28 -17
  168. package/models/trace/extras/extras-tsconfig.ref.json +49 -0
  169. package/models/trace/extras/extras_node_typecheck-tsconfig.json +78 -0
  170. package/models/trace/extras/extras_node_typecheck.stamp +0 -0
  171. package/models/trace/extras/foundation_unittests-tsconfig.json +91 -0
  172. package/models/trace/extras/foundation_unittests-tsconfig.ref.json +58 -0
  173. package/models/trace/extras/foundation_unittests_node_typecheck-tsconfig.json +88 -0
  174. package/models/trace/foundation_unittests-tsconfig.json +70 -0
  175. package/models/trace/foundation_unittests-tsconfig.ref.json +37 -0
  176. package/models/trace/foundation_unittests_node_typecheck-tsconfig.json +67 -0
  177. package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -1
  178. package/models/trace/handlers/ExtensionTraceDataHandler.js +1 -1
  179. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
  180. package/models/trace/handlers/FlowsHandler.js.map +1 -1
  181. package/models/trace/handlers/FramesHandler.d.ts +1 -2
  182. package/models/trace/handlers/FramesHandler.js +4 -5
  183. package/models/trace/handlers/FramesHandler.js.map +1 -1
  184. package/models/trace/handlers/LayerTreeHandler.js +3 -3
  185. package/models/trace/handlers/LayerTreeHandler.js.map +1 -1
  186. package/models/trace/handlers/LayoutShiftsHandler.d.ts +2 -2
  187. package/models/trace/handlers/LayoutShiftsHandler.js +17 -18
  188. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  189. package/models/trace/handlers/MetaHandler.d.ts +2 -3
  190. package/models/trace/handlers/MetaHandler.js +38 -7
  191. package/models/trace/handlers/MetaHandler.js.map +1 -1
  192. package/models/trace/handlers/ModelHandlers.d.ts +0 -1
  193. package/models/trace/handlers/ModelHandlers.js +0 -1
  194. package/models/trace/handlers/ModelHandlers.js.map +1 -1
  195. package/models/trace/handlers/NetworkRequestsHandler.js +13 -11
  196. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  197. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +2 -0
  198. package/models/trace/handlers/PageLoadMetricsHandler.js +43 -4
  199. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
  200. package/models/trace/handlers/RendererHandler.js +19 -20
  201. package/models/trace/handlers/RendererHandler.js.map +1 -1
  202. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  203. package/models/trace/handlers/ScreenshotsHandler.js +1 -43
  204. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -1
  205. package/models/trace/handlers/Threads.d.ts +1 -3
  206. package/models/trace/handlers/Threads.js +4 -8
  207. package/models/trace/handlers/Threads.js.map +1 -1
  208. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -1
  209. package/models/trace/handlers/UserTimingsHandler.d.ts +1 -1
  210. package/models/trace/handlers/UserTimingsHandler.js +16 -6
  211. package/models/trace/handlers/UserTimingsHandler.js.map +1 -1
  212. package/models/trace/handlers/WarningsHandler.js.map +1 -1
  213. package/models/trace/handlers/bundle-tsconfig.json +59 -1
  214. package/models/trace/handlers/bundle-tsconfig.ref.json +27 -0
  215. package/models/trace/handlers/foundation_unittests-tsconfig.json +102 -0
  216. package/models/trace/handlers/foundation_unittests-tsconfig.ref.json +69 -0
  217. package/models/trace/handlers/foundation_unittests_node_typecheck-tsconfig.json +99 -0
  218. package/models/trace/handlers/handlers-tsconfig.json +30 -20
  219. package/models/trace/handlers/handlers-tsconfig.ref.json +80 -0
  220. package/models/trace/handlers/handlers_node_typecheck-tsconfig.json +109 -0
  221. package/models/trace/handlers/handlers_node_typecheck.stamp +0 -0
  222. package/models/trace/helpers/Network.d.ts +3 -1
  223. package/models/trace/helpers/Network.js.map +1 -1
  224. package/models/trace/helpers/SamplesIntegrator.js +22 -6
  225. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  226. package/models/trace/helpers/SyntheticEvents.d.ts +7 -0
  227. package/models/trace/helpers/SyntheticEvents.js +20 -1
  228. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  229. package/models/trace/helpers/Timing.js +14 -1
  230. package/models/trace/helpers/Timing.js.map +1 -1
  231. package/models/trace/helpers/Trace.js.map +1 -1
  232. package/models/trace/helpers/bundle-tsconfig.json +59 -1
  233. package/models/trace/helpers/bundle-tsconfig.ref.json +27 -0
  234. package/models/trace/helpers/foundation_unittests-tsconfig.json +73 -0
  235. package/models/trace/helpers/foundation_unittests-tsconfig.ref.json +40 -0
  236. package/models/trace/helpers/foundation_unittests_node_typecheck-tsconfig.json +70 -0
  237. package/models/trace/helpers/helpers-tsconfig.json +27 -19
  238. package/models/trace/helpers/helpers-tsconfig.ref.json +45 -0
  239. package/models/trace/helpers/helpers_node_typecheck-tsconfig.json +74 -0
  240. package/models/trace/helpers/helpers_node_typecheck.stamp +0 -0
  241. package/models/trace/insights/CLSCulprits.d.ts +18 -15
  242. package/models/trace/insights/CLSCulprits.js +7 -6
  243. package/models/trace/insights/CLSCulprits.js.map +1 -1
  244. package/models/trace/insights/Cache.d.ts +8 -7
  245. package/models/trace/insights/Cache.js.map +1 -1
  246. package/models/trace/insights/CharacterSet.d.ts +10 -9
  247. package/models/trace/insights/CharacterSet.js +4 -4
  248. package/models/trace/insights/CharacterSet.js.map +1 -1
  249. package/models/trace/insights/Common.js +21 -3
  250. package/models/trace/insights/Common.js.map +1 -1
  251. package/models/trace/insights/DOMSize.d.ts +15 -14
  252. package/models/trace/insights/DOMSize.js +2 -2
  253. package/models/trace/insights/DOMSize.js.map +1 -1
  254. package/models/trace/insights/DocumentLatency.d.ts +13 -12
  255. package/models/trace/insights/DocumentLatency.js +4 -4
  256. package/models/trace/insights/DocumentLatency.js.map +1 -1
  257. package/models/trace/insights/DuplicatedJavaScript.d.ts +13 -8
  258. package/models/trace/insights/DuplicatedJavaScript.js +7 -3
  259. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
  260. package/models/trace/insights/FontDisplay.d.ts +16 -10
  261. package/models/trace/insights/FontDisplay.js +9 -3
  262. package/models/trace/insights/FontDisplay.js.map +1 -1
  263. package/models/trace/insights/ForcedReflow.d.ts +13 -13
  264. package/models/trace/insights/ForcedReflow.js +4 -4
  265. package/models/trace/insights/ForcedReflow.js.map +1 -1
  266. package/models/trace/insights/INPBreakdown.d.ts +12 -12
  267. package/models/trace/insights/INPBreakdown.js +1 -1
  268. package/models/trace/insights/INPBreakdown.js.map +1 -1
  269. package/models/trace/insights/ImageDelivery.d.ts +13 -12
  270. package/models/trace/insights/ImageDelivery.js +5 -5
  271. package/models/trace/insights/ImageDelivery.js.map +1 -1
  272. package/models/trace/insights/LCPBreakdown.d.ts +13 -12
  273. package/models/trace/insights/LCPBreakdown.js +3 -3
  274. package/models/trace/insights/LCPBreakdown.js.map +1 -1
  275. package/models/trace/insights/LCPDiscovery.d.ts +14 -13
  276. package/models/trace/insights/LCPDiscovery.js +7 -7
  277. package/models/trace/insights/LCPDiscovery.js.map +1 -1
  278. package/models/trace/insights/LegacyJavaScript.d.ts +13 -8
  279. package/models/trace/insights/LegacyJavaScript.js +7 -3
  280. package/models/trace/insights/LegacyJavaScript.js.map +1 -1
  281. package/models/trace/insights/ModernHTTP.d.ts +10 -10
  282. package/models/trace/insights/ModernHTTP.js +9 -5
  283. package/models/trace/insights/ModernHTTP.js.map +1 -1
  284. package/models/trace/insights/NetworkDependencyTree.d.ts +33 -28
  285. package/models/trace/insights/NetworkDependencyTree.js +17 -13
  286. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  287. package/models/trace/insights/RenderBlocking.d.ts +8 -7
  288. package/models/trace/insights/RenderBlocking.js +3 -5
  289. package/models/trace/insights/RenderBlocking.js.map +1 -1
  290. package/models/trace/insights/SlowCSSSelector.d.ts +17 -16
  291. package/models/trace/insights/SlowCSSSelector.js +23 -20
  292. package/models/trace/insights/SlowCSSSelector.js.map +1 -1
  293. package/models/trace/insights/ThirdParties.d.ts +22 -13
  294. package/models/trace/insights/ThirdParties.js +19 -8
  295. package/models/trace/insights/ThirdParties.js.map +1 -1
  296. package/models/trace/insights/Viewport.d.ts +8 -6
  297. package/models/trace/insights/Viewport.js +4 -2
  298. package/models/trace/insights/Viewport.js.map +1 -1
  299. package/models/trace/insights/bundle-tsconfig.json +59 -1
  300. package/models/trace/insights/bundle-tsconfig.ref.json +27 -0
  301. package/models/trace/insights/foundation_unittests-tsconfig.json +98 -0
  302. package/models/trace/insights/foundation_unittests-tsconfig.ref.json +65 -0
  303. package/models/trace/insights/foundation_unittests_node_typecheck-tsconfig.json +95 -0
  304. package/models/trace/insights/insights-tsconfig.json +34 -23
  305. package/models/trace/insights/insights-tsconfig.ref.json +82 -0
  306. package/models/trace/insights/insights_node_typecheck-tsconfig.json +111 -0
  307. package/models/trace/insights/insights_node_typecheck.stamp +0 -0
  308. package/models/trace/insights/types.d.ts +9 -6
  309. package/models/trace/insights/types.js.map +1 -1
  310. package/models/trace/lantern/bundle-tsconfig.json +71 -1
  311. package/models/trace/lantern/bundle-tsconfig.ref.json +39 -0
  312. package/models/trace/lantern/core/NetworkAnalyzer.d.ts +1 -0
  313. package/models/trace/lantern/core/NetworkAnalyzer.js +6 -2
  314. package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -1
  315. package/models/trace/lantern/core/bundle-tsconfig.json +59 -1
  316. package/models/trace/lantern/core/bundle-tsconfig.ref.json +27 -0
  317. package/models/trace/lantern/core/core-tsconfig.json +23 -12
  318. package/models/trace/lantern/core/core-tsconfig.ref.json +28 -0
  319. package/models/trace/lantern/core/core_node_typecheck-tsconfig.json +57 -0
  320. package/models/trace/lantern/core/core_node_typecheck.stamp +0 -0
  321. package/models/trace/lantern/core/{devtools_entrypoint-bundle-typescript-tsconfig.json → foundation_unittests-tsconfig.json} +34 -13
  322. package/models/trace/lantern/core/foundation_unittests-tsconfig.ref.json +36 -0
  323. package/models/trace/lantern/core/foundation_unittests_node_typecheck-tsconfig.json +66 -0
  324. package/models/trace/lantern/graph/BaseNode.d.ts +2 -2
  325. package/models/trace/lantern/graph/BaseNode.js.map +1 -1
  326. package/models/trace/lantern/graph/CPUNode.d.ts +4 -2
  327. package/models/trace/lantern/graph/CPUNode.js +23 -7
  328. package/models/trace/lantern/graph/CPUNode.js.map +1 -1
  329. package/models/trace/lantern/graph/NetworkNode.js +12 -0
  330. package/models/trace/lantern/graph/NetworkNode.js.map +1 -1
  331. package/models/trace/lantern/graph/PageDependencyGraph.js +26 -4
  332. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
  333. package/models/trace/lantern/graph/bundle-tsconfig.json +59 -1
  334. package/models/trace/lantern/graph/bundle-tsconfig.ref.json +27 -0
  335. package/models/trace/lantern/graph/{devtools_entrypoint-bundle-typescript-tsconfig.json → foundation_unittests-tsconfig.json} +26 -13
  336. package/models/trace/lantern/graph/foundation_unittests-tsconfig.ref.json +28 -0
  337. package/models/trace/lantern/graph/foundation_unittests_node_typecheck-tsconfig.json +58 -0
  338. package/models/trace/lantern/graph/graph-tsconfig.json +24 -13
  339. package/models/trace/lantern/graph/graph-tsconfig.ref.json +33 -0
  340. package/models/trace/lantern/graph/graph_node_typecheck-tsconfig.json +62 -0
  341. package/models/trace/lantern/graph/graph_node_typecheck.stamp +0 -0
  342. package/models/trace/lantern/metrics/TotalBlockingTime.js +1 -1
  343. package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -1
  344. package/models/trace/lantern/metrics/bundle-tsconfig.json +59 -1
  345. package/models/trace/lantern/metrics/bundle-tsconfig.ref.json +27 -0
  346. package/models/trace/lantern/metrics/foundation_unittests-tsconfig.json +76 -0
  347. package/models/trace/lantern/metrics/foundation_unittests-tsconfig.ref.json +43 -0
  348. package/models/trace/lantern/metrics/foundation_unittests_node_typecheck-tsconfig.json +73 -0
  349. package/models/trace/lantern/metrics/metrics-tsconfig.json +26 -15
  350. package/models/trace/lantern/metrics/metrics-tsconfig.ref.json +43 -0
  351. package/models/trace/lantern/metrics/metrics_node_typecheck-tsconfig.json +72 -0
  352. package/models/trace/lantern/metrics/metrics_node_typecheck.stamp +0 -0
  353. package/models/trace/lantern/simulation/ConnectionPool.js +4 -4
  354. package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -1
  355. package/models/trace/lantern/simulation/Constants.d.ts +29 -28
  356. package/models/trace/lantern/simulation/Constants.js +3 -1
  357. package/models/trace/lantern/simulation/Constants.js.map +1 -1
  358. package/models/trace/lantern/simulation/DNSCache.js.map +1 -1
  359. package/models/trace/lantern/simulation/Simulator.js +6 -2
  360. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  361. package/models/trace/lantern/simulation/TCPConnection.d.ts +4 -4
  362. package/models/trace/lantern/simulation/TCPConnection.js +12 -12
  363. package/models/trace/lantern/simulation/TCPConnection.js.map +1 -1
  364. package/models/trace/lantern/simulation/bundle-tsconfig.json +59 -1
  365. package/models/trace/lantern/simulation/bundle-tsconfig.ref.json +27 -0
  366. package/models/trace/lantern/simulation/foundation_unittests-tsconfig.json +75 -0
  367. package/models/trace/lantern/simulation/foundation_unittests-tsconfig.ref.json +42 -0
  368. package/models/trace/lantern/simulation/foundation_unittests_node_typecheck-tsconfig.json +72 -0
  369. package/models/trace/lantern/simulation/simulation-tsconfig.json +25 -14
  370. package/models/trace/lantern/simulation/simulation-tsconfig.ref.json +38 -0
  371. package/models/trace/lantern/simulation/simulation_node_typecheck-tsconfig.json +67 -0
  372. package/models/trace/lantern/simulation/simulation_node_typecheck.stamp +0 -0
  373. package/models/trace/lantern/{metrics/devtools_entrypoint-bundle-typescript-tsconfig.json → testing/bundle-tsconfig.json} +25 -13
  374. package/models/trace/lantern/testing/bundle-tsconfig.ref.json +27 -0
  375. package/models/trace/lantern/{simulation/devtools_entrypoint-bundle-typescript-tsconfig.json → testing/testing-tsconfig.json} +28 -13
  376. package/models/trace/lantern/testing/testing-tsconfig.ref.json +30 -0
  377. package/models/trace/lantern/types/Lantern.d.ts +27 -19
  378. package/models/trace/lantern/types/Lantern.js.map +1 -1
  379. package/models/trace/lantern/types/bundle-tsconfig.json +59 -1
  380. package/models/trace/lantern/types/bundle-tsconfig.ref.json +27 -0
  381. package/models/trace/lantern/types/types-tsconfig.json +23 -12
  382. package/models/trace/lantern/types/types-tsconfig.ref.json +27 -0
  383. package/models/trace/lantern/types/{devtools_entrypoint-bundle-typescript-tsconfig.json → types_node_typecheck-tsconfig.json} +25 -17
  384. package/models/trace/lantern/types/types_node_typecheck.stamp +0 -0
  385. package/models/trace/trace-tsconfig.json +31 -20
  386. package/models/trace/trace-tsconfig.ref.json +57 -0
  387. package/models/trace/trace_node_typecheck-tsconfig.json +86 -0
  388. package/models/trace/trace_node_typecheck.stamp +0 -0
  389. package/models/trace/types/Configuration.d.ts +11 -0
  390. package/models/trace/types/Configuration.js +1 -0
  391. package/models/trace/types/Configuration.js.map +1 -1
  392. package/models/trace/types/Extensions.d.ts +1 -1
  393. package/models/trace/types/File.d.ts +1 -0
  394. package/models/trace/types/File.js.map +1 -1
  395. package/models/trace/types/Overlays.d.ts +13 -3
  396. package/models/trace/types/Overlays.js.map +1 -1
  397. package/models/trace/types/TraceEvents.d.ts +39 -9
  398. package/models/trace/types/TraceEvents.js +103 -3
  399. package/models/trace/types/TraceEvents.js.map +1 -1
  400. package/models/trace/types/bundle-tsconfig.json +59 -1
  401. package/models/trace/types/bundle-tsconfig.ref.json +27 -0
  402. package/{core/platform/api/api_node_typecheck-tsconfig.json → models/trace/types/foundation_unittests-tsconfig.json} +32 -13
  403. package/models/trace/types/foundation_unittests-tsconfig.ref.json +34 -0
  404. package/models/trace/types/foundation_unittests_node_typecheck-tsconfig.json +64 -0
  405. package/models/trace/types/types-tsconfig.json +27 -16
  406. package/models/trace/types/types-tsconfig.ref.json +44 -0
  407. package/models/trace/types/types_node_typecheck-tsconfig.json +73 -0
  408. package/models/trace/types/types_node_typecheck.stamp +0 -0
  409. package/package.json +2 -3
  410. package/test/test-trace-engine.mjs +1 -1
  411. package/{models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json → third_party/legacy-javascript/bundle-tsconfig.json} +24 -13
  412. package/third_party/legacy-javascript/bundle-tsconfig.ref.json +27 -0
  413. package/third_party/legacy-javascript/legacy-javascript-tsconfig.ref.json +15 -0
  414. package/third_party/legacy-javascript/legacy-javascript.d.ts +2 -1
  415. package/third_party/legacy-javascript/legacy-javascript.js +3 -1
  416. package/third_party/legacy-javascript/legacy-javascript.js.map +1 -0
  417. package/third_party/legacy-javascript/lib/legacy-javascript.d.ts +18 -0
  418. package/third_party/legacy-javascript/lib/legacy-javascript.js +1119 -0
  419. package/core/platform/api/bundle-tsconfig.json +0 -1
  420. package/core/platform/api/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  421. package/core/platform/browser/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  422. package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  423. package/core/platform/node/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  424. package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  425. package/models/trace/handlers/AuctionWorkletsHandler.d.ts +0 -8
  426. package/models/trace/handlers/AuctionWorkletsHandler.js +0 -163
  427. package/models/trace/handlers/AuctionWorkletsHandler.js.map +0 -1
  428. package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  429. package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  430. package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  431. package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -60
  432. package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
@@ -4,7 +4,6 @@
4
4
  import * as Platform from '../../../core/platform/platform.js';
5
5
  import * as Helpers from '../helpers/helpers.js';
6
6
  import * as Types from '../types/types.js';
7
- import { data as auctionWorkletsData } from './AuctionWorkletsHandler.js';
8
7
  import * as HandlerHelpers from './helpers.js';
9
8
  import { data as metaHandlerData } from './MetaHandler.js';
10
9
  import { data as networkRequestHandlerData } from './NetworkRequestsHandler.js';
@@ -208,7 +207,6 @@ export function assignThreadName(processes, threadsInProcess) {
208
207
  * - Deletes processes with an unknown origin.
209
208
  */
210
209
  export function sanitizeProcesses(processes) {
211
- const auctionWorklets = auctionWorkletsData().worklets;
212
210
  const metaData = metaHandlerData();
213
211
  if (metaData.traceIsGeneric) {
214
212
  return;
@@ -218,20 +216,8 @@ export function sanitizeProcesses(processes) {
218
216
  // parsed for some reason, or if it's an "about:" origin, delete it.
219
217
  // This is done because we don't really care about processes for which we
220
218
  // can't provide actionable insights to the user (e.g. about:blank pages).
221
- //
222
- // There is one exception; AuctionWorklet processes get parsed in a
223
- // separate handler, so at this point we check to see if the process has
224
- // been found by the AuctionWorkletsHandler, and if so we update the URL.
225
- // This ensures that we keep this process around and do not drop it due to
226
- // the lack of a URL.
227
219
  if (process.url === null) {
228
- const maybeWorklet = auctionWorklets.get(pid);
229
- if (maybeWorklet) {
230
- process.url = maybeWorklet.host;
231
- }
232
- else {
233
- processes.delete(pid);
234
- }
220
+ processes.delete(pid);
235
221
  continue;
236
222
  }
237
223
  }
@@ -275,13 +261,22 @@ export function sanitizeThreads(processes) {
275
261
  * |- Task C -|
276
262
  */
277
263
  export function buildHierarchy(processes, options) {
264
+ // Ensure threads that only contain V8 CPU profiler samples (such as WebAssembly
265
+ // background execution threads) are registered in their process before we iterate.
266
+ // These threads do not receive standard renderer trace events, so their RendererThread
267
+ // objects must be initialized here so SamplesIntegrator can inject profile calls.
278
268
  const samplesData = samplesHandlerData();
269
+ for (const [pid, profilesByThread] of samplesData.profilesInProcess) {
270
+ const process = processes.get(pid);
271
+ if (!process) {
272
+ continue;
273
+ }
274
+ for (const [tid] of profilesByThread) {
275
+ getOrCreateRendererThread(process, tid);
276
+ }
277
+ }
279
278
  for (const [pid, process] of processes) {
280
279
  for (const [tid, thread] of process.threads) {
281
- if (!thread.entries.length) {
282
- thread.tree = Helpers.TreeHelpers.makeEmptyTraceEntryTree();
283
- continue;
284
- }
285
280
  // Step 1. Massage the data.
286
281
  Helpers.Trace.sortTraceEventsInPlace(thread.entries);
287
282
  // Step 2. Inject profile calls from samples
@@ -301,6 +296,10 @@ export function buildHierarchy(processes, options) {
301
296
  }
302
297
  }
303
298
  }
299
+ if (!thread.entries.length) {
300
+ thread.tree = Helpers.TreeHelpers.makeEmptyTraceEntryTree();
301
+ continue;
302
+ }
304
303
  // Step 3. Build the tree.
305
304
  const treeData = Helpers.TreeHelpers.treify(thread.entries, options);
306
305
  thread.tree = treeData.tree;
@@ -342,6 +341,6 @@ export function makeCompleteEvent(event) {
342
341
  return syntheticComplete;
343
342
  }
344
343
  export function deps() {
345
- return ['Meta', 'Samples', 'AuctionWorklets', 'NetworkRequests'];
344
+ return ['Meta', 'Samples', 'NetworkRequests'];
346
345
  }
347
346
  //# sourceMappingURL=RendererHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RendererHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/RendererHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,cAAc,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAwB,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAC,IAAI,IAAI,yBAAyB,EAAC,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAC,IAAI,IAAI,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAG/D;;;;;;;;;;GAUG;AAEH,IAAI,SAAS,GAAG,IAAI,GAAG,EAA2C,CAAC;AAEnE,IAAI,cAAc,GAAkC;IAClD,cAAc,EAAE,IAAI,GAAG,EAA+C;IACtE,aAAa,EAAE,IAAI,GAAG,EAA6C;IACnE,kBAAkB,EAAE,IAAI,GAAG,EAAiC;IAC5D,gBAAgB,EAAE,IAAI,GAAG,EAAiC;CAC3D,CAAC;AAEF,+EAA+E;AAC/E,8EAA8E;AAC9E,yEAAyE;AACzE,IAAI,qBAAqB,G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,GAAG,IAAI,GAAG,UAAU,CAAC,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC,EAAE,GAAG,IAAI;gBACrG,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,mEAAmE;QACnE,SAAS;QACT,UAAU,CAAC,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mEAAmE;IACnE,wDAAwD;IACxD,MAAM,iBAAiB,GAAmC;QACxD,GAAG,KAAK;QACR,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC/B,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KAC3B,CAAC;IAEF,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC3C,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;AACnE,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 Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {data as auctionWorkletsData} from './AuctionWorkletsHandler.js';\nimport * as HandlerHelpers from './helpers.js';\nimport {data as metaHandlerData, type FrameProcessData} from './MetaHandler.js';\nimport {data as networkRequestHandlerData} from './NetworkRequestsHandler.js';\nimport {data as samplesHandlerData} from './SamplesHandler.js';\nimport type {HandlerName} from './types.js';\n\n/**\n * This handler builds the hierarchy of trace events and profile calls\n * on each thread on each process.\n *\n * Throughout the code, trace events and profile calls are referred to\n * as \"entries\", but note they are different types of data. Trace events\n * come directly from the backend and it's the type the engine commonly\n * refers to. Profile calls on the other hand are built in the frontend,\n * and, for compatibility purposes, typed as an extension to the trace\n * event type.\n */\n\nlet processes = new Map<Types.Events.ProcessID, RendererProcess>();\n\nlet entityMappings: HandlerHelpers.EntityMappings = {\n eventsByEntity: new Map<HandlerHelpers.Entity, Types.Events.Event[]>(),\n entityByEvent: new Map<Types.Events.Event, HandlerHelpers.Entity>(),\n createdEntityCache: new Map<string, HandlerHelpers.Entity>(),\n entityByUrlCache: new Map<string, HandlerHelpers.Entity>(),\n};\n\n// We track the compositor tile worker thread name events so that at the end we\n// can return these keyed by the process ID. These are used in the frontend to\n// show the user the rasterization thread(s) on the main frame as tracks.\nlet compositorTileWorkers = Array<{\n pid: Types.Events.ProcessID,\n tid: Types.Events.ThreadID,\n}>();\nlet entryToNode = new Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>();\n\nlet completeEventStack: (Types.Events.SyntheticComplete)[] = [];\n\nlet config: Types.Configuration.Configuration = Types.Configuration.defaults();\n\nconst makeRendererProcess = (): RendererProcess => ({\n url: null,\n isOnMainFrame: false,\n threads: new Map(),\n});\n\nconst makeRendererThread = (): RendererThread => ({\n name: null,\n entries: [],\n profileCalls: [],\n layoutEvents: [],\n recalcStyleEvents: [],\n});\n\nconst getOrCreateRendererProcess =\n (processes: Map<Types.Events.ProcessID, RendererProcess>, pid: Types.Events.ProcessID): RendererProcess => {\n return Platform.MapUtilities.getWithDefault(processes, pid, makeRendererProcess);\n };\n\nconst getOrCreateRendererThread = (process: RendererProcess, tid: Types.Events.ThreadID): RendererThread => {\n return Platform.MapUtilities.getWithDefault(process.threads, tid, makeRendererThread);\n};\n\nexport function handleUserConfig(userConfig: Types.Configuration.Configuration): void {\n config = userConfig;\n}\n\nexport function reset(): void {\n processes = new Map();\n entryToNode = new Map();\n entityMappings = {\n eventsByEntity: new Map<HandlerHelpers.Entity, Types.Events.Event[]>(),\n entityByEvent: new Map<Types.Events.Event, HandlerHelpers.Entity>(),\n createdEntityCache: new Map<string, HandlerHelpers.Entity>(),\n entityByUrlCache: new Map<string, HandlerHelpers.Entity>(),\n };\n completeEventStack = [];\n compositorTileWorkers = [];\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (Types.Events.isThreadName(event) && event.args.name?.startsWith('CompositorTileWorker')) {\n compositorTileWorkers.push({\n pid: event.pid,\n tid: event.tid,\n });\n }\n\n if (Types.Events.isBegin(event) || Types.Events.isEnd(event)) {\n const process = getOrCreateRendererProcess(processes, event.pid);\n const thread = getOrCreateRendererThread(process, event.tid);\n const completeEvent = makeCompleteEvent(event);\n if (!completeEvent) {\n return;\n }\n thread.entries.push(completeEvent);\n return;\n }\n\n if (Types.Events.isInstant(event) || Types.Events.isComplete(event)) {\n const process = getOrCreateRendererProcess(processes, event.pid);\n const thread = getOrCreateRendererThread(process, event.tid);\n thread.entries.push(event);\n }\n\n if (Types.Events.isLayout(event)) {\n const process = getOrCreateRendererProcess(processes, event.pid);\n const thread = getOrCreateRendererThread(process, event.tid);\n thread.layoutEvents.push(event);\n }\n\n if (Types.Events.isRecalcStyle(event)) {\n const process = getOrCreateRendererProcess(processes, event.pid);\n const thread = getOrCreateRendererThread(process, event.tid);\n thread.recalcStyleEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n const {mainFrameId, rendererProcessesByFrame, threadsInProcess} = metaHandlerData();\n entityMappings = networkRequestHandlerData().entityMappings;\n\n assignMeta(processes, mainFrameId, rendererProcessesByFrame, threadsInProcess);\n sanitizeProcesses(processes);\n buildHierarchy(processes);\n sanitizeThreads(processes);\n}\n\nexport function data(): RendererHandlerData {\n return {\n processes,\n compositorTileWorkers: gatherCompositorThreads(),\n entryToNode,\n entityMappings: {\n entityByEvent: entityMappings.entityByEvent,\n eventsByEntity: entityMappings.eventsByEntity,\n createdEntityCache: entityMappings.createdEntityCache,\n entityByUrlCache: entityMappings.entityByUrlCache,\n },\n };\n}\n\nfunction gatherCompositorThreads(): Map<Types.Events.ProcessID, Types.Events.ThreadID[]> {\n const threadsByProcess = new Map<Types.Events.ProcessID, Types.Events.ThreadID[]>();\n for (const worker of compositorTileWorkers) {\n const byProcess = threadsByProcess.get(worker.pid) || [];\n byProcess.push(worker.tid);\n threadsByProcess.set(worker.pid, byProcess);\n }\n return threadsByProcess;\n}\n\n/**\n * Steps through all the renderer processes we've located so far in the meta\n * handler, obtaining their URL, checking whether they are the main frame, and\n * collecting each one of their threads' name. This meta handler's data is\n * assigned to the renderer handler's data.\n */\nexport function assignMeta(\n processes: Map<Types.Events.ProcessID, RendererProcess>, mainFrameId: string,\n rendererProcessesByFrame: FrameProcessData,\n threadsInProcess: Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.ThreadName>>): void {\n assignOrigin(processes, rendererProcessesByFrame);\n assignIsMainFrame(processes, mainFrameId, rendererProcessesByFrame);\n assignThreadName(processes, threadsInProcess);\n}\n\n/**\n * Assigns origins to all threads in all processes.\n * @see assignMeta\n */\nexport function assignOrigin(\n processes: Map<Types.Events.ProcessID, RendererProcess>, rendererProcessesByFrame: FrameProcessData): void {\n for (const renderProcessesByPid of rendererProcessesByFrame.values()) {\n for (const [pid, processWindows] of renderProcessesByPid) {\n for (const processInfo of processWindows.flat()) {\n const process = getOrCreateRendererProcess(processes, pid);\n // Sometimes a single process is responsible with rendering multiple\n // frames at the same time. For example, see https://crbug.com/1334563.\n // When this happens, we'd still like to assign a single url per process\n // so: 1) use the first frame rendered by this process as the url source\n // and 2) if the last url is \"about:blank\", use the next frame's url,\n // data from about:blank is irrelevant.\n if (process.url === null || process.url === 'about:blank') {\n // If we are here, it's because we care about this process and the URL. But before we store\n // it, we check if it is a valid URL by trying to create a URL object. If it isn't, we won't\n // set it, and this process will be filtered out later.\n try {\n new URL(processInfo.frame.url);\n process.url = processInfo.frame.url;\n } catch {\n process.url = null;\n }\n }\n }\n }\n }\n}\n\n/**\n * Assigns whether or not a thread is the main frame to all threads in all processes.\n * @see assignMeta\n */\nexport function assignIsMainFrame(\n processes: Map<Types.Events.ProcessID, RendererProcess>, mainFrameId: string,\n rendererProcessesByFrame: FrameProcessData): void {\n for (const [frameId, renderProcessesByPid] of rendererProcessesByFrame) {\n for (const [pid] of renderProcessesByPid) {\n const process = getOrCreateRendererProcess(processes, pid);\n // We have this go in one direction; once a renderer has been flagged as\n // being on the main frame, we don't unset it to false if were to show up\n // in a subframe. Equally, if we already saw this renderer in a subframe,\n // but it becomes the main frame, the flag would get updated.\n if (frameId === mainFrameId) {\n process.isOnMainFrame = true;\n }\n }\n }\n}\n\n/**\n * Assigns the thread name to all threads in all processes.\n * @see assignMeta\n */\nexport function assignThreadName(\n processes: Map<Types.Events.ProcessID, RendererProcess>,\n threadsInProcess: Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.ThreadName>>): void {\n for (const [pid, process] of processes) {\n for (const [tid, threadInfo] of threadsInProcess.get(pid) ?? []) {\n const thread = getOrCreateRendererThread(process, tid);\n thread.name = threadInfo?.args.name ?? `${tid}`;\n }\n }\n}\n\n/**\n * Removes unneeded trace data opportunistically stored while handling events.\n * This currently does the following:\n * - Deletes processes with an unknown origin.\n */\nexport function sanitizeProcesses(processes: Map<Types.Events.ProcessID, RendererProcess>): void {\n const auctionWorklets = auctionWorkletsData().worklets;\n const metaData = metaHandlerData();\n if (metaData.traceIsGeneric) {\n return;\n }\n for (const [pid, process] of processes) {\n // If the process had no url, or if it had a malformed url that could not be\n // parsed for some reason, or if it's an \"about:\" origin, delete it.\n // This is done because we don't really care about processes for which we\n // can't provide actionable insights to the user (e.g. about:blank pages).\n //\n // There is one exception; AuctionWorklet processes get parsed in a\n // separate handler, so at this point we check to see if the process has\n // been found by the AuctionWorkletsHandler, and if so we update the URL.\n // This ensures that we keep this process around and do not drop it due to\n // the lack of a URL.\n if (process.url === null) {\n const maybeWorklet = auctionWorklets.get(pid);\n if (maybeWorklet) {\n process.url = maybeWorklet.host;\n } else {\n processes.delete(pid);\n }\n continue;\n }\n }\n}\n\n/**\n * Removes unneeded trace data opportunistically stored while handling events.\n * This currently does the following:\n * - Deletes threads with no roots.\n */\nexport function sanitizeThreads(processes: Map<Types.Events.ProcessID, RendererProcess>): void {\n for (const [, process] of processes) {\n for (const [tid, thread] of process.threads) {\n // If the thread has no roots, delete it. Otherwise, there's going to\n // be space taken, even though nothing is rendered in the track manager.\n if (!thread.tree?.roots.size) {\n process.threads.delete(tid);\n }\n }\n }\n}\n\n/**\n * Creates a hierarchical structure from the trace events. Each thread in each\n * process will contribute to their own individual hierarchy.\n *\n * The trace data comes in as a contiguous array of events, against which we\n * make a couple of assumptions:\n *\n * 1. Events are temporally-ordered in terms of start time (though they're\n * not necessarily ordered as such in the data stream).\n * 2. If event B's start and end times are within event A's time boundaries\n * we assume that A is the parent of B.\n *\n * Therefore we expect to reformulate something like:\n *\n * [ Task A ][ Task B ][ Task C ][ Task D ][ Task E ]\n *\n * Into something hierarchically-arranged like below:\n *\n * |------------- Task A -------------||-- Task E --|\n * |-- Task B --||-- Task D --|\n * |- Task C -|\n */\nexport function buildHierarchy(\n processes: Map<Types.Events.ProcessID, RendererProcess>,\n options?: {filter: {has: (name: Types.Events.Name) => boolean}}): void {\n const samplesData = samplesHandlerData();\n for (const [pid, process] of processes) {\n for (const [tid, thread] of process.threads) {\n if (!thread.entries.length) {\n thread.tree = Helpers.TreeHelpers.makeEmptyTraceEntryTree();\n continue;\n }\n // Step 1. Massage the data.\n Helpers.Trace.sortTraceEventsInPlace(thread.entries);\n // Step 2. Inject profile calls from samples\n const samplesDataForThread = samplesData.profilesInProcess.get(pid)?.get(tid);\n if (samplesDataForThread) {\n const cpuProfile = samplesDataForThread.parsedProfile;\n const samplesIntegrator = cpuProfile &&\n new Helpers.SamplesIntegrator.SamplesIntegrator(\n cpuProfile, samplesDataForThread.profileId, pid, tid, config);\n const profileCalls = samplesIntegrator?.buildProfileCalls(thread.entries);\n if (samplesIntegrator && profileCalls) {\n thread.entries = Helpers.Trace.mergeEventsInOrder(thread.entries, profileCalls);\n thread.profileCalls = profileCalls;\n\n // We'll also inject the instant JSSample events (in debug mode only)\n const jsSamples = samplesIntegrator.jsSampleEvents;\n if (jsSamples.length) {\n thread.entries = Helpers.Trace.mergeEventsInOrder(thread.entries, jsSamples);\n }\n }\n }\n // Step 3. Build the tree.\n const treeData = Helpers.TreeHelpers.treify(thread.entries, options);\n thread.tree = treeData.tree;\n // Update the entryToNode map with the entries from this thread\n for (const [entry, node] of treeData.entryToNode) {\n entryToNode.set(entry, node);\n // Entity mapping is unrelated to the tree, but calling here as we need to call on every node anyway.\n HandlerHelpers.addEventToEntityMapping(entry, entityMappings);\n }\n }\n }\n}\n\nexport function makeCompleteEvent(event: Types.Events.Begin|Types.Events.End): Types.Events.SyntheticComplete|null {\n if (Types.Events.isEnd(event)) {\n // Quietly ignore unbalanced close events, they're legit (we could\n // have missed start one).\n const beginEvent = completeEventStack.pop();\n if (!beginEvent) {\n return null;\n }\n if (beginEvent.name !== event.name || beginEvent.cat !== event.cat) {\n console.error(\n 'Begin/End events mismatch at ' + beginEvent.ts + ' (' + beginEvent.name + ') vs. ' + event.ts + ' (' +\n event.name + ')');\n return null;\n }\n // Update the begin event's duration using the timestamp of the end\n // event.\n beginEvent.dur = Types.Timing.Micro(event.ts - beginEvent.ts);\n return null;\n }\n\n // Create a synthetic event using the begin event, when we find the\n // matching end event later we will update its duration.\n const syntheticComplete: Types.Events.SyntheticComplete = {\n ...event,\n ph: Types.Events.Phase.COMPLETE,\n dur: Types.Timing.Micro(0),\n };\n\n completeEventStack.push(syntheticComplete);\n return syntheticComplete;\n}\n\nexport function deps(): HandlerName[] {\n return ['Meta', 'Samples', 'AuctionWorklets', 'NetworkRequests'];\n}\n\nexport interface RendererHandlerData {\n processes: Map<Types.Events.ProcessID, RendererProcess>;\n /**\n * A map of all compositor workers (which we show in the UI as Rasterizers)\n * by the process ID.\n */\n compositorTileWorkers: Map<Types.Events.ProcessID, Types.Events.ThreadID[]>;\n entryToNode: Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>;\n entityMappings: HandlerHelpers.EntityMappings;\n}\n\nexport interface RendererProcess {\n // In an ideal world this would be modelled as a URL, but URLs cannot be sent\n // between the main thread and workers, so we have to store it as a string.\n url: string|null;\n isOnMainFrame: boolean;\n threads: Map<Types.Events.ThreadID, RendererThread>;\n}\n\nexport interface RendererThread {\n name: string|null;\n /**\n * Contains trace events and synthetic profile calls made from\n * samples.\n */\n entries: Types.Events.Event[];\n profileCalls: Types.Events.SyntheticProfileCall[];\n layoutEvents: Types.Events.Layout[];\n recalcStyleEvents: Types.Events.RecalcStyle[];\n tree?: Helpers.TreeHelpers.TraceEntryTree;\n}\n"]}
1
+ {"version":3,"file":"RendererHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/RendererHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,cAAc,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAwB,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAC,IAAI,IAAI,yBAAyB,EAAC,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAC,IAAI,IAAI,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAG/D;;;;;;;;;;GAUG;AAEH,IAAI,SAAS,GAAG,IAAI,GAAG,EAA2C,CAAC;AAEnE,IAAI,cAAc,GAAkC;IAClD,cAAc,EAAE,IAAI,GAAG,EAA+C;IACtE,aAAa,EAAE,IAAI,GAAG,EAA6C;IACnE,kBAAkB,EAAE,IAAI,GAAG,EAAiC;IAC5D,gBAAgB,EAAE,IAAI,GAAG,EAAiC;CAC3D,CAAC;AAEF,+EAA+E;AAC/E,8EAA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,UAAU,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,EAAE,CAAC;YACnE,OAAO,CAAC,KAAK,CACT,+BAA+B,GAAG,UAAU,CAAC,EAAE,GAAG,IAAI,GAAG,UAAU,CAAC,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC,EAAE,GAAG,IAAI;gBACrG,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,mEAAmE;QACnE,SAAS;QACT,UAAU,CAAC,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mEAAmE;IACnE,wDAAwD;IACxD,MAAM,iBAAiB,GAAmC;QACxD,GAAG,KAAK;QACR,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC/B,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KAC3B,CAAC;IAEF,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC3C,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,iBAAiB,CAAC,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 Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport * as HandlerHelpers from './helpers.js';\nimport {data as metaHandlerData, type FrameProcessData} from './MetaHandler.js';\nimport {data as networkRequestHandlerData} from './NetworkRequestsHandler.js';\nimport {data as samplesHandlerData} from './SamplesHandler.js';\nimport type {HandlerName} from './types.js';\n\n/**\n * This handler builds the hierarchy of trace events and profile calls\n * on each thread on each process.\n *\n * Throughout the code, trace events and profile calls are referred to\n * as \"entries\", but note they are different types of data. Trace events\n * come directly from the backend and it's the type the engine commonly\n * refers to. Profile calls on the other hand are built in the frontend,\n * and, for compatibility purposes, typed as an extension to the trace\n * event type.\n */\n\nlet processes = new Map<Types.Events.ProcessID, RendererProcess>();\n\nlet entityMappings: HandlerHelpers.EntityMappings = {\n eventsByEntity: new Map<HandlerHelpers.Entity, Types.Events.Event[]>(),\n entityByEvent: new Map<Types.Events.Event, HandlerHelpers.Entity>(),\n createdEntityCache: new Map<string, HandlerHelpers.Entity>(),\n entityByUrlCache: new Map<string, HandlerHelpers.Entity>(),\n};\n\n// We track the compositor tile worker thread name events so that at the end we\n// can return these keyed by the process ID. These are used in the frontend to\n// show the user the rasterization thread(s) on the main frame as tracks.\nlet compositorTileWorkers = Array<{\n pid: Types.Events.ProcessID,\n tid: Types.Events.ThreadID,\n}>();\nlet entryToNode = new Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>();\n\nlet completeEventStack: (Types.Events.SyntheticComplete)[] = [];\n\nlet config: Types.Configuration.Configuration = Types.Configuration.defaults();\n\nconst makeRendererProcess = (): RendererProcess => ({\n url: null,\n isOnMainFrame: false,\n threads: new Map(),\n});\n\nconst makeRendererThread = (): RendererThread => ({\n name: null,\n entries: [],\n profileCalls: [],\n layoutEvents: [],\n recalcStyleEvents: [],\n});\n\nconst getOrCreateRendererProcess =\n (processes: Map<Types.Events.ProcessID, RendererProcess>, pid: Types.Events.ProcessID): RendererProcess => {\n return Platform.MapUtilities.getWithDefault(processes, pid, makeRendererProcess);\n };\n\nconst getOrCreateRendererThread = (process: RendererProcess, tid: Types.Events.ThreadID): RendererThread => {\n return Platform.MapUtilities.getWithDefault(process.threads, tid, makeRendererThread);\n};\n\nexport function handleUserConfig(userConfig: Types.Configuration.Configuration): void {\n config = userConfig;\n}\n\nexport function reset(): void {\n processes = new Map();\n entryToNode = new Map();\n entityMappings = {\n eventsByEntity: new Map<HandlerHelpers.Entity, Types.Events.Event[]>(),\n entityByEvent: new Map<Types.Events.Event, HandlerHelpers.Entity>(),\n createdEntityCache: new Map<string, HandlerHelpers.Entity>(),\n entityByUrlCache: new Map<string, HandlerHelpers.Entity>(),\n };\n completeEventStack = [];\n compositorTileWorkers = [];\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (Types.Events.isThreadName(event) && event.args.name?.startsWith('CompositorTileWorker')) {\n compositorTileWorkers.push({\n pid: event.pid,\n tid: event.tid,\n });\n }\n\n if (Types.Events.isBegin(event) || Types.Events.isEnd(event)) {\n const process = getOrCreateRendererProcess(processes, event.pid);\n const thread = getOrCreateRendererThread(process, event.tid);\n const completeEvent = makeCompleteEvent(event);\n if (!completeEvent) {\n return;\n }\n thread.entries.push(completeEvent);\n return;\n }\n\n if (Types.Events.isInstant(event) || Types.Events.isComplete(event)) {\n const process = getOrCreateRendererProcess(processes, event.pid);\n const thread = getOrCreateRendererThread(process, event.tid);\n thread.entries.push(event);\n }\n\n if (Types.Events.isLayout(event)) {\n const process = getOrCreateRendererProcess(processes, event.pid);\n const thread = getOrCreateRendererThread(process, event.tid);\n thread.layoutEvents.push(event);\n }\n\n if (Types.Events.isRecalcStyle(event)) {\n const process = getOrCreateRendererProcess(processes, event.pid);\n const thread = getOrCreateRendererThread(process, event.tid);\n thread.recalcStyleEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n const {mainFrameId, rendererProcessesByFrame, threadsInProcess} = metaHandlerData();\n entityMappings = networkRequestHandlerData().entityMappings;\n\n assignMeta(processes, mainFrameId, rendererProcessesByFrame, threadsInProcess);\n sanitizeProcesses(processes);\n buildHierarchy(processes);\n sanitizeThreads(processes);\n}\n\nexport function data(): RendererHandlerData {\n return {\n processes,\n compositorTileWorkers: gatherCompositorThreads(),\n entryToNode,\n entityMappings: {\n entityByEvent: entityMappings.entityByEvent,\n eventsByEntity: entityMappings.eventsByEntity,\n createdEntityCache: entityMappings.createdEntityCache,\n entityByUrlCache: entityMappings.entityByUrlCache,\n },\n };\n}\n\nfunction gatherCompositorThreads(): Map<Types.Events.ProcessID, Types.Events.ThreadID[]> {\n const threadsByProcess = new Map<Types.Events.ProcessID, Types.Events.ThreadID[]>();\n for (const worker of compositorTileWorkers) {\n const byProcess = threadsByProcess.get(worker.pid) || [];\n byProcess.push(worker.tid);\n threadsByProcess.set(worker.pid, byProcess);\n }\n return threadsByProcess;\n}\n\n/**\n * Steps through all the renderer processes we've located so far in the meta\n * handler, obtaining their URL, checking whether they are the main frame, and\n * collecting each one of their threads' name. This meta handler's data is\n * assigned to the renderer handler's data.\n */\nexport function assignMeta(\n processes: Map<Types.Events.ProcessID, RendererProcess>, mainFrameId: string,\n rendererProcessesByFrame: FrameProcessData,\n threadsInProcess: Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.ThreadName>>): void {\n assignOrigin(processes, rendererProcessesByFrame);\n assignIsMainFrame(processes, mainFrameId, rendererProcessesByFrame);\n assignThreadName(processes, threadsInProcess);\n}\n\n/**\n * Assigns origins to all threads in all processes.\n * @see assignMeta\n */\nexport function assignOrigin(\n processes: Map<Types.Events.ProcessID, RendererProcess>, rendererProcessesByFrame: FrameProcessData): void {\n for (const renderProcessesByPid of rendererProcessesByFrame.values()) {\n for (const [pid, processWindows] of renderProcessesByPid) {\n for (const processInfo of processWindows.flat()) {\n const process = getOrCreateRendererProcess(processes, pid);\n // Sometimes a single process is responsible with rendering multiple\n // frames at the same time. For example, see https://crbug.com/1334563.\n // When this happens, we'd still like to assign a single url per process\n // so: 1) use the first frame rendered by this process as the url source\n // and 2) if the last url is \"about:blank\", use the next frame's url,\n // data from about:blank is irrelevant.\n if (process.url === null || process.url === 'about:blank') {\n // If we are here, it's because we care about this process and the URL. But before we store\n // it, we check if it is a valid URL by trying to create a URL object. If it isn't, we won't\n // set it, and this process will be filtered out later.\n try {\n new URL(processInfo.frame.url);\n process.url = processInfo.frame.url;\n } catch {\n process.url = null;\n }\n }\n }\n }\n }\n}\n\n/**\n * Assigns whether or not a thread is the main frame to all threads in all processes.\n * @see assignMeta\n */\nexport function assignIsMainFrame(\n processes: Map<Types.Events.ProcessID, RendererProcess>, mainFrameId: string,\n rendererProcessesByFrame: FrameProcessData): void {\n for (const [frameId, renderProcessesByPid] of rendererProcessesByFrame) {\n for (const [pid] of renderProcessesByPid) {\n const process = getOrCreateRendererProcess(processes, pid);\n // We have this go in one direction; once a renderer has been flagged as\n // being on the main frame, we don't unset it to false if were to show up\n // in a subframe. Equally, if we already saw this renderer in a subframe,\n // but it becomes the main frame, the flag would get updated.\n if (frameId === mainFrameId) {\n process.isOnMainFrame = true;\n }\n }\n }\n}\n\n/**\n * Assigns the thread name to all threads in all processes.\n * @see assignMeta\n */\nexport function assignThreadName(\n processes: Map<Types.Events.ProcessID, RendererProcess>,\n threadsInProcess: Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.ThreadName>>): void {\n for (const [pid, process] of processes) {\n for (const [tid, threadInfo] of threadsInProcess.get(pid) ?? []) {\n const thread = getOrCreateRendererThread(process, tid);\n thread.name = threadInfo?.args.name ?? `${tid}`;\n }\n }\n}\n\n/**\n * Removes unneeded trace data opportunistically stored while handling events.\n * This currently does the following:\n * - Deletes processes with an unknown origin.\n */\nexport function sanitizeProcesses(processes: Map<Types.Events.ProcessID, RendererProcess>): void {\n const metaData = metaHandlerData();\n if (metaData.traceIsGeneric) {\n return;\n }\n for (const [pid, process] of processes) {\n // If the process had no url, or if it had a malformed url that could not be\n // parsed for some reason, or if it's an \"about:\" origin, delete it.\n // This is done because we don't really care about processes for which we\n // can't provide actionable insights to the user (e.g. about:blank pages).\n if (process.url === null) {\n processes.delete(pid);\n continue;\n }\n }\n}\n\n/**\n * Removes unneeded trace data opportunistically stored while handling events.\n * This currently does the following:\n * - Deletes threads with no roots.\n */\nexport function sanitizeThreads(processes: Map<Types.Events.ProcessID, RendererProcess>): void {\n for (const [, process] of processes) {\n for (const [tid, thread] of process.threads) {\n // If the thread has no roots, delete it. Otherwise, there's going to\n // be space taken, even though nothing is rendered in the track manager.\n if (!thread.tree?.roots.size) {\n process.threads.delete(tid);\n }\n }\n }\n}\n\n/**\n * Creates a hierarchical structure from the trace events. Each thread in each\n * process will contribute to their own individual hierarchy.\n *\n * The trace data comes in as a contiguous array of events, against which we\n * make a couple of assumptions:\n *\n * 1. Events are temporally-ordered in terms of start time (though they're\n * not necessarily ordered as such in the data stream).\n * 2. If event B's start and end times are within event A's time boundaries\n * we assume that A is the parent of B.\n *\n * Therefore we expect to reformulate something like:\n *\n * [ Task A ][ Task B ][ Task C ][ Task D ][ Task E ]\n *\n * Into something hierarchically-arranged like below:\n *\n * |------------- Task A -------------||-- Task E --|\n * |-- Task B --||-- Task D --|\n * |- Task C -|\n */\nexport function buildHierarchy(\n processes: Map<Types.Events.ProcessID, RendererProcess>,\n options?: {filter: {has: (name: Types.Events.Name) => boolean}}): void {\n // Ensure threads that only contain V8 CPU profiler samples (such as WebAssembly\n // background execution threads) are registered in their process before we iterate.\n // These threads do not receive standard renderer trace events, so their RendererThread\n // objects must be initialized here so SamplesIntegrator can inject profile calls.\n const samplesData = samplesHandlerData();\n for (const [pid, profilesByThread] of samplesData.profilesInProcess) {\n const process = processes.get(pid);\n if (!process) {\n continue;\n }\n for (const [tid] of profilesByThread) {\n getOrCreateRendererThread(process, tid);\n }\n }\n\n for (const [pid, process] of processes) {\n for (const [tid, thread] of process.threads) {\n // Step 1. Massage the data.\n Helpers.Trace.sortTraceEventsInPlace(thread.entries);\n // Step 2. Inject profile calls from samples\n const samplesDataForThread = samplesData.profilesInProcess.get(pid)?.get(tid);\n if (samplesDataForThread) {\n const cpuProfile = samplesDataForThread.parsedProfile;\n const samplesIntegrator = cpuProfile &&\n new Helpers.SamplesIntegrator.SamplesIntegrator(\n cpuProfile, samplesDataForThread.profileId, pid, tid, config);\n const profileCalls = samplesIntegrator?.buildProfileCalls(thread.entries);\n if (samplesIntegrator && profileCalls) {\n thread.entries = Helpers.Trace.mergeEventsInOrder(thread.entries, profileCalls);\n thread.profileCalls = profileCalls;\n\n // We'll also inject the instant JSSample events (in debug mode only)\n const jsSamples = samplesIntegrator.jsSampleEvents;\n if (jsSamples.length) {\n thread.entries = Helpers.Trace.mergeEventsInOrder(thread.entries, jsSamples);\n }\n }\n }\n\n if (!thread.entries.length) {\n thread.tree = Helpers.TreeHelpers.makeEmptyTraceEntryTree();\n continue;\n }\n\n // Step 3. Build the tree.\n const treeData = Helpers.TreeHelpers.treify(thread.entries, options);\n thread.tree = treeData.tree;\n // Update the entryToNode map with the entries from this thread\n for (const [entry, node] of treeData.entryToNode) {\n entryToNode.set(entry, node);\n // Entity mapping is unrelated to the tree, but calling here as we need to call on every node anyway.\n HandlerHelpers.addEventToEntityMapping(entry, entityMappings);\n }\n }\n }\n}\n\nexport function makeCompleteEvent(event: Types.Events.Begin|Types.Events.End): Types.Events.SyntheticComplete|null {\n if (Types.Events.isEnd(event)) {\n // Quietly ignore unbalanced close events, they're legit (we could\n // have missed start one).\n const beginEvent = completeEventStack.pop();\n if (!beginEvent) {\n return null;\n }\n if (beginEvent.name !== event.name || beginEvent.cat !== event.cat) {\n console.error(\n 'Begin/End events mismatch at ' + beginEvent.ts + ' (' + beginEvent.name + ') vs. ' + event.ts + ' (' +\n event.name + ')');\n return null;\n }\n // Update the begin event's duration using the timestamp of the end\n // event.\n beginEvent.dur = Types.Timing.Micro(event.ts - beginEvent.ts);\n return null;\n }\n\n // Create a synthetic event using the begin event, when we find the\n // matching end event later we will update its duration.\n const syntheticComplete: Types.Events.SyntheticComplete = {\n ...event,\n ph: Types.Events.Phase.COMPLETE,\n dur: Types.Timing.Micro(0),\n };\n\n completeEventStack.push(syntheticComplete);\n return syntheticComplete;\n}\n\nexport function deps(): HandlerName[] {\n return ['Meta', 'Samples', 'NetworkRequests'];\n}\n\nexport interface RendererHandlerData {\n processes: Map<Types.Events.ProcessID, RendererProcess>;\n /**\n * A map of all compositor workers (which we show in the UI as Rasterizers)\n * by the process ID.\n */\n compositorTileWorkers: Map<Types.Events.ProcessID, Types.Events.ThreadID[]>;\n entryToNode: Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>;\n entityMappings: HandlerHelpers.EntityMappings;\n}\n\nexport interface RendererProcess {\n // In an ideal world this would be modelled as a URL, but URLs cannot be sent\n // between the main thread and workers, so we have to store it as a string.\n url: string|null;\n isOnMainFrame: boolean;\n threads: Map<Types.Events.ThreadID, RendererThread>;\n}\n\nexport interface RendererThread {\n name: string|null;\n /**\n * Contains trace events and synthetic profile calls made from\n * samples.\n */\n entries: Types.Events.Event[];\n profileCalls: Types.Events.SyntheticProfileCall[];\n layoutEvents: Types.Events.Layout[];\n recalcStyleEvents: Types.Events.RecalcStyle[];\n tree?: Helpers.TreeHelpers.TraceEntryTree;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SamplesHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/SamplesHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,IAAI,iBAAiB,GAAG,IAAI,GAAG,EAAmE,CAAC;AACnG,IAAI,WAAW,GAAG,IAAI,GAAG,EAA0D,CAAC;AAEpF,2DAA2D;AAC3D,6DAA6D;AAC7D,sEAAsE;AACtE,uEAAuE;AACvE,sEAAsE;AACtE,mDAAmD;AACnD,uEAAuE;AACvE,uEAAuE;AACvE,+BAA+B;AAC/B,IAAI,gBAAgB,GAAG,IAAI,GAAG,EAAyE,CAAC;AAExG;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,2BAA2B,GAAG;IAClC,UAAU,EAAE,CAAC,WAAW,CAAiC;IACzD,gBAAgB,EA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YAAY,CAAC;AACtC,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 type * as Protocol from '../../../generated/protocol.js';\nimport * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nlet profilesInProcess = new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, ProfileData>>();\nlet entryToNode = new Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>();\n\n// The profile head, containing its metadata like its start\n// time, comes in a \"Profile\" event. The sample data comes in\n// \"ProfileChunk\" events. We match these ProfileChunks with their head\n// using process and profile ids. However, in order to integrate sample\n// data with trace data, we need the thread id that owns each profile.\n// This thread id is extracted from the head event.\n// For this reason, we have a preprocessed data structure, where events\n// are matched by profile id, which we then finish processing to export\n// events matched by thread id.\nlet preprocessedData = new Map<Types.Events.ProcessID, Map<Types.Events.ProfileID, PreprocessedData>>();\n\n/**\n * Profile source selection priority when multiple profiles exist for the same thread.\n *\n * Profile sources and their typical scenarios:\n * - 'Internal': Browser-initiated profiling performance panel traces.\n * This is the profiling mechanism when users click \"Record\" in the Devtools UI.\n * - 'Inspector': User-initiated via console.profile()/profileEnd() calls.\n * Represents explicit developer intent to profile specific code.\n * - 'SelfProfiling': Page-initiated via JS Self-Profiling API.\n * Lower signal vs the two above; treated as fallback.\n *\n * Selection strategy:\n * - CPU Profile mode: Prefer 'Inspector' (explicit user request).\n * - Performance trace: Prefer 'Internal' (integrated timeline context), then 'Inspector'.\n * - Sources not in the priority list (including 'SelfProfiling') act as fallbacks.\n * When no priority source matches, the first candidate profile is selected.\n */\nconst PROFILE_SOURCES_BY_PRIORITY = {\n cpuProfile: ['Inspector'] as Types.Events.ProfileSource[],\n performanceTrace: ['Internal', 'Inspector'] as Types.Events.ProfileSource[],\n};\n\nfunction parseCPUProfileData(parseOptions: Types.Configuration.ParseOptions): void {\n const priorityList =\n parseOptions.isCPUProfile ? PROFILE_SOURCES_BY_PRIORITY.cpuProfile : PROFILE_SOURCES_BY_PRIORITY.performanceTrace;\n\n for (const [processId, profiles] of preprocessedData) {\n const profilesByThread =\n new Map<Types.Events.ThreadID, Array<{id: Types.Events.ProfileID, data: PreprocessedData}>>();\n for (const [profileId, preProcessedData] of profiles) {\n const threadId = preProcessedData.threadId;\n if (threadId === undefined) {\n continue;\n }\n const listForThread = Platform.MapUtilities.getWithDefault(profilesByThread, threadId, () => []);\n listForThread.push({id: profileId, data: preProcessedData});\n }\n\n for (const [threadId, candidates] of profilesByThread) {\n if (!candidates.length) {\n continue;\n }\n let chosen = candidates[0];\n for (const source of priorityList) {\n const match = candidates.find(p => p.data.source === source);\n if (match) {\n chosen = match;\n break;\n }\n }\n const chosenData = chosen.data;\n if (!chosenData.rawProfile.nodes.length) {\n continue;\n }\n const indexStack: number[] = [];\n\n const profileModel = new CPUProfile.CPUProfileDataModel.CPUProfileDataModel(chosenData.rawProfile);\n const profileTree = Helpers.TreeHelpers.makeEmptyTraceEntryTree();\n profileTree.maxDepth = profileModel.maxDepth;\n\n const selectedProfileId = chosen.id;\n const finalizedData: ProfileData = {\n rawProfile: chosenData.rawProfile,\n parsedProfile: profileModel,\n profileCalls: [],\n profileTree,\n profileId: selectedProfileId,\n };\n const dataByThread = Platform.MapUtilities.getWithDefault(profilesInProcess, processId, () => new Map());\n dataByThread.set(threadId, finalizedData);\n\n // Only need to build pure JS ProfileCalls if we're parsing a CPU Profile, otherwise SamplesIntegrator does the work.\n if (parseOptions.isCPUProfile) {\n buildProfileCallsForCPUProfile();\n }\n\n function buildProfileCallsForCPUProfile(): void {\n profileModel.forEachFrame(openFrameCallback, closeFrameCallback);\n\n function openFrameCallback(\n depth: number, node: CPUProfile.ProfileTreeModel.ProfileNode, sampleIndex: number,\n timeStampMilliseconds: number): void {\n if (threadId === undefined) {\n return;\n }\n const ts = Helpers.Timing.milliToMicro(Types.Timing.Milli(timeStampMilliseconds));\n const nodeId = node.id as Helpers.TreeHelpers.TraceEntryNodeId;\n\n const profileCall =\n Helpers.Trace.makeProfileCall(node, selectedProfileId, sampleIndex, ts, processId, threadId);\n finalizedData.profileCalls.push(profileCall);\n indexStack.push(finalizedData.profileCalls.length - 1);\n const traceEntryNode = Helpers.TreeHelpers.makeEmptyTraceEntryNode(profileCall, nodeId);\n entryToNode.set(profileCall, traceEntryNode);\n traceEntryNode.depth = depth;\n if (indexStack.length === 1) {\n // First call in the stack is a root call.\n finalizedData.profileTree?.roots.add(traceEntryNode);\n }\n }\n function closeFrameCallback(\n _depth: number, _node: CPUProfile.ProfileTreeModel.ProfileNode, _sampleIndex: number,\n _timeStampMillis: number, durMs: number, selfTimeMs: number): void {\n const profileCallIndex = indexStack.pop();\n const profileCall = profileCallIndex !== undefined && finalizedData.profileCalls[profileCallIndex];\n if (!profileCall) {\n return;\n }\n const {callFrame, ts, pid, tid} = profileCall;\n const traceEntryNode = entryToNode.get(profileCall);\n if (callFrame === undefined || ts === undefined || pid === undefined || selectedProfileId === undefined ||\n tid === undefined || traceEntryNode === undefined) {\n return;\n }\n const dur = Helpers.Timing.milliToMicro(Types.Timing.Milli(durMs));\n const selfTime = Helpers.Timing.milliToMicro(Types.Timing.Milli(selfTimeMs));\n profileCall.dur = dur;\n traceEntryNode.selfTime = selfTime;\n\n const parentIndex = indexStack.at(-1);\n const parent = parentIndex !== undefined && finalizedData.profileCalls.at(parentIndex);\n const parentNode = parent && entryToNode.get(parent);\n if (!parentNode) {\n return;\n }\n traceEntryNode.parent = parentNode;\n parentNode.children.push(traceEntryNode);\n }\n }\n }\n }\n}\n\nexport function reset(): void {\n preprocessedData = new Map();\n profilesInProcess = new Map();\n entryToNode = new Map();\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n /**\n * A fake trace event created to support CDP.Profiler.Profiles in the\n * trace engine.\n */\n if (Types.Events.isSyntheticCpuProfile(event)) {\n // At the moment we are attaching to a single node target so we\n // should only get a single CPU profile. The values of the process\n // id and thread id are not really important, so we use the data\n // in the fake event. Should multi-thread CPU profiling be supported\n // we could use these fields in the event to pass thread info.\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n profileData.rawProfile = event.args.data.cpuProfile;\n profileData.threadId = event.tid;\n return;\n }\n\n if (Types.Events.isProfile(event)) {\n // Do not use event.args.data.startTime as it is in CLOCK_MONOTONIC domain,\n // but use profileEvent.ts which has been translated to Perfetto's clock\n // domain. Also convert from ms to us.\n // Note: events are collected on a different thread than what's sampled.\n // The correct process and thread ids are specified by the profile.\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n profileData.rawProfile.startTime = event.ts;\n profileData.threadId = event.tid;\n assignProfileSourceIfKnown(profileData, event.args?.data?.source);\n return;\n }\n if (Types.Events.isProfileChunk(event)) {\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n const cdpProfile = profileData.rawProfile;\n const nodesAndSamples: Types.Events.PartialProfile = event.args?.data?.cpuProfile || {samples: []};\n const samples = nodesAndSamples?.samples || [];\n const traceIds = event.args?.data?.cpuProfile?.trace_ids;\n for (const n of nodesAndSamples?.nodes || []) {\n const lineNumber = typeof n.callFrame.lineNumber === 'undefined' ? -1 : n.callFrame.lineNumber;\n const columnNumber = typeof n.callFrame.columnNumber === 'undefined' ? -1 : n.callFrame.columnNumber;\n\n const scriptId = String(n.callFrame.scriptId) as Protocol.Runtime.ScriptId;\n const url = n.callFrame.url || '';\n const node = {\n ...n,\n callFrame: {\n ...n.callFrame,\n url,\n lineNumber,\n columnNumber,\n scriptId,\n },\n };\n cdpProfile.nodes.push(node);\n }\n\n const timeDeltas = event.args.data?.timeDeltas || [];\n const lines = event.args.data?.lines || Array(samples.length).fill(0);\n const columns = event.args.data?.columns || Array(samples.length).fill(0);\n cdpProfile.samples?.push(...samples);\n cdpProfile.timeDeltas?.push(...timeDeltas);\n cdpProfile.lines?.push(...lines);\n cdpProfile.columns?.push(...columns);\n\n if (traceIds) {\n cdpProfile.traceIds ??= {};\n for (const key in traceIds) {\n cdpProfile.traceIds[key] = traceIds[key];\n }\n }\n\n if (cdpProfile.samples && cdpProfile.timeDeltas && cdpProfile.samples.length !== cdpProfile.timeDeltas.length) {\n console.error('Failed to parse CPU profile.');\n return;\n }\n if (!cdpProfile.endTime && cdpProfile.timeDeltas) {\n const timeDeltas: number[] = cdpProfile.timeDeltas;\n cdpProfile.endTime = timeDeltas.reduce((x, y) => x + y, cdpProfile.startTime);\n }\n assignProfileSourceIfKnown(profileData, event.args?.data?.source);\n return;\n }\n}\n\nexport async function finalize(parseOptions: Types.Configuration.ParseOptions = {}): Promise<void> {\n parseCPUProfileData(parseOptions);\n}\n\nfunction assignProfileSourceIfKnown(profileData: PreprocessedData, source: unknown): void {\n if (Types.Events.VALID_PROFILE_SOURCES.includes(source as Types.Events.ProfileSource)) {\n profileData.source = source as Types.Events.ProfileSource;\n }\n}\n\nexport function data(): SamplesHandlerData {\n return {\n profilesInProcess,\n entryToNode,\n };\n}\n\nfunction getOrCreatePreProcessedData(\n processId: Types.Events.ProcessID, profileId: Types.Events.ProfileID): PreprocessedData {\n const profileById = Platform.MapUtilities.getWithDefault(preprocessedData, processId, () => new Map());\n return Platform.MapUtilities.getWithDefault<Types.Events.ProfileID, PreprocessedData>(\n profileById, profileId, () => ({\n rawProfile: {\n startTime: 0,\n endTime: 0,\n nodes: [],\n samples: [],\n timeDeltas: [],\n lines: [],\n columns: [],\n },\n profileId,\n }));\n}\n\nexport interface SamplesHandlerData {\n profilesInProcess: typeof profilesInProcess;\n entryToNode: typeof entryToNode;\n}\n\nexport interface ProfileData {\n profileId: Types.Events.ProfileID;\n rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;\n parsedProfile: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Contains the calls built from the CPU profile samples.\n * Note: This doesn't contain real trace events coming from the\n * browser, only calls synthetically typed as trace events for\n * compatibility, as such it only makes sense to use them in pure CPU\n * profiles.\n *\n * If you need the profile calls from a CPU profile obtained from a\n * web trace, use the data exported by the RendererHandler instead.\n */\n profileCalls: Types.Events.SyntheticProfileCall[];\n /**\n * Contains the call tree built from the CPU profile samples.\n * Similar to the profileCalls field, this tree does not contain nor\n * take into account trace events, as such it only makes sense to use\n * them in pure CPU profiles.\n */\n profileTree?: Helpers.TreeHelpers.TraceEntryTree;\n}\n\ninterface PreprocessedData {\n rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;\n profileId: Types.Events.ProfileID;\n threadId?: Types.Events.ThreadID;\n source?: Types.Events.ProfileSource;\n}\n\n/**\n * Returns the name of a function for a given synthetic profile call.\n * We first look to find the ProfileNode representing this call, and use its\n * function name. This is preferred (and should always exist) because if we\n * resolve sourcemaps, we will update this name. If that name is not present,\n * we fall back to the function name that was in the callframe that we got\n * when parsing the profile's trace data.\n */\nexport function getProfileCallFunctionName(data: SamplesHandlerData, entry: Types.Events.SyntheticProfileCall): string {\n const profile = data.profilesInProcess.get(entry.pid)?.get(entry.tid);\n const node = profile?.parsedProfile.nodeById(entry.nodeId);\n if (node?.functionName) {\n return node.functionName;\n }\n return entry.callFrame.functionName;\n}\n"]}
1
+ {"version":3,"file":"SamplesHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/SamplesHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,IAAI,iBAAiB,GACjB,IAAI,GAAG,EAAmE,CAAC;AAC/E,IAAI,WAAW,GACX,IAAI,GAAG,EAA0D,CAAC;AAEtE,2DAA2D;AAC3D,6DAA6D;AAC7D,sEAAsE;AACtE,uEAAuE;AACvE,sEAAsE;AACtE,mDAAm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E,MAAM,IAAI,GAAG,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,IAAI,EAAE,YAAY,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC;AACtC,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 type * as Protocol from '../../../generated/protocol.js';\nimport * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nlet profilesInProcess: Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, ProfileData>> =\n new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, ProfileData>>();\nlet entryToNode: Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode> =\n new Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>();\n\n// The profile head, containing its metadata like its start\n// time, comes in a \"Profile\" event. The sample data comes in\n// \"ProfileChunk\" events. We match these ProfileChunks with their head\n// using process and profile ids. However, in order to integrate sample\n// data with trace data, we need the thread id that owns each profile.\n// This thread id is extracted from the head event.\n// For this reason, we have a preprocessed data structure, where events\n// are matched by profile id, which we then finish processing to export\n// events matched by thread id.\nlet preprocessedData = new Map<Types.Events.ProcessID, Map<Types.Events.ProfileID, PreprocessedData>>();\n\n/**\n * Profile source selection priority when multiple profiles exist for the same thread.\n *\n * Profile sources and their typical scenarios:\n * - 'Internal': Browser-initiated profiling performance panel traces.\n * This is the profiling mechanism when users click \"Record\" in the Devtools UI.\n * - 'Inspector': User-initiated via console.profile()/profileEnd() calls.\n * Represents explicit developer intent to profile specific code.\n * - 'SelfProfiling': Page-initiated via JS Self-Profiling API.\n * Lower signal vs the two above; treated as fallback.\n *\n * Selection strategy:\n * - CPU Profile mode: Prefer 'Inspector' (explicit user request).\n * - Performance trace: Prefer 'Internal' (integrated timeline context), then 'Inspector'.\n * - Sources not in the priority list (including 'SelfProfiling') act as fallbacks.\n * When no priority source matches, the first candidate profile is selected.\n */\nconst PROFILE_SOURCES_BY_PRIORITY = {\n cpuProfile: ['Inspector'] as Types.Events.ProfileSource[],\n performanceTrace: ['Internal', 'Inspector'] as Types.Events.ProfileSource[],\n};\n\nfunction parseCPUProfileData(parseOptions: Types.Configuration.ParseOptions): void {\n const priorityList =\n parseOptions.isCPUProfile ? PROFILE_SOURCES_BY_PRIORITY.cpuProfile : PROFILE_SOURCES_BY_PRIORITY.performanceTrace;\n\n for (const [processId, profiles] of preprocessedData) {\n const profilesByThread =\n new Map<Types.Events.ThreadID, Array<{id: Types.Events.ProfileID, data: PreprocessedData}>>();\n for (const [profileId, preProcessedData] of profiles) {\n const threadId = preProcessedData.threadId;\n if (threadId === undefined) {\n continue;\n }\n const listForThread = Platform.MapUtilities.getWithDefault(profilesByThread, threadId, () => []);\n listForThread.push({id: profileId, data: preProcessedData});\n }\n\n for (const [threadId, candidates] of profilesByThread) {\n if (!candidates.length) {\n continue;\n }\n let chosen = candidates[0];\n for (const source of priorityList) {\n const match = candidates.find(p => p.data.source === source);\n if (match) {\n chosen = match;\n break;\n }\n }\n const chosenData = chosen.data;\n if (!chosenData.rawProfile.nodes.length) {\n continue;\n }\n const indexStack: number[] = [];\n\n const profileModel = new CPUProfile.CPUProfileDataModel.CPUProfileDataModel(chosenData.rawProfile);\n const profileTree = Helpers.TreeHelpers.makeEmptyTraceEntryTree();\n profileTree.maxDepth = profileModel.maxDepth;\n\n const selectedProfileId = chosen.id;\n const finalizedData: ProfileData = {\n rawProfile: chosenData.rawProfile,\n parsedProfile: profileModel,\n profileCalls: [],\n profileTree,\n profileId: selectedProfileId,\n };\n const dataByThread = Platform.MapUtilities.getWithDefault(profilesInProcess, processId, () => new Map());\n dataByThread.set(threadId, finalizedData);\n\n // Only need to build pure JS ProfileCalls if we're parsing a CPU Profile, otherwise SamplesIntegrator does the work.\n if (parseOptions.isCPUProfile) {\n buildProfileCallsForCPUProfile();\n }\n\n function buildProfileCallsForCPUProfile(): void {\n profileModel.forEachFrame(openFrameCallback, closeFrameCallback);\n\n function openFrameCallback(\n depth: number, node: CPUProfile.ProfileTreeModel.ProfileNode, sampleIndex: number,\n timeStampMilliseconds: number): void {\n if (threadId === undefined) {\n return;\n }\n const ts = Helpers.Timing.milliToMicro(Types.Timing.Milli(timeStampMilliseconds));\n const nodeId = node.id as Helpers.TreeHelpers.TraceEntryNodeId;\n\n const profileCall =\n Helpers.Trace.makeProfileCall(node, selectedProfileId, sampleIndex, ts, processId, threadId);\n finalizedData.profileCalls.push(profileCall);\n indexStack.push(finalizedData.profileCalls.length - 1);\n const traceEntryNode = Helpers.TreeHelpers.makeEmptyTraceEntryNode(profileCall, nodeId);\n entryToNode.set(profileCall, traceEntryNode);\n traceEntryNode.depth = depth;\n if (indexStack.length === 1) {\n // First call in the stack is a root call.\n finalizedData.profileTree?.roots.add(traceEntryNode);\n }\n }\n function closeFrameCallback(\n _depth: number, _node: CPUProfile.ProfileTreeModel.ProfileNode, _sampleIndex: number,\n _timeStampMillis: number, durMs: number, selfTimeMs: number): void {\n const profileCallIndex = indexStack.pop();\n const profileCall = profileCallIndex !== undefined && finalizedData.profileCalls[profileCallIndex];\n if (!profileCall) {\n return;\n }\n const {callFrame, ts, pid, tid} = profileCall;\n const traceEntryNode = entryToNode.get(profileCall);\n if (callFrame === undefined || ts === undefined || pid === undefined || selectedProfileId === undefined ||\n tid === undefined || traceEntryNode === undefined) {\n return;\n }\n const dur = Helpers.Timing.milliToMicro(Types.Timing.Milli(durMs));\n const selfTime = Helpers.Timing.milliToMicro(Types.Timing.Milli(selfTimeMs));\n profileCall.dur = dur;\n traceEntryNode.selfTime = selfTime;\n\n const parentIndex = indexStack.at(-1);\n const parent = parentIndex !== undefined && finalizedData.profileCalls.at(parentIndex);\n const parentNode = parent && entryToNode.get(parent);\n if (!parentNode) {\n return;\n }\n traceEntryNode.parent = parentNode;\n parentNode.children.push(traceEntryNode);\n }\n }\n }\n }\n}\n\nexport function reset(): void {\n preprocessedData = new Map();\n profilesInProcess = new Map();\n entryToNode = new Map();\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n /**\n * A fake trace event created to support CDP.Profiler.Profiles in the\n * trace engine.\n */\n if (Types.Events.isSyntheticCpuProfile(event)) {\n // At the moment we are attaching to a single node target so we\n // should only get a single CPU profile. The values of the process\n // id and thread id are not really important, so we use the data\n // in the fake event. Should multi-thread CPU profiling be supported\n // we could use these fields in the event to pass thread info.\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n profileData.rawProfile = event.args.data.cpuProfile;\n profileData.threadId = event.tid;\n return;\n }\n\n if (Types.Events.isProfile(event)) {\n // Do not use event.args.data.startTime as it is in CLOCK_MONOTONIC domain,\n // but use profileEvent.ts which has been translated to Perfetto's clock\n // domain. Also convert from ms to us.\n // Note: events are collected on a different thread than what's sampled.\n // The correct process and thread ids are specified by the profile.\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n profileData.rawProfile.startTime = event.ts;\n profileData.threadId = event.tid;\n assignProfileSourceIfKnown(profileData, event.args?.data?.source);\n return;\n }\n if (Types.Events.isProfileChunk(event)) {\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n const cdpProfile = profileData.rawProfile;\n const nodesAndSamples: Types.Events.PartialProfile = event.args?.data?.cpuProfile || {samples: []};\n const samples = nodesAndSamples?.samples || [];\n const traceIds = event.args?.data?.cpuProfile?.trace_ids;\n for (const n of nodesAndSamples?.nodes || []) {\n const lineNumber = typeof n.callFrame.lineNumber === 'undefined' ? -1 : n.callFrame.lineNumber;\n const columnNumber = typeof n.callFrame.columnNumber === 'undefined' ? -1 : n.callFrame.columnNumber;\n\n const scriptId = String(n.callFrame.scriptId) as Protocol.Runtime.ScriptId;\n const url = n.callFrame.url || '';\n const node = {\n ...n,\n callFrame: {\n ...n.callFrame,\n url,\n lineNumber,\n columnNumber,\n scriptId,\n },\n };\n cdpProfile.nodes.push(node);\n }\n\n const timeDeltas = event.args.data?.timeDeltas || [];\n const lines = event.args.data?.lines || Array(samples.length).fill(0);\n const columns = event.args.data?.columns || Array(samples.length).fill(0);\n cdpProfile.samples?.push(...samples);\n cdpProfile.timeDeltas?.push(...timeDeltas);\n cdpProfile.lines?.push(...lines);\n cdpProfile.columns?.push(...columns);\n\n if (traceIds) {\n cdpProfile.traceIds ??= {};\n for (const key in traceIds) {\n cdpProfile.traceIds[key] = traceIds[key];\n }\n }\n\n if (cdpProfile.samples && cdpProfile.timeDeltas && cdpProfile.samples.length !== cdpProfile.timeDeltas.length) {\n console.error('Failed to parse CPU profile.');\n return;\n }\n if (!cdpProfile.endTime && cdpProfile.timeDeltas) {\n const timeDeltas: number[] = cdpProfile.timeDeltas;\n cdpProfile.endTime = timeDeltas.reduce((x, y) => x + y, cdpProfile.startTime);\n }\n assignProfileSourceIfKnown(profileData, event.args?.data?.source);\n return;\n }\n}\n\nexport async function finalize(parseOptions: Types.Configuration.ParseOptions = {}): Promise<void> {\n parseCPUProfileData(parseOptions);\n}\n\nfunction assignProfileSourceIfKnown(profileData: PreprocessedData, source: unknown): void {\n if (Types.Events.VALID_PROFILE_SOURCES.includes(source as Types.Events.ProfileSource)) {\n profileData.source = source as Types.Events.ProfileSource;\n }\n}\n\nexport function data(): SamplesHandlerData {\n return {\n profilesInProcess,\n entryToNode,\n };\n}\n\nfunction getOrCreatePreProcessedData(\n processId: Types.Events.ProcessID, profileId: Types.Events.ProfileID): PreprocessedData {\n const profileById = Platform.MapUtilities.getWithDefault(preprocessedData, processId, () => new Map());\n return Platform.MapUtilities.getWithDefault<Types.Events.ProfileID, PreprocessedData>(\n profileById, profileId, () => ({\n rawProfile: {\n startTime: 0,\n endTime: 0,\n nodes: [],\n samples: [],\n timeDeltas: [],\n lines: [],\n columns: [],\n },\n profileId,\n }));\n}\n\nexport interface SamplesHandlerData {\n profilesInProcess: typeof profilesInProcess;\n entryToNode: typeof entryToNode;\n}\n\nexport interface ProfileData {\n profileId: Types.Events.ProfileID;\n rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;\n parsedProfile: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Contains the calls built from the CPU profile samples.\n * Note: This doesn't contain real trace events coming from the\n * browser, only calls synthetically typed as trace events for\n * compatibility, as such it only makes sense to use them in pure CPU\n * profiles.\n *\n * If you need the profile calls from a CPU profile obtained from a\n * web trace, use the data exported by the RendererHandler instead.\n */\n profileCalls: Types.Events.SyntheticProfileCall[];\n /**\n * Contains the call tree built from the CPU profile samples.\n * Similar to the profileCalls field, this tree does not contain nor\n * take into account trace events, as such it only makes sense to use\n * them in pure CPU profiles.\n */\n profileTree?: Helpers.TreeHelpers.TraceEntryTree;\n}\n\ninterface PreprocessedData {\n rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;\n profileId: Types.Events.ProfileID;\n threadId?: Types.Events.ThreadID;\n source?: Types.Events.ProfileSource;\n}\n\n/**\n * Returns the name of a function for a given synthetic profile call.\n * We first look to find the ProfileNode representing this call, and use its\n * function name. This is preferred (and should always exist) because if we\n * resolve sourcemaps, we will update this name. If that name is not present,\n * we fall back to the function name that was in the callframe that we got\n * when parsing the profile's trace data.\n */\nexport function getProfileCallFunctionName(data: SamplesHandlerData, entry: Types.Events.SyntheticProfileCall): string {\n const profile = data.profilesInProcess.get(entry.pid)?.get(entry.tid);\n const node = profile?.parsedProfile.nodeById(entry.nodeId);\n if (node?.functionName) {\n return node.functionName;\n }\n return entry.callFrame.functionName;\n}\n"]}
@@ -3,19 +3,13 @@
3
3
  // found in the LICENSE file.
4
4
  import * as Helpers from '../helpers/helpers.js';
5
5
  import * as Types from '../types/types.js';
6
- // Each thread contains events. Events indicate the thread and process IDs, which are
7
- // used to store the event in the correct process thread entry below.
8
- let unpairedAsyncEvents = [];
9
6
  let legacyScreenshotEvents = [];
10
7
  let modernScreenshotEvents = [];
11
8
  let syntheticScreenshots = [];
12
- let frameSequenceToTs = {};
13
9
  export function reset() {
14
- unpairedAsyncEvents = [];
15
10
  legacyScreenshotEvents = [];
16
11
  syntheticScreenshots = [];
17
12
  modernScreenshotEvents = [];
18
- frameSequenceToTs = {};
19
13
  }
20
14
  export function handleEvent(event) {
21
15
  if (Types.Events.isLegacyScreenshot(event)) {
@@ -24,19 +18,8 @@ export function handleEvent(event) {
24
18
  else if (Types.Events.isScreenshot(event)) {
25
19
  modernScreenshotEvents.push(event);
26
20
  }
27
- else if (Types.Events.isPipelineReporter(event)) {
28
- unpairedAsyncEvents.push(event);
29
- }
30
21
  }
31
22
  export async function finalize() {
32
- const pipelineReporterEvents = Helpers.Trace.createMatchedSortedSyntheticEvents(unpairedAsyncEvents);
33
- frameSequenceToTs = Object.fromEntries(pipelineReporterEvents.map(evt => {
34
- const args = evt.args.data.beginEvent.args;
35
- const frameReporter = 'frame_reporter' in args ? args.frame_reporter : args.chrome_frame_reporter;
36
- const frameSequenceId = frameReporter.frame_sequence;
37
- const presentationTs = Types.Timing.Micro(evt.ts + evt.dur);
38
- return [frameSequenceId, presentationTs];
39
- }));
40
23
  for (const snapshotEvent of legacyScreenshotEvents) {
41
24
  const { cat, name, ph, pid, tid } = snapshotEvent;
42
25
  const syntheticEvent = Helpers.SyntheticEvents.SyntheticEventsManager.registerSyntheticEvent({
@@ -46,8 +29,7 @@ export async function finalize() {
46
29
  ph,
47
30
  pid,
48
31
  tid,
49
- // TODO(paulirish, crbug.com/41363012): investigate why getPresentationTimestamp(snapshotEvent) seems less accurate. Resolve screenshot timing inaccuracy.
50
- // `getPresentationTimestamp(snapshotEvent) - snapshotEvent.ts` is how many microsec the screenshot should be adjusted to the right/later
32
+ // TODO(paulirish, crbug.com/41363012): fix snapshot timestamps.
51
33
  ts: snapshotEvent.ts,
52
34
  args: {
53
35
  dataUri: `data:image/jpg;base64,${snapshotEvent.args.snapshot}`,
@@ -62,30 +44,6 @@ export function screenshotImageDataUri(event) {
62
44
  }
63
45
  return `data:image/jpg;base64,${event.args.snapshot}`;
64
46
  }
65
- /**
66
- * Correct the screenshot timestamps
67
- * The screenshot 'snapshot object' trace event has the "frame sequence number" attached as an ID.
68
- * We match that up with the "PipelineReporter" trace events as they terminate at presentation.
69
- * Presentation == when the pixels hit the screen. AKA Swap on the GPU
70
- */
71
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
72
- function getPresentationTimestamp(screenshotEvent) {
73
- const frameSequence = parseInt(screenshotEvent.id, 16);
74
- // If it's 1, then it's an old trace (before https://crrev.com/c/4957973) and cannot be corrected.
75
- if (frameSequence === 1) {
76
- return screenshotEvent.ts;
77
- }
78
- // The screenshot trace event's `ts` reflects the "expected display time" which is ESTIMATE.
79
- // It is set by the compositor frame sink from the `expected_display_time`, which is based on a previously known
80
- // frame start PLUS the vsync interval (eg 16.6ms)
81
- const updatedTs = frameSequenceToTs[frameSequence];
82
- // Do we always find a match? No...
83
- // We generally don't match the very first screenshot and, sometimes, the last
84
- // The very first screenshot is requested immediately (even if nothing is painting). As a result there's no compositor
85
- // instrumentation running alongside.
86
- // The last one is sometimes missing as because the trace terminates right before the associated PipelineReporter is emitted.
87
- return updatedTs ?? screenshotEvent.ts;
88
- }
89
47
  export function data() {
90
48
  return {
91
49
  legacySyntheticScreenshots: syntheticScreenshots.length ? syntheticScreenshots : null,
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenshotsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/ScreenshotsHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAI3C,qFAAqF;AACrF,qEAAqE;AACrE,IAAI,mBAAmB,GAAoC,EAAE,CAAC;AAE9D,IAAI,sBAAsB,GAAoC,EAAE,CAAC;AACjE,I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AC,EAAE,CAAC;IAC5B,CAAC;IACD,4FAA4F;IAC5F,gHAAgH;IAChH,kDAAkD;IAClD,MAAM,SAAS,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACnD,mCAAmC;IACnC,8EAA8E;IAC9E,sHAAsH;IACtH,qCAAqC;IACrC,6HAA6H;IAC7H,OAAO,SAAS,IAAI,eAAe,CAAC,EAAE,CAAC;AACzC,CAAC;AAcD,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,0BAA0B,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI;QACrF,WAAW,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI;KAC3E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,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\nimport type {HandlerName} from './types.js';\n\n// Each thread contains events. Events indicate the thread and process IDs, which are\n// used to store the event in the correct process thread entry below.\nlet unpairedAsyncEvents: Types.Events.PipelineReporter[] = [];\n\nlet legacyScreenshotEvents: Types.Events.LegacyScreenshot[] = [];\nlet modernScreenshotEvents: Types.Events.Screenshot[] = [];\nlet syntheticScreenshots: Types.Events.LegacySyntheticScreenshot[] = [];\nlet frameSequenceToTs: Record<string, Types.Timing.Micro> = {};\n\nexport function reset(): void {\n unpairedAsyncEvents = [];\n legacyScreenshotEvents = [];\n syntheticScreenshots = [];\n modernScreenshotEvents = [];\n frameSequenceToTs = {};\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (Types.Events.isLegacyScreenshot(event)) {\n legacyScreenshotEvents.push(event);\n } else if (Types.Events.isScreenshot(event)) {\n modernScreenshotEvents.push(event);\n } else if (Types.Events.isPipelineReporter(event)) {\n unpairedAsyncEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n const pipelineReporterEvents = Helpers.Trace.createMatchedSortedSyntheticEvents(unpairedAsyncEvents);\n\n frameSequenceToTs = Object.fromEntries(pipelineReporterEvents.map(evt => {\n const args = evt.args.data.beginEvent.args;\n const frameReporter = 'frame_reporter' in args ? args.frame_reporter : args.chrome_frame_reporter;\n const frameSequenceId = frameReporter.frame_sequence;\n const presentationTs = Types.Timing.Micro(evt.ts + evt.dur);\n return [frameSequenceId, presentationTs];\n }));\n\n for (const snapshotEvent of legacyScreenshotEvents) {\n const {cat, name, ph, pid, tid} = snapshotEvent;\n const syntheticEvent = Helpers.SyntheticEvents.SyntheticEventsManager.registerSyntheticEvent<\n Types.Events.LegacySyntheticScreenshot>({\n rawSourceEvent: snapshotEvent,\n cat,\n name,\n ph,\n pid,\n tid,\n // TODO(paulirish, crbug.com/41363012): investigate why getPresentationTimestamp(snapshotEvent) seems less accurate. Resolve screenshot timing inaccuracy.\n // `getPresentationTimestamp(snapshotEvent) - snapshotEvent.ts` is how many microsec the screenshot should be adjusted to the right/later\n ts: snapshotEvent.ts,\n args: {\n dataUri: `data:image/jpg;base64,${snapshotEvent.args.snapshot}`,\n },\n });\n syntheticScreenshots.push(syntheticEvent);\n }\n}\n\nexport function screenshotImageDataUri(event: Types.Events.LegacySyntheticScreenshot|Types.Events.Screenshot): string {\n if (Types.Events.isLegacySyntheticScreenshot(event)) {\n return event.args.dataUri;\n }\n return `data:image/jpg;base64,${event.args.snapshot}`;\n}\n\n/**\n * Correct the screenshot timestamps\n * The screenshot 'snapshot object' trace event has the \"frame sequence number\" attached as an ID.\n * We match that up with the \"PipelineReporter\" trace events as they terminate at presentation.\n * Presentation == when the pixels hit the screen. AKA Swap on the GPU\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction getPresentationTimestamp(screenshotEvent: Types.Events.LegacyScreenshot): Types.Timing.Micro {\n const frameSequence = parseInt(screenshotEvent.id, 16);\n // If it's 1, then it's an old trace (before https://crrev.com/c/4957973) and cannot be corrected.\n if (frameSequence === 1) {\n return screenshotEvent.ts;\n }\n // The screenshot trace event's `ts` reflects the \"expected display time\" which is ESTIMATE.\n // It is set by the compositor frame sink from the `expected_display_time`, which is based on a previously known\n // frame start PLUS the vsync interval (eg 16.6ms)\n const updatedTs = frameSequenceToTs[frameSequence];\n // Do we always find a match? No...\n // We generally don't match the very first screenshot and, sometimes, the last\n // The very first screenshot is requested immediately (even if nothing is painting). As a result there's no compositor\n // instrumentation running alongside.\n // The last one is sometimes missing as because the trace terminates right before the associated PipelineReporter is emitted.\n return updatedTs ?? screenshotEvent.ts;\n}\n\nexport interface Data {\n // These are nullable because in January 2025 a CL in Chromium\n // crrev.com/c/6197645 landed which changed the format of screenshots. For a\n // given trace, it can have either \"legacy\" screenshot events, or \"modern\"\n // screenshot events, but no trace can ever contain both.\n // So, if either of these arrays are empty, we instead return `null`. This forces consumers to check the presence of the array.\n // Traces can have no screenshots if the trace category is not enabled, so it\n // is possible for a trace to return null for both of these arrays.\n legacySyntheticScreenshots: Types.Events.LegacySyntheticScreenshot[]|null;\n screenshots: Types.Events.Screenshot[]|null;\n}\n\nexport function data(): Data {\n return {\n legacySyntheticScreenshots: syntheticScreenshots.length ? syntheticScreenshots : null,\n screenshots: modernScreenshotEvents.length ? modernScreenshotEvents : null,\n };\n}\n\nexport function deps(): HandlerName[] {\n return ['Meta'];\n}\n"]}
1
+ {"version":3,"file":"ScreenshotsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/ScreenshotsHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAI3C,IAAI,sBAAsB,GAAoC,EAAE,CAAC;AACjE,IAAI,sBAAsB,GAA8B,E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C,OAAO,CAAC;IAC5B,CAAC;IACD,OAAO,yBAAyB,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AACxD,CAAC;AAcD,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,0BAA0B,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI;QACrF,WAAW,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI;KAC3E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,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\nimport type {HandlerName} from './types.js';\n\nlet legacyScreenshotEvents: Types.Events.LegacyScreenshot[] = [];\nlet modernScreenshotEvents: Types.Events.Screenshot[] = [];\nlet syntheticScreenshots: Types.Events.LegacySyntheticScreenshot[] = [];\n\nexport function reset(): void {\n legacyScreenshotEvents = [];\n syntheticScreenshots = [];\n modernScreenshotEvents = [];\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (Types.Events.isLegacyScreenshot(event)) {\n legacyScreenshotEvents.push(event);\n } else if (Types.Events.isScreenshot(event)) {\n modernScreenshotEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n for (const snapshotEvent of legacyScreenshotEvents) {\n const {cat, name, ph, pid, tid} = snapshotEvent;\n const syntheticEvent =\n Helpers.SyntheticEvents.SyntheticEventsManager.registerSyntheticEvent<Types.Events.LegacySyntheticScreenshot>({\n rawSourceEvent: snapshotEvent,\n cat,\n name,\n ph,\n pid,\n tid,\n // TODO(paulirish, crbug.com/41363012): fix snapshot timestamps.\n ts: snapshotEvent.ts,\n args: {\n dataUri: `data:image/jpg;base64,${snapshotEvent.args.snapshot}`,\n },\n });\n syntheticScreenshots.push(syntheticEvent);\n }\n}\n\nexport function screenshotImageDataUri(event: Types.Events.LegacySyntheticScreenshot|Types.Events.Screenshot): string {\n if (Types.Events.isLegacySyntheticScreenshot(event)) {\n return event.args.dataUri;\n }\n return `data:image/jpg;base64,${event.args.snapshot}`;\n}\n\nexport interface Data {\n // These are nullable because in January 2025 a CL in Chromium\n // crrev.com/c/6197645 landed which changed the format of screenshots. For a\n // given trace, it can have either \"legacy\" screenshot events, or \"modern\"\n // screenshot events, but no trace can ever contain both.\n // So, if either of these arrays are empty, we instead return `null`. This forces consumers to check the presence of the array.\n // Traces can have no screenshots if the trace category is not enabled, so it\n // is possible for a trace to return null for both of these arrays.\n legacySyntheticScreenshots: Types.Events.LegacySyntheticScreenshot[]|null;\n screenshots: Types.Events.Screenshot[]|null;\n}\n\nexport function data(): Data {\n return {\n legacySyntheticScreenshots: syntheticScreenshots.length ? syntheticScreenshots : null,\n screenshots: modernScreenshotEvents.length ? modernScreenshotEvents : null,\n };\n}\n\nexport function deps(): HandlerName[] {\n return ['Meta'];\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import type * as Helpers from '../helpers/helpers.js';
2
2
  import type * as Types from '../types/types.js';
3
- import type { AuctionWorkletsData } from './AuctionWorkletsHandler.js';
4
3
  import type * as Renderer from './RendererHandler.js';
5
4
  import type { HandlerData } from './types.js';
6
5
  export interface ThreadData {
@@ -17,12 +16,11 @@ export declare enum ThreadType {
17
16
  MAIN_THREAD = "MAIN_THREAD",
18
17
  WORKER = "WORKER",
19
18
  RASTERIZER = "RASTERIZER",
20
- AUCTION_WORKLET = "AUCTION_WORKLET",
21
19
  OTHER = "OTHER",
22
20
  CPU_PROFILE = "CPU_PROFILE",
23
21
  THREAD_POOL = "THREAD_POOL"
24
22
  }
25
- export declare function threadsInRenderer(rendererData: Renderer.RendererHandlerData, auctionWorkletsData: AuctionWorkletsData): readonly ThreadData[];
23
+ export declare function threadsInRenderer(rendererData: Renderer.RendererHandlerData): readonly ThreadData[];
26
24
  /**
27
25
  * Given trace parsed data, this helper will return a high level array of
28
26
  * ThreadData. This is useful because it allows you to get a list of threads
@@ -3,12 +3,11 @@ export var ThreadType;
3
3
  ThreadType["MAIN_THREAD"] = "MAIN_THREAD";
4
4
  ThreadType["WORKER"] = "WORKER";
5
5
  ThreadType["RASTERIZER"] = "RASTERIZER";
6
- ThreadType["AUCTION_WORKLET"] = "AUCTION_WORKLET";
7
6
  ThreadType["OTHER"] = "OTHER";
8
7
  ThreadType["CPU_PROFILE"] = "CPU_PROFILE";
9
8
  ThreadType["THREAD_POOL"] = "THREAD_POOL";
10
9
  })(ThreadType || (ThreadType = {}));
11
- function getThreadTypeForRendererThread(pid, thread, auctionWorkletsData) {
10
+ function getThreadTypeForRendererThread(pid, thread) {
12
11
  let threadType = ThreadType.OTHER;
13
12
  if (thread.name === 'CrRendererMain') {
14
13
  threadType = ThreadType.MAIN_THREAD;
@@ -19,16 +18,13 @@ function getThreadTypeForRendererThread(pid, thread, auctionWorkletsData) {
19
18
  else if (thread.name?.startsWith('CompositorTileWorker')) {
20
19
  threadType = ThreadType.RASTERIZER;
21
20
  }
22
- else if (auctionWorkletsData.worklets.has(pid)) {
23
- threadType = ThreadType.AUCTION_WORKLET;
24
- }
25
21
  else if (thread.name?.startsWith('ThreadPool')) {
26
22
  // TODO(paulirish): perhaps exclude ThreadPoolServiceThread entirely
27
23
  threadType = ThreadType.THREAD_POOL;
28
24
  }
29
25
  return threadType;
30
26
  }
31
- export function threadsInRenderer(rendererData, auctionWorkletsData) {
27
+ export function threadsInRenderer(rendererData) {
32
28
  const foundThreads = [];
33
29
  // If we have Renderer threads, we prefer to use those. In the event that a
34
30
  // trace is a CPU Profile trace, we will never have Renderer threads, so we
@@ -43,7 +39,7 @@ export function threadsInRenderer(rendererData, auctionWorkletsData) {
43
39
  // filtering we need.
44
40
  continue;
45
41
  }
46
- const threadType = getThreadTypeForRendererThread(pid, thread, auctionWorkletsData);
42
+ const threadType = getThreadTypeForRendererThread(pid, thread);
47
43
  foundThreads.push({
48
44
  name: thread.name,
49
45
  pid,
@@ -74,7 +70,7 @@ export function threadsInTrace(handlerData) {
74
70
  return cached;
75
71
  }
76
72
  // If we have Renderer threads, we prefer to use those.
77
- const threadsFromRenderer = threadsInRenderer(handlerData.Renderer, handlerData.AuctionWorklets);
73
+ const threadsFromRenderer = threadsInRenderer(handlerData.Renderer);
78
74
  if (threadsFromRenderer.length) {
79
75
  threadsInHandlerDataCache.set(handlerData, threadsFromRenderer);
80
76
  return threadsFromRenderer;
@@ -1 +1 @@
1
- {"version":3,"file":"Threads.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/Threads.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,yCAA2B,CAAA;IAC3B,+BAAiB,CAAA;IACjB,uCAAyB,CAAA;IACzB,iDAAmC,CAAA;IACnC,6BAAe,CAAA;IACf,yCAA2B,CAAA;IAC3B,yCAA2B,CAAA;AAC7B,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB;AAED,SAAS,8BAA8B,CACnC,GAA2B,EAAE,MAA+B,EAC5D,mBAAwC;IAC1C,IAAI,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;IAClC,IAAI,MAAM,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC;IACtC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,wBAAwB,EAAE,CAAC;QACpD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;IACjC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC3D,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;IACrC,CAAC;SAAM,IAAI,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,UAAU,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C,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACzD,OAAO,YAAY,CAAC;AACtB,CAAC","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 Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport type {AuctionWorkletsData} from './AuctionWorkletsHandler.js';\nimport type * as Renderer from './RendererHandler.js';\nimport type {HandlerData} from './types.js';\n\nexport interface ThreadData {\n pid: Types.Events.ProcessID;\n tid: Types.Events.ThreadID;\n entries: readonly Types.Events.Event[];\n processIsOnMainFrame: boolean;\n tree: Helpers.TreeHelpers.TraceEntryTree;\n type: ThreadType;\n name: string|null;\n entryToNode: Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>;\n}\n\nexport enum ThreadType {\n MAIN_THREAD = 'MAIN_THREAD',\n WORKER = 'WORKER',\n RASTERIZER = 'RASTERIZER',\n AUCTION_WORKLET = 'AUCTION_WORKLET',\n OTHER = 'OTHER',\n CPU_PROFILE = 'CPU_PROFILE',\n THREAD_POOL = 'THREAD_POOL',\n}\n\nfunction getThreadTypeForRendererThread(\n pid: Types.Events.ProcessID, thread: Renderer.RendererThread,\n auctionWorkletsData: AuctionWorkletsData): ThreadType {\n let threadType = ThreadType.OTHER;\n if (thread.name === 'CrRendererMain') {\n threadType = ThreadType.MAIN_THREAD;\n } else if (thread.name === 'DedicatedWorker thread') {\n threadType = ThreadType.WORKER;\n } else if (thread.name?.startsWith('CompositorTileWorker')) {\n threadType = ThreadType.RASTERIZER;\n } else if (auctionWorkletsData.worklets.has(pid)) {\n threadType = ThreadType.AUCTION_WORKLET;\n } else if (thread.name?.startsWith('ThreadPool')) {\n // TODO(paulirish): perhaps exclude ThreadPoolServiceThread entirely\n threadType = ThreadType.THREAD_POOL;\n }\n return threadType;\n}\n\nexport function threadsInRenderer(\n rendererData: Renderer.RendererHandlerData, auctionWorkletsData: AuctionWorkletsData): readonly ThreadData[] {\n const foundThreads: ThreadData[] = [];\n // If we have Renderer threads, we prefer to use those. In the event that a\n // trace is a CPU Profile trace, we will never have Renderer threads, so we\n // know if there are no Renderer threads that we can fallback to using the\n // data from the SamplesHandler.\n if (rendererData.processes.size) {\n for (const [pid, process] of rendererData.processes) {\n for (const [tid, thread] of process.threads) {\n if (!thread.tree) {\n // Drop threads where we could not create the tree; this indicates\n // unexpected data and we won't be able to support all the UI\n // filtering we need.\n continue;\n }\n const threadType = getThreadTypeForRendererThread(pid, thread, auctionWorkletsData);\n foundThreads.push({\n name: thread.name,\n pid,\n tid,\n processIsOnMainFrame: process.isOnMainFrame,\n entries: thread.entries,\n tree: thread.tree,\n type: threadType,\n entryToNode: rendererData.entryToNode,\n });\n }\n }\n }\n return foundThreads;\n}\n\nconst threadsInHandlerDataCache = new WeakMap<HandlerData, readonly ThreadData[]>();\n\n/**\n * Given trace parsed data, this helper will return a high level array of\n * ThreadData. This is useful because it allows you to get a list of threads\n * regardless of if the trace is a CPU Profile or a Tracing profile. Thus you\n * can use this helper to iterate over threads in confidence that it will work\n * for both trace types.\n * The resulting data is cached per-trace, so you can safely call this multiple times.\n */\nexport function threadsInTrace(handlerData: HandlerData): readonly ThreadData[] {\n const cached = threadsInHandlerDataCache.get(handlerData);\n if (cached) {\n return cached;\n }\n\n // If we have Renderer threads, we prefer to use those.\n const threadsFromRenderer = threadsInRenderer(handlerData.Renderer, handlerData.AuctionWorklets);\n if (threadsFromRenderer.length) {\n threadsInHandlerDataCache.set(handlerData, threadsFromRenderer);\n return threadsFromRenderer;\n }\n\n // If it's a CPU Profile trace, there will be no Renderer threads.\n // We can fallback to using the data from the SamplesHandler.\n const foundThreads: ThreadData[] = [];\n if (handlerData.Samples.profilesInProcess.size) {\n for (const [pid, process] of handlerData.Samples.profilesInProcess) {\n for (const [tid, thread] of process) {\n if (!thread.profileTree) {\n // Drop threads where we could not create the tree; this indicates\n // unexpected data and we won't be able to support all the UI\n // filtering we need.\n continue;\n }\n\n foundThreads.push({\n pid,\n tid,\n // CPU Profile threads do not have a name.\n name: null,\n entries: thread.profileCalls,\n // There is no concept of a \"Main Frame\" in a CPU profile.\n processIsOnMainFrame: false,\n tree: thread.profileTree,\n type: ThreadType.CPU_PROFILE,\n entryToNode: handlerData.Samples.entryToNode,\n });\n }\n }\n }\n\n threadsInHandlerDataCache.set(handlerData, foundThreads);\n return foundThreads;\n}\n"]}
1
+ {"version":3,"file":"Threads.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/Threads.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,yCAA2B,CAAA;IAC3B,+BAAiB,CAAA;IACjB,uCAAyB,CAAA;IACzB,6BAAe,CAAA;IACf,yCAA2B,CAAA;IAC3B,yCAA2B,CAAA;AAC7B,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB;AAED,SAAS,8BAA8B,CAAC,GAA2B,EAAE,MAA+B;IAClG,IAAI,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;IAClC,IAAI,MAAM,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC;IACtC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,wBAAwB,EAAE,CAAC;QACpD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;IACjC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC3D,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;IACrC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjD,oEAAoE;QACpE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC;IACtC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,YAA0C;IAC1E,MA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AC;QAC/B,yBAAyB,CAAC,GAAG,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;QAChE,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,kEAAkE;IAClE,6DAA6D;IAC7D,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,IAAI,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAC/C,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;YACnE,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;gBACpC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;oBACxB,kEAAkE;oBAClE,6DAA6D;oBAC7D,qBAAqB;oBACrB,SAAS;gBACX,CAAC;gBAED,YAAY,CAAC,IAAI,CAAC;oBAChB,GAAG;oBACH,GAAG;oBACH,0CAA0C;oBAC1C,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,MAAM,CAAC,YAAY;oBAC5B,0DAA0D;oBAC1D,oBAAoB,EAAE,KAAK;oBAC3B,IAAI,EAAE,MAAM,CAAC,WAAW;oBACxB,IAAI,EAAE,UAAU,CAAC,WAAW;oBAC5B,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,WAAW;iBAC7C,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,yBAAyB,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACzD,OAAO,YAAY,CAAC;AACtB,CAAC","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 Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport type * as Renderer from './RendererHandler.js';\nimport type {HandlerData} from './types.js';\n\nexport interface ThreadData {\n pid: Types.Events.ProcessID;\n tid: Types.Events.ThreadID;\n entries: readonly Types.Events.Event[];\n processIsOnMainFrame: boolean;\n tree: Helpers.TreeHelpers.TraceEntryTree;\n type: ThreadType;\n name: string|null;\n entryToNode: Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>;\n}\n\nexport enum ThreadType {\n MAIN_THREAD = 'MAIN_THREAD',\n WORKER = 'WORKER',\n RASTERIZER = 'RASTERIZER',\n OTHER = 'OTHER',\n CPU_PROFILE = 'CPU_PROFILE',\n THREAD_POOL = 'THREAD_POOL',\n}\n\nfunction getThreadTypeForRendererThread(pid: Types.Events.ProcessID, thread: Renderer.RendererThread): ThreadType {\n let threadType = ThreadType.OTHER;\n if (thread.name === 'CrRendererMain') {\n threadType = ThreadType.MAIN_THREAD;\n } else if (thread.name === 'DedicatedWorker thread') {\n threadType = ThreadType.WORKER;\n } else if (thread.name?.startsWith('CompositorTileWorker')) {\n threadType = ThreadType.RASTERIZER;\n } else if (thread.name?.startsWith('ThreadPool')) {\n // TODO(paulirish): perhaps exclude ThreadPoolServiceThread entirely\n threadType = ThreadType.THREAD_POOL;\n }\n return threadType;\n}\n\nexport function threadsInRenderer(rendererData: Renderer.RendererHandlerData): readonly ThreadData[] {\n const foundThreads: ThreadData[] = [];\n // If we have Renderer threads, we prefer to use those. In the event that a\n // trace is a CPU Profile trace, we will never have Renderer threads, so we\n // know if there are no Renderer threads that we can fallback to using the\n // data from the SamplesHandler.\n if (rendererData.processes.size) {\n for (const [pid, process] of rendererData.processes) {\n for (const [tid, thread] of process.threads) {\n if (!thread.tree) {\n // Drop threads where we could not create the tree; this indicates\n // unexpected data and we won't be able to support all the UI\n // filtering we need.\n continue;\n }\n const threadType = getThreadTypeForRendererThread(pid, thread);\n foundThreads.push({\n name: thread.name,\n pid,\n tid,\n processIsOnMainFrame: process.isOnMainFrame,\n entries: thread.entries,\n tree: thread.tree,\n type: threadType,\n entryToNode: rendererData.entryToNode,\n });\n }\n }\n }\n return foundThreads;\n}\n\nconst threadsInHandlerDataCache = new WeakMap<HandlerData, readonly ThreadData[]>();\n\n/**\n * Given trace parsed data, this helper will return a high level array of\n * ThreadData. This is useful because it allows you to get a list of threads\n * regardless of if the trace is a CPU Profile or a Tracing profile. Thus you\n * can use this helper to iterate over threads in confidence that it will work\n * for both trace types.\n * The resulting data is cached per-trace, so you can safely call this multiple times.\n */\nexport function threadsInTrace(handlerData: HandlerData): readonly ThreadData[] {\n const cached = threadsInHandlerDataCache.get(handlerData);\n if (cached) {\n return cached;\n }\n\n // If we have Renderer threads, we prefer to use those.\n const threadsFromRenderer = threadsInRenderer(handlerData.Renderer);\n if (threadsFromRenderer.length) {\n threadsInHandlerDataCache.set(handlerData, threadsFromRenderer);\n return threadsFromRenderer;\n }\n\n // If it's a CPU Profile trace, there will be no Renderer threads.\n // We can fallback to using the data from the SamplesHandler.\n const foundThreads: ThreadData[] = [];\n if (handlerData.Samples.profilesInProcess.size) {\n for (const [pid, process] of handlerData.Samples.profilesInProcess) {\n for (const [tid, thread] of process) {\n if (!thread.profileTree) {\n // Drop threads where we could not create the tree; this indicates\n // unexpected data and we won't be able to support all the UI\n // filtering we need.\n continue;\n }\n\n foundThreads.push({\n pid,\n tid,\n // CPU Profile threads do not have a name.\n name: null,\n entries: thread.profileCalls,\n // There is no concept of a \"Main Frame\" in a CPU profile.\n processIsOnMainFrame: false,\n tree: thread.profileTree,\n type: ThreadType.CPU_PROFILE,\n entryToNode: handlerData.Samples.entryToNode,\n });\n }\n }\n }\n\n threadsInHandlerDataCache.set(handlerData, foundThreads);\n return foundThreads;\n}\n"]}