@paulirish/trace_engine 0.0.58 → 0.0.60

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 (450) hide show
  1. package/.tmp/tsbuildinfo/analyze-trace.d.mts +2 -3
  2. package/.tmp/tsbuildinfo/analyze-trace.d.mts.map +1 -1
  3. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  4. package/LICENSE +1 -1
  5. package/README.md +28 -1
  6. package/analyze-trace.mjs +5 -3
  7. package/core/platform/ArrayUtilities.d.ts +1 -0
  8. package/core/platform/ArrayUtilities.js +2 -2
  9. package/core/platform/ArrayUtilities.js.map +1 -1
  10. package/core/platform/Brand.js +1 -1
  11. package/core/platform/Brand.js.map +1 -1
  12. package/core/platform/Constructor.js +1 -1
  13. package/core/platform/Constructor.js.map +1 -1
  14. package/core/platform/DOMUtilities.js +1 -1
  15. package/core/platform/DOMUtilities.js.map +1 -1
  16. package/core/platform/DateUtilities.js +1 -1
  17. package/core/platform/DateUtilities.js.map +1 -1
  18. package/core/platform/DevToolsPath.js +1 -1
  19. package/core/platform/DevToolsPath.js.map +1 -1
  20. package/core/platform/KeyboardUtilities.js +1 -1
  21. package/core/platform/KeyboardUtilities.js.map +1 -1
  22. package/core/platform/MapUtilities.js +1 -1
  23. package/core/platform/MapUtilities.js.map +1 -1
  24. package/core/platform/MimeType.js +1 -1
  25. package/core/platform/MimeType.js.map +1 -1
  26. package/core/platform/NumberUtilities.js +1 -1
  27. package/core/platform/NumberUtilities.js.map +1 -1
  28. package/core/platform/StringUtilities.d.ts +2 -1
  29. package/core/platform/StringUtilities.js +34 -32
  30. package/core/platform/StringUtilities.js.map +1 -1
  31. package/core/platform/Timing.js +1 -1
  32. package/core/platform/Timing.js.map +1 -1
  33. package/core/platform/TypedArrayUtilities.js +1 -1
  34. package/core/platform/TypedArrayUtilities.js.map +1 -1
  35. package/core/platform/TypescriptUtilities.js +1 -1
  36. package/core/platform/TypescriptUtilities.js.map +1 -1
  37. package/core/platform/UIString.js +1 -1
  38. package/core/platform/UIString.js.map +1 -1
  39. package/core/platform/UserVisibleError.js +1 -1
  40. package/core/platform/UserVisibleError.js.map +1 -1
  41. package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  42. package/core/platform/platform-tsconfig.json +6 -2
  43. package/core/platform/platform.js +3 -29
  44. package/core/platform/platform.js.map +1 -1
  45. package/generated/protocol.d.ts +224 -14
  46. package/generated/protocol.js +1 -1
  47. package/locales/af.json +0 -9
  48. package/locales/am.json +0 -9
  49. package/locales/ar.json +0 -9
  50. package/locales/as.json +0 -9
  51. package/locales/az.json +0 -9
  52. package/locales/be.json +0 -9
  53. package/locales/bg.json +0 -9
  54. package/locales/bn.json +1 -10
  55. package/locales/bs.json +0 -9
  56. package/locales/ca.json +0 -9
  57. package/locales/cs.json +0 -9
  58. package/locales/cy.json +0 -9
  59. package/locales/da.json +0 -9
  60. package/locales/de.json +0 -9
  61. package/locales/el.json +0 -9
  62. package/locales/en-GB.json +0 -9
  63. package/locales/en-US.json +8 -8
  64. package/locales/en-XL.json +8 -8
  65. package/locales/es-419.json +0 -9
  66. package/locales/es.json +0 -9
  67. package/locales/et.json +0 -9
  68. package/locales/eu.json +0 -9
  69. package/locales/fa.json +0 -9
  70. package/locales/fi.json +0 -9
  71. package/locales/fil.json +0 -9
  72. package/locales/fr-CA.json +0 -9
  73. package/locales/fr.json +0 -9
  74. package/locales/gl.json +0 -9
  75. package/locales/gu.json +0 -9
  76. package/locales/he.json +0 -9
  77. package/locales/hi.json +0 -9
  78. package/locales/hr.json +4 -13
  79. package/locales/hu.json +0 -9
  80. package/locales/hy.json +0 -9
  81. package/locales/id.json +0 -9
  82. package/locales/is.json +0 -9
  83. package/locales/it.json +0 -9
  84. package/locales/ja.json +0 -9
  85. package/locales/ka.json +0 -9
  86. package/locales/kk.json +0 -9
  87. package/locales/km.json +0 -9
  88. package/locales/kn.json +0 -9
  89. package/locales/ko.json +0 -9
  90. package/locales/ky.json +0 -9
  91. package/locales/lo.json +0 -9
  92. package/locales/lt.json +0 -9
  93. package/locales/lv.json +0 -9
  94. package/locales/mk.json +0 -9
  95. package/locales/ml.json +0 -9
  96. package/locales/mn.json +0 -9
  97. package/locales/mr.json +0 -9
  98. package/locales/ms.json +0 -9
  99. package/locales/my.json +1 -10
  100. package/locales/ne.json +22 -31
  101. package/locales/nl.json +0 -9
  102. package/locales/no.json +0 -9
  103. package/locales/or.json +0 -9
  104. package/locales/pa.json +0 -9
  105. package/locales/pl.json +0 -9
  106. package/locales/pt-PT.json +0 -9
  107. package/locales/pt.json +0 -9
  108. package/locales/ro.json +0 -9
  109. package/locales/ru.json +0 -9
  110. package/locales/si.json +1 -10
  111. package/locales/sk.json +0 -9
  112. package/locales/sl.json +0 -9
  113. package/locales/sq.json +0 -9
  114. package/locales/sr-Latn.json +0 -9
  115. package/locales/sr.json +0 -9
  116. package/locales/sv.json +0 -9
  117. package/locales/sw.json +0 -9
  118. package/locales/ta.json +0 -9
  119. package/locales/te.json +0 -9
  120. package/locales/th.json +0 -9
  121. package/locales/tr.json +0 -9
  122. package/locales/uk.json +0 -9
  123. package/locales/ur.json +0 -9
  124. package/locales/uz.json +0 -9
  125. package/locales/vi.json +0 -9
  126. package/locales/zh-HK.json +0 -9
  127. package/locales/zh-TW.json +0 -9
  128. package/locales/zh.json +0 -9
  129. package/locales/zu.json +0 -9
  130. package/models/cpu_profile/CPUProfileDataModel.d.ts +1 -0
  131. package/models/cpu_profile/CPUProfileDataModel.js +1 -1
  132. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
  133. package/models/cpu_profile/ProfileTreeModel.d.ts +1 -1
  134. package/models/cpu_profile/ProfileTreeModel.js +1 -1
  135. package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
  136. package/models/cpu_profile/cpu_profile-tsconfig.json +6 -2
  137. package/models/cpu_profile/cpu_profile.js +1 -1
  138. package/models/cpu_profile/cpu_profile.js.map +1 -1
  139. package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  140. package/models/trace/EntityMapper.d.ts +33 -0
  141. package/models/trace/EntityMapper.js +123 -0
  142. package/models/trace/EntityMapper.js.map +1 -0
  143. package/models/trace/EventsSerializer.d.ts +11 -0
  144. package/models/trace/EventsSerializer.js +82 -0
  145. package/models/trace/EventsSerializer.js.map +1 -0
  146. package/models/trace/LanternComputationData.d.ts +3 -3
  147. package/models/trace/LanternComputationData.js +12 -10
  148. package/models/trace/LanternComputationData.js.map +1 -1
  149. package/models/trace/ModelImpl.d.ts +7 -14
  150. package/models/trace/ModelImpl.js +25 -52
  151. package/models/trace/ModelImpl.js.map +1 -1
  152. package/models/trace/Name.d.ts +12 -0
  153. package/models/trace/Name.js +115 -0
  154. package/models/trace/Name.js.map +1 -0
  155. package/models/trace/Processor.d.ts +1 -1
  156. package/models/trace/Processor.js +42 -61
  157. package/models/trace/Processor.js.map +1 -1
  158. package/models/trace/Styles.d.ts +50 -0
  159. package/models/trace/Styles.js +816 -0
  160. package/models/trace/Styles.js.map +1 -0
  161. package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  162. package/models/trace/extras/FilmStrip.d.ts +1 -1
  163. package/models/trace/extras/FilmStrip.js +7 -7
  164. package/models/trace/extras/FilmStrip.js.map +1 -1
  165. package/models/trace/extras/MainThreadActivity.js +1 -1
  166. package/models/trace/extras/MainThreadActivity.js.map +1 -1
  167. package/models/trace/extras/ScriptDuplication.js +1 -1
  168. package/models/trace/extras/ScriptDuplication.js.map +1 -1
  169. package/models/trace/extras/StackTraceForEvent.d.ts +2 -2
  170. package/models/trace/extras/StackTraceForEvent.js +21 -21
  171. package/models/trace/extras/StackTraceForEvent.js.map +1 -1
  172. package/models/trace/extras/ThirdParties.d.ts +2 -2
  173. package/models/trace/extras/ThirdParties.js +17 -17
  174. package/models/trace/extras/ThirdParties.js.map +1 -1
  175. package/models/trace/extras/TraceFilter.d.ts +1 -1
  176. package/models/trace/extras/TraceFilter.js +1 -1
  177. package/models/trace/extras/TraceFilter.js.map +1 -1
  178. package/models/trace/extras/TraceTree.d.ts +1 -0
  179. package/models/trace/extras/TraceTree.js +2 -2
  180. package/models/trace/extras/TraceTree.js.map +1 -1
  181. package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  182. package/models/trace/extras/extras-tsconfig.json +6 -2
  183. package/models/trace/extras/extras.js.map +1 -1
  184. package/models/trace/handlers/AnimationFramesHandler.js +11 -11
  185. package/models/trace/handlers/AnimationFramesHandler.js.map +1 -1
  186. package/models/trace/handlers/AnimationHandler.js +5 -5
  187. package/models/trace/handlers/AnimationHandler.js.map +1 -1
  188. package/models/trace/handlers/AsyncJSCallsHandler.d.ts +3 -3
  189. package/models/trace/handlers/AsyncJSCallsHandler.js +9 -9
  190. package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -1
  191. package/models/trace/handlers/AuctionWorkletsHandler.js +12 -12
  192. package/models/trace/handlers/AuctionWorkletsHandler.js.map +1 -1
  193. package/models/trace/handlers/DOMStatsHandler.js +3 -3
  194. package/models/trace/handlers/DOMStatsHandler.js.map +1 -1
  195. package/models/trace/handlers/ExtensionTraceDataHandler.d.ts +15 -2
  196. package/models/trace/handlers/ExtensionTraceDataHandler.js +53 -64
  197. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
  198. package/models/trace/handlers/FlowsHandler.js +11 -11
  199. package/models/trace/handlers/FlowsHandler.js.map +1 -1
  200. package/models/trace/handlers/FramesHandler.d.ts +7 -0
  201. package/models/trace/handlers/FramesHandler.js +12 -10
  202. package/models/trace/handlers/FramesHandler.js.map +1 -1
  203. package/models/trace/handlers/GPUHandler.js +3 -3
  204. package/models/trace/handlers/GPUHandler.js.map +1 -1
  205. package/models/trace/handlers/ImagePaintingHandler.js +13 -13
  206. package/models/trace/handlers/ImagePaintingHandler.js.map +1 -1
  207. package/models/trace/handlers/InitiatorsHandler.js +32 -41
  208. package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
  209. package/models/trace/handlers/InvalidationsHandler.js +63 -44
  210. package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
  211. package/models/trace/handlers/LargestImagePaintHandler.js +5 -4
  212. package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -1
  213. package/models/trace/handlers/LargestTextPaintHandler.js +3 -3
  214. package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -1
  215. package/models/trace/handlers/LayerTreeHandler.js +11 -11
  216. package/models/trace/handlers/LayerTreeHandler.js.map +1 -1
  217. package/models/trace/handlers/LayoutShiftsHandler.d.ts +17 -4
  218. package/models/trace/handlers/LayoutShiftsHandler.js +47 -40
  219. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  220. package/models/trace/handlers/MemoryHandler.js +3 -3
  221. package/models/trace/handlers/MemoryHandler.js.map +1 -1
  222. package/models/trace/handlers/MetaHandler.d.ts +22 -1
  223. package/models/trace/handlers/MetaHandler.js +30 -29
  224. package/models/trace/handlers/MetaHandler.js.map +1 -1
  225. package/models/trace/handlers/ModelHandlers.js +1 -1
  226. package/models/trace/handlers/ModelHandlers.js.map +1 -1
  227. package/models/trace/handlers/NetworkRequestsHandler.d.ts +10 -0
  228. package/models/trace/handlers/NetworkRequestsHandler.js +44 -25
  229. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  230. package/models/trace/handlers/PageFramesHandler.js +3 -3
  231. package/models/trace/handlers/PageFramesHandler.js.map +1 -1
  232. package/models/trace/handlers/PageLoadMetricsHandler.js +5 -5
  233. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
  234. package/models/trace/handlers/RendererHandler.d.ts +1 -1
  235. package/models/trace/handlers/RendererHandler.js +22 -22
  236. package/models/trace/handlers/RendererHandler.js.map +1 -1
  237. package/models/trace/handlers/SamplesHandler.d.ts +2 -2
  238. package/models/trace/handlers/SamplesHandler.js +7 -9
  239. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  240. package/models/trace/handlers/ScreenshotsHandler.js +9 -10
  241. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -1
  242. package/models/trace/handlers/ScriptsHandler.js +9 -8
  243. package/models/trace/handlers/ScriptsHandler.js.map +1 -1
  244. package/models/trace/handlers/SelectorStatsHandler.d.ts +2 -2
  245. package/models/trace/handlers/SelectorStatsHandler.js +13 -13
  246. package/models/trace/handlers/SelectorStatsHandler.js.map +1 -1
  247. package/models/trace/handlers/Threads.d.ts +2 -2
  248. package/models/trace/handlers/Threads.js +9 -9
  249. package/models/trace/handlers/Threads.js.map +1 -1
  250. package/models/trace/handlers/UserInteractionsHandler.d.ts +10 -3
  251. package/models/trace/handlers/UserInteractionsHandler.js +104 -84
  252. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -1
  253. package/models/trace/handlers/UserTimingsHandler.d.ts +21 -0
  254. package/models/trace/handlers/UserTimingsHandler.js +67 -39
  255. package/models/trace/handlers/UserTimingsHandler.js.map +1 -1
  256. package/models/trace/handlers/WarningsHandler.js +14 -14
  257. package/models/trace/handlers/WarningsHandler.js.map +1 -1
  258. package/models/trace/handlers/WorkersHandler.js +7 -7
  259. package/models/trace/handlers/WorkersHandler.js.map +1 -1
  260. package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  261. package/models/trace/handlers/handlers-tsconfig.json +6 -2
  262. package/models/trace/handlers/handlers.js +1 -1
  263. package/models/trace/handlers/handlers.js.map +1 -1
  264. package/models/trace/handlers/helpers.d.ts +3 -2
  265. package/models/trace/handlers/helpers.js +10 -10
  266. package/models/trace/handlers/helpers.js.map +1 -1
  267. package/models/trace/handlers/types.d.ts +25 -2
  268. package/models/trace/handlers/types.js.map +1 -1
  269. package/models/trace/helpers/Extensions.js +8 -8
  270. package/models/trace/helpers/Extensions.js.map +1 -1
  271. package/models/trace/helpers/Network.js.map +1 -1
  272. package/models/trace/helpers/SamplesIntegrator.js +11 -9
  273. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  274. package/models/trace/helpers/SyntheticEvents.js +1 -1
  275. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  276. package/models/trace/helpers/Timing.d.ts +4 -0
  277. package/models/trace/helpers/Timing.js +6 -4
  278. package/models/trace/helpers/Timing.js.map +1 -1
  279. package/models/trace/helpers/Trace.d.ts +21 -23
  280. package/models/trace/helpers/Trace.js +188 -67
  281. package/models/trace/helpers/Trace.js.map +1 -1
  282. package/models/trace/helpers/TreeHelpers.js +1 -1
  283. package/models/trace/helpers/TreeHelpers.js.map +1 -1
  284. package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  285. package/models/trace/helpers/helpers-tsconfig.json +6 -2
  286. package/models/trace/helpers/helpers.js +1 -1
  287. package/models/trace/helpers/helpers.js.map +1 -1
  288. package/models/trace/insights/CLSCulprits.d.ts +2 -2
  289. package/models/trace/insights/CLSCulprits.js +14 -14
  290. package/models/trace/insights/CLSCulprits.js.map +1 -1
  291. package/models/trace/insights/Cache.d.ts +2 -1
  292. package/models/trace/insights/Cache.js +8 -5
  293. package/models/trace/insights/Cache.js.map +1 -1
  294. package/models/trace/insights/Common.d.ts +9 -1
  295. package/models/trace/insights/Common.js +33 -1
  296. package/models/trace/insights/Common.js.map +1 -1
  297. package/models/trace/insights/DOMSize.d.ts +3 -2
  298. package/models/trace/insights/DOMSize.js +10 -7
  299. package/models/trace/insights/DOMSize.js.map +1 -1
  300. package/models/trace/insights/DocumentLatency.d.ts +2 -2
  301. package/models/trace/insights/DocumentLatency.js +18 -17
  302. package/models/trace/insights/DocumentLatency.js.map +1 -1
  303. package/models/trace/insights/DuplicatedJavaScript.d.ts +2 -2
  304. package/models/trace/insights/DuplicatedJavaScript.js +5 -5
  305. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
  306. package/models/trace/insights/FontDisplay.d.ts +2 -1
  307. package/models/trace/insights/FontDisplay.js +7 -4
  308. package/models/trace/insights/FontDisplay.js.map +1 -1
  309. package/models/trace/insights/ForcedReflow.d.ts +2 -1
  310. package/models/trace/insights/ForcedReflow.js +6 -3
  311. package/models/trace/insights/ForcedReflow.js.map +1 -1
  312. package/models/trace/insights/INPBreakdown.d.ts +3 -3
  313. package/models/trace/insights/INPBreakdown.js +16 -5
  314. package/models/trace/insights/INPBreakdown.js.map +1 -1
  315. package/models/trace/insights/ImageDelivery.d.ts +2 -2
  316. package/models/trace/insights/ImageDelivery.js +13 -13
  317. package/models/trace/insights/ImageDelivery.js.map +1 -1
  318. package/models/trace/insights/LCPBreakdown.d.ts +3 -2
  319. package/models/trace/insights/LCPBreakdown.js +21 -15
  320. package/models/trace/insights/LCPBreakdown.js.map +1 -1
  321. package/models/trace/insights/LCPDiscovery.d.ts +2 -2
  322. package/models/trace/insights/LCPDiscovery.js +9 -11
  323. package/models/trace/insights/LCPDiscovery.js.map +1 -1
  324. package/models/trace/insights/LegacyJavaScript.d.ts +1 -1
  325. package/models/trace/insights/LegacyJavaScript.js +5 -4
  326. package/models/trace/insights/LegacyJavaScript.js.map +1 -1
  327. package/models/trace/insights/Models.js +1 -1
  328. package/models/trace/insights/Models.js.map +1 -1
  329. package/models/trace/insights/ModernHTTP.d.ts +2 -2
  330. package/models/trace/insights/ModernHTTP.js +6 -6
  331. package/models/trace/insights/ModernHTTP.js.map +1 -1
  332. package/models/trace/insights/NetworkDependencyTree.d.ts +6 -3
  333. package/models/trace/insights/NetworkDependencyTree.js +19 -16
  334. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  335. package/models/trace/insights/RenderBlocking.d.ts +2 -2
  336. package/models/trace/insights/RenderBlocking.js +11 -11
  337. package/models/trace/insights/RenderBlocking.js.map +1 -1
  338. package/models/trace/insights/SlowCSSSelector.d.ts +3 -2
  339. package/models/trace/insights/SlowCSSSelector.js +9 -6
  340. package/models/trace/insights/SlowCSSSelector.js.map +1 -1
  341. package/models/trace/insights/Statistics.js +1 -1
  342. package/models/trace/insights/Statistics.js.map +1 -1
  343. package/models/trace/insights/ThirdParties.d.ts +2 -1
  344. package/models/trace/insights/ThirdParties.js +8 -5
  345. package/models/trace/insights/ThirdParties.js.map +1 -1
  346. package/models/trace/insights/Viewport.d.ts +2 -1
  347. package/models/trace/insights/Viewport.js +8 -5
  348. package/models/trace/insights/Viewport.js.map +1 -1
  349. package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  350. package/models/trace/insights/insights-tsconfig.json +6 -2
  351. package/models/trace/insights/insights.d.ts +2 -0
  352. package/models/trace/insights/insights.js +3 -1
  353. package/models/trace/insights/insights.js.map +1 -1
  354. package/models/trace/insights/types.d.ts +4 -1
  355. package/models/trace/insights/types.js +2 -1
  356. package/models/trace/insights/types.js.map +1 -1
  357. package/models/trace/lantern/core/LanternError.js +1 -1
  358. package/models/trace/lantern/core/LanternError.js.map +1 -1
  359. package/models/trace/lantern/core/NetworkAnalyzer.js +1 -1
  360. package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -1
  361. package/models/trace/lantern/core/core-tsconfig.json +6 -2
  362. package/models/trace/lantern/core/core.js +1 -1
  363. package/models/trace/lantern/core/core.js.map +1 -1
  364. package/models/trace/lantern/core/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  365. package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  366. package/models/trace/lantern/graph/BaseNode.js +1 -1
  367. package/models/trace/lantern/graph/BaseNode.js.map +1 -1
  368. package/models/trace/lantern/graph/CPUNode.js +1 -1
  369. package/models/trace/lantern/graph/CPUNode.js.map +1 -1
  370. package/models/trace/lantern/graph/NetworkNode.js +1 -1
  371. package/models/trace/lantern/graph/NetworkNode.js.map +1 -1
  372. package/models/trace/lantern/graph/PageDependencyGraph.js +1 -1
  373. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
  374. package/models/trace/lantern/graph/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  375. package/models/trace/lantern/graph/graph-tsconfig.json +6 -2
  376. package/models/trace/lantern/graph/graph.js +1 -1
  377. package/models/trace/lantern/graph/graph.js.map +1 -1
  378. package/models/trace/lantern/lantern-tsconfig.json +6 -2
  379. package/models/trace/lantern/lantern.js +1 -1
  380. package/models/trace/lantern/lantern.js.map +1 -1
  381. package/models/trace/lantern/metrics/FirstContentfulPaint.js +1 -1
  382. package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +1 -1
  383. package/models/trace/lantern/metrics/Interactive.js +1 -1
  384. package/models/trace/lantern/metrics/Interactive.js.map +1 -1
  385. package/models/trace/lantern/metrics/LargestContentfulPaint.js +1 -1
  386. package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -1
  387. package/models/trace/lantern/metrics/MaxPotentialFID.js +1 -1
  388. package/models/trace/lantern/metrics/MaxPotentialFID.js.map +1 -1
  389. package/models/trace/lantern/metrics/Metric.js +1 -1
  390. package/models/trace/lantern/metrics/Metric.js.map +1 -1
  391. package/models/trace/lantern/metrics/SpeedIndex.js +1 -1
  392. package/models/trace/lantern/metrics/SpeedIndex.js.map +1 -1
  393. package/models/trace/lantern/metrics/TBTUtils.js +1 -1
  394. package/models/trace/lantern/metrics/TBTUtils.js.map +1 -1
  395. package/models/trace/lantern/metrics/TotalBlockingTime.js +1 -1
  396. package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -1
  397. package/models/trace/lantern/metrics/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  398. package/models/trace/lantern/metrics/metrics-tsconfig.json +6 -2
  399. package/models/trace/lantern/metrics/metrics.js +1 -1
  400. package/models/trace/lantern/metrics/metrics.js.map +1 -1
  401. package/models/trace/lantern/simulation/ConnectionPool.js +1 -1
  402. package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -1
  403. package/models/trace/lantern/simulation/Constants.js +1 -1
  404. package/models/trace/lantern/simulation/Constants.js.map +1 -1
  405. package/models/trace/lantern/simulation/DNSCache.js +1 -1
  406. package/models/trace/lantern/simulation/DNSCache.js.map +1 -1
  407. package/models/trace/lantern/simulation/SimulationTimingMap.js +1 -1
  408. package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -1
  409. package/models/trace/lantern/simulation/Simulator.js +1 -1
  410. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  411. package/models/trace/lantern/simulation/TCPConnection.js +1 -1
  412. package/models/trace/lantern/simulation/TCPConnection.js.map +1 -1
  413. package/models/trace/lantern/simulation/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  414. package/models/trace/lantern/simulation/simulation-tsconfig.json +6 -2
  415. package/models/trace/lantern/simulation/simulation.js +1 -1
  416. package/models/trace/lantern/simulation/simulation.js.map +1 -1
  417. package/models/trace/lantern/types/Lantern.js +1 -1
  418. package/models/trace/lantern/types/Lantern.js.map +1 -1
  419. package/models/trace/lantern/types/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  420. package/models/trace/lantern/types/types-tsconfig.json +6 -2
  421. package/models/trace/lantern/types/types.js +1 -1
  422. package/models/trace/lantern/types/types.js.map +1 -1
  423. package/models/trace/trace-tsconfig.json +10 -2
  424. package/models/trace/trace.d.ts +5 -1
  425. package/models/trace/trace.js +6 -2
  426. package/models/trace/trace.js.map +1 -1
  427. package/models/trace/types/Configuration.d.ts +11 -0
  428. package/models/trace/types/Configuration.js +1 -1
  429. package/models/trace/types/Configuration.js.map +1 -1
  430. package/models/trace/types/Extensions.d.ts +25 -13
  431. package/models/trace/types/Extensions.js +6 -3
  432. package/models/trace/types/Extensions.js.map +1 -1
  433. package/models/trace/types/File.d.ts +13 -2
  434. package/models/trace/types/File.js +1 -1
  435. package/models/trace/types/File.js.map +1 -1
  436. package/models/trace/types/Overlays.d.ts +5 -4
  437. package/models/trace/types/Overlays.js +1 -1
  438. package/models/trace/types/Overlays.js.map +1 -1
  439. package/models/trace/types/Timing.d.ts +1 -0
  440. package/models/trace/types/Timing.js +1 -1
  441. package/models/trace/types/Timing.js.map +1 -1
  442. package/models/trace/types/TraceEvents.d.ts +81 -61
  443. package/models/trace/types/TraceEvents.js +42 -29
  444. package/models/trace/types/TraceEvents.js.map +1 -1
  445. package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +6 -2
  446. package/models/trace/types/types-tsconfig.json +6 -2
  447. package/models/trace/types/types.js +1 -1
  448. package/models/trace/types/types.js.map +1 -1
  449. package/package.json +1 -1
  450. package/test/test-trace-engine.mjs +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"FlowsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/FlowsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAC7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,qEAAqE;AACrE,wEAAwE;AAExE,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,kEAAkE;AAClE,iEAAiE;AAEjE,uEAAuE;AACvE,8DAA8D;AAE9D,wEAAwE;AACxE,mEAAmE;AACnE,aAAa;AAEb,wEAAwE;AACxE,uEAAuE;AACvE,sEAAsE;AACtE,yDAAyD;AACzD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAkB,CAAC;AASvD,mEAAmE;AACnE,uEAAuE;AACvE,qEAAqE;AACrE,qBAAqB;AACrB,qEAAqE;AACrE,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,6DAA6D;AAC7D,eAAe;AACf,MAAM,aAAa,GAAqB,IAAI,GAAG,EAAE,CAAC;AAElD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuD,CAAC;AACjF,MAAM,UAAU,GAA6B,EAAE,CAAC;AAChD,MAAM,aAAa,GAAyB,EAAE,CAAC;AAC/C,IAAI,KAAK,GAA2B,EAAE,CAAC;AACvC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,UAAU,KAAK;IACnB,KAAK,GAAG,EAAE,CAAC;IACX,UAAU,CAAC,MAAM,GAAG,CAAC,CAA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AAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;SAC7C,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;SACtD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Types from '../types/types.js';\n\n// A flow is a logic connection between trace events. We display this\n// connection as arrows between trace events belonging to the same flow.\n\n// In the trace event format, flows are represented with pairing \"flow\n// phase\" events. Each flow phase event corresponds to one trace event\n// and indicates the role a trace event plays in a flow (start, step or\n// end). For each flow, one `start` and one `end` phase events are\n// included, while the amount of `step` phase events can be >= 0.\n\n// A flow phase event is assigned to a trace event when their cat, tid,\n// pid and ts are equal (see @flowPhaseBindingTokenForEvent ).\n\n// It's possible for a single event to belong to multiple flows. In that\n// case, it will have multiple corresponding flow phase events (one\n// per flow).\n\n// To parse flows, we first handle flow phase events, by creating unique\n// flows with the timestamps of each phase. Then, we place trace events\n// in the flows where their corresponding phase events were placed (if\n// there are any corresponding flow phase events at all).\nconst flowDataByGroupToken = new Map<string, number>();\n\ninterface EventFlowData {\n flows: Set<number>;\n bindingParsed: boolean;\n}\ntype FlowBindingTuple =\n Map<Types.Timing.Micro, Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Map<string, EventFlowData>>>>;\n\n// Given a trace event's flow binding tuple (timestamp, process id,\n// thread id and category) we determine if there is any flow data bound\n// to it by using this map's content. It's built when processing flow\n// events in a trace.\n// An alternative to having a map of four levels is having single map\n// from a string token built from concatenating the binding data to the\n// corresponding flow data. However, this token would be calculated for\n// every event in a trace, resulting in a lot of memory overhead and\n// major GC triggering. So we are trading off readability for\n// performance.\nconst boundFlowData: FlowBindingTuple = new Map();\n\nconst flowsById = new Map<number, Map<Types.Timing.Micro, Types.Events.Event>>();\nconst flowEvents: Types.Events.FlowEvent[] = [];\nconst nonFlowEvents: Types.Events.Event[] = [];\nlet flows: Types.Events.Event[][] = [];\nconst ID_COMPONENT_SEPARATOR = '-$-';\nexport function reset(): void {\n flows = [];\n flowEvents.length = 0;\n nonFlowEvents.length = 0;\n flowDataByGroupToken.clear();\n boundFlowData.clear();\n flowsById.clear();\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (Types.Events.isFlowPhaseEvent(event)) {\n flowEvents.push(event);\n return;\n }\n nonFlowEvents.push(event);\n}\n\nfunction processNonFlowEvent(event: Types.Events.Event): void {\n const flowDataForEvent = boundFlowData.get(event.ts)?.get(event.pid)?.get(event.tid)?.get(event.cat);\n if (!flowDataForEvent) {\n return;\n }\n const {flows, bindingParsed} = flowDataForEvent;\n if (bindingParsed) {\n // We only consider the first event for a given flow binding tuple.\n return;\n }\n for (const flowId of flows) {\n const flow = Platform.MapUtilities.getWithDefault(\n flowsById, flowId, () => new Map<Types.Timing.Micro, Types.Events.Event>());\n flow.set(event.ts, event);\n }\n flowDataForEvent.bindingParsed = true;\n}\n\n/**\n * Creates unique flows by tracking flow phase events. A new created\n * flow whenever a flow start phase event is detected.\n * Subsequent flow phase events with the same group token are added to\n * this flow until a flow end phase is detected.\n */\nfunction processFlowEvent(flowPhaseEvent: Types.Events.FlowEvent): void {\n const flowGroup = flowGroupTokenForFlowPhaseEvent(flowPhaseEvent);\n switch (flowPhaseEvent.ph) {\n case (Types.Events.Phase.FLOW_START): {\n const flowMetadata = {flowId: flowPhaseEvent.id, times: new Map([[flowPhaseEvent.ts, undefined]])};\n flowDataByGroupToken.set(flowGroup, flowPhaseEvent.id);\n addFlowIdToEventBinding(flowPhaseEvent, flowMetadata.flowId);\n return;\n }\n case (Types.Events.Phase.FLOW_STEP): {\n const flowId = flowDataByGroupToken.get(flowGroup);\n if (flowId === undefined) {\n // Found non-start flow event with no corresponding start flow,\n // start event. Quietly ignore the problematic event.\n return;\n }\n addFlowIdToEventBinding(flowPhaseEvent, flowId);\n return;\n }\n case (Types.Events.Phase.FLOW_END): {\n const flowId = flowDataByGroupToken.get(flowGroup);\n if (flowId === undefined) {\n // Found non-start flow event with no corresponding start flow,\n // start event. Quietly ignore the problematic event.\n return;\n }\n addFlowIdToEventBinding(flowPhaseEvent, flowId);\n // We don't need this data anymore as the flow has been finished,\n // so we can drop it.\n flowDataByGroupToken.delete(flowGroup);\n }\n }\n}\n\ntype MapValueType<T extends Map<unknown, unknown>> = NonNullable<ReturnType<T['get']>>;\n/**\n * A single trace event can belong to multiple flows. This method\n * tracks which flows (flowId) an event belongs to given its flow\n * binding tuple (made of its ts, pid, tid and cat).\n */\nfunction addFlowIdToEventBinding(event: Types.Events.Event, flowId: number): void {\n const flowsByPid = Platform.MapUtilities.getWithDefault<Types.Timing.Micro, MapValueType<typeof boundFlowData>>(\n boundFlowData, event.ts, () => new Map());\n const flowsByTid = Platform.MapUtilities.getWithDefault<Types.Events.ProcessID, MapValueType<typeof flowsByPid>>(\n flowsByPid, event.pid, () => new Map());\n const flowsByCat = Platform.MapUtilities.getWithDefault<Types.Events.ThreadID, MapValueType<typeof flowsByTid>>(\n flowsByTid, event.tid, () => new Map());\n const flowData =\n Platform.MapUtilities.getWithDefault(flowsByCat, event.cat, () => ({flows: new Set(), bindingParsed: false}));\n flowData.flows.add(flowId);\n}\n\n/**\n * Returns a token to group flow phase events (start, step and end)\n * belonging to the same flow. Flow phase events belonging to the same\n * flow share category, thread id, process id and name.\n *\n * Note that other phase events of other flows can share these\n * attributes too. For this reason, we group flow phase events in\n * cycles. A cycle starts on a flow start phase event and finishes on a\n * flow end phase event. For this reason, flow phase events need to be\n * handled in timestamp order.\n */\nfunction flowGroupTokenForFlowPhaseEvent(event: Types.Events.FlowEvent): string {\n return `${event.cat}${ID_COMPONENT_SEPARATOR}${event.name}${ID_COMPONENT_SEPARATOR}${event.id}`;\n}\n\nexport async function finalize(): Promise<void> {\n // Order is important: flow events need to be handled first.\n flowEvents.forEach(processFlowEvent);\n nonFlowEvents.forEach(processNonFlowEvent);\n flows = [...flowsById.values()]\n .map(flowMapping => [...flowMapping.values()])\n .map(flow => flow.filter(event => event !== undefined))\n .filter(flow => flow.length > 1);\n}\n\nexport function data(): {flows: Types.Events.Event[][]} {\n return {\n flows,\n };\n}\n"]}
1
+ {"version":3,"file":"FlowsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/FlowsHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAC7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,qEAAqE;AACrE,wEAAwE;AAExE,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,kEAAkE;AAClE,iEAAiE;AAEjE,uEAAuE;AACvE,8DAA8D;AAE9D,wEAAwE;AACxE,mEAAmE;AACnE,aAAa;AAEb,wEAAwE;AACxE,uEAAuE;AACvE,sEAAsE;AACtE,yDAAyD;AACzD,IAAI,oBAAoB,GAAG,IAAI,GAAG,EAAkB,CAAC;AASrD,mEAAmE;AACnE,uEAAuE;AACvE,qEAAqE;AACrE,qBAAqB;AACrB,qEAAqE;AACrE,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,6DAA6D;AAC7D,eAAe;AACf,IAAI,aAAa,GAAqB,IAAI,GAAG,EAAE,CAAC;AAEhD,IAAI,SAAS,GAAG,IAAI,GAAG,EAAuD,CAAC;AAC/E,IAAI,UAAU,GAA6B,EAAE,CAAC;AAC9C,IAAI,aAAa,GAAyB,EAAE,CAAC;AAC7C,IAAI,KAAK,GAA2B,EAAE,CAAC;AACvC,MAAM,sBAAsB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;IAC3C,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;SAClB,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;SAC7C,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;SACtD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Types from '../types/types.js';\n\n// A flow is a logic connection between trace events. We display this\n// connection as arrows between trace events belonging to the same flow.\n\n// In the trace event format, flows are represented with pairing \"flow\n// phase\" events. Each flow phase event corresponds to one trace event\n// and indicates the role a trace event plays in a flow (start, step or\n// end). For each flow, one `start` and one `end` phase events are\n// included, while the amount of `step` phase events can be >= 0.\n\n// A flow phase event is assigned to a trace event when their cat, tid,\n// pid and ts are equal (see @flowPhaseBindingTokenForEvent ).\n\n// It's possible for a single event to belong to multiple flows. In that\n// case, it will have multiple corresponding flow phase events (one\n// per flow).\n\n// To parse flows, we first handle flow phase events, by creating unique\n// flows with the timestamps of each phase. Then, we place trace events\n// in the flows where their corresponding phase events were placed (if\n// there are any corresponding flow phase events at all).\nlet flowDataByGroupToken = new Map<string, number>();\n\ninterface EventFlowData {\n flows: Set<number>;\n bindingParsed: boolean;\n}\ntype FlowBindingTuple =\n Map<Types.Timing.Micro, Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Map<string, EventFlowData>>>>;\n\n// Given a trace event's flow binding tuple (timestamp, process id,\n// thread id and category) we determine if there is any flow data bound\n// to it by using this map's content. It's built when processing flow\n// events in a trace.\n// An alternative to having a map of four levels is having single map\n// from a string token built from concatenating the binding data to the\n// corresponding flow data. However, this token would be calculated for\n// every event in a trace, resulting in a lot of memory overhead and\n// major GC triggering. So we are trading off readability for\n// performance.\nlet boundFlowData: FlowBindingTuple = new Map();\n\nlet flowsById = new Map<number, Map<Types.Timing.Micro, Types.Events.Event>>();\nlet flowEvents: Types.Events.FlowEvent[] = [];\nlet nonFlowEvents: Types.Events.Event[] = [];\nlet flows: Types.Events.Event[][] = [];\nconst ID_COMPONENT_SEPARATOR = '-$-';\nexport function reset(): void {\n flows = [];\n flowEvents = [];\n nonFlowEvents = [];\n flowDataByGroupToken = new Map();\n boundFlowData = new Map();\n flowsById = new Map();\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (Types.Events.isFlowPhaseEvent(event)) {\n flowEvents.push(event);\n return;\n }\n nonFlowEvents.push(event);\n}\n\nfunction processNonFlowEvent(event: Types.Events.Event): void {\n const flowDataForEvent = boundFlowData.get(event.ts)?.get(event.pid)?.get(event.tid)?.get(event.cat);\n if (!flowDataForEvent) {\n return;\n }\n const {flows, bindingParsed} = flowDataForEvent;\n if (bindingParsed) {\n // We only consider the first event for a given flow binding tuple.\n return;\n }\n for (const flowId of flows) {\n const flow = Platform.MapUtilities.getWithDefault(\n flowsById, flowId, () => new Map<Types.Timing.Micro, Types.Events.Event>());\n flow.set(event.ts, event);\n }\n flowDataForEvent.bindingParsed = true;\n}\n\n/**\n * Creates unique flows by tracking flow phase events. A new created\n * flow whenever a flow start phase event is detected.\n * Subsequent flow phase events with the same group token are added to\n * this flow until a flow end phase is detected.\n */\nfunction processFlowEvent(flowPhaseEvent: Types.Events.FlowEvent): void {\n const flowGroup = flowGroupTokenForFlowPhaseEvent(flowPhaseEvent);\n switch (flowPhaseEvent.ph) {\n case (Types.Events.Phase.FLOW_START): {\n const flowMetadata = {flowId: flowPhaseEvent.id, times: new Map([[flowPhaseEvent.ts, undefined]])};\n flowDataByGroupToken.set(flowGroup, flowPhaseEvent.id);\n addFlowIdToEventBinding(flowPhaseEvent, flowMetadata.flowId);\n return;\n }\n case (Types.Events.Phase.FLOW_STEP): {\n const flowId = flowDataByGroupToken.get(flowGroup);\n if (flowId === undefined) {\n // Found non-start flow event with no corresponding start flow,\n // start event. Quietly ignore the problematic event.\n return;\n }\n addFlowIdToEventBinding(flowPhaseEvent, flowId);\n return;\n }\n case (Types.Events.Phase.FLOW_END): {\n const flowId = flowDataByGroupToken.get(flowGroup);\n if (flowId === undefined) {\n // Found non-start flow event with no corresponding start flow,\n // start event. Quietly ignore the problematic event.\n return;\n }\n addFlowIdToEventBinding(flowPhaseEvent, flowId);\n // We don't need this data anymore as the flow has been finished,\n // so we can drop it.\n flowDataByGroupToken.delete(flowGroup);\n }\n }\n}\n\ntype MapValueType<T extends Map<unknown, unknown>> = NonNullable<ReturnType<T['get']>>;\n/**\n * A single trace event can belong to multiple flows. This method\n * tracks which flows (flowId) an event belongs to given its flow\n * binding tuple (made of its ts, pid, tid and cat).\n */\nfunction addFlowIdToEventBinding(event: Types.Events.Event, flowId: number): void {\n const flowsByPid = Platform.MapUtilities.getWithDefault<Types.Timing.Micro, MapValueType<typeof boundFlowData>>(\n boundFlowData, event.ts, () => new Map());\n const flowsByTid = Platform.MapUtilities.getWithDefault<Types.Events.ProcessID, MapValueType<typeof flowsByPid>>(\n flowsByPid, event.pid, () => new Map());\n const flowsByCat = Platform.MapUtilities.getWithDefault<Types.Events.ThreadID, MapValueType<typeof flowsByTid>>(\n flowsByTid, event.tid, () => new Map());\n const flowData =\n Platform.MapUtilities.getWithDefault(flowsByCat, event.cat, () => ({flows: new Set(), bindingParsed: false}));\n flowData.flows.add(flowId);\n}\n\n/**\n * Returns a token to group flow phase events (start, step and end)\n * belonging to the same flow. Flow phase events belonging to the same\n * flow share category, thread id, process id and name.\n *\n * Note that other phase events of other flows can share these\n * attributes too. For this reason, we group flow phase events in\n * cycles. A cycle starts on a flow start phase event and finishes on a\n * flow end phase event. For this reason, flow phase events need to be\n * handled in timestamp order.\n */\nfunction flowGroupTokenForFlowPhaseEvent(event: Types.Events.FlowEvent): string {\n return `${event.cat}${ID_COMPONENT_SEPARATOR}${event.name}${ID_COMPONENT_SEPARATOR}${event.id}`;\n}\n\nexport async function finalize(): Promise<void> {\n // Order is important: flow events need to be handled first.\n flowEvents.forEach(processFlowEvent);\n nonFlowEvents.forEach(processNonFlowEvent);\n flows = [...flowsById.values()]\n .map(flowMapping => [...flowMapping.values()])\n .map(flow => flow.filter(event => event !== undefined))\n .filter(flow => flow.length > 1);\n}\n\nexport function data(): {flows: Types.Events.Event[][]} {\n return {\n flows,\n };\n}\n"]}
@@ -68,6 +68,7 @@ export declare class PendingFrame {
68
68
  triggerTime: number;
69
69
  constructor(triggerTime: number);
70
70
  }
71
+ /** The parameters of an impl-side BeginFrame. **/
71
72
  declare class BeginFrameInfo {
72
73
  seqId: number;
73
74
  startTime: Types.Timing.Micro;
@@ -75,6 +76,12 @@ declare class BeginFrameInfo {
75
76
  isPartial: boolean;
76
77
  constructor(seqId: number, startTime: Types.Timing.Micro, isDropped: boolean, isPartial: boolean);
77
78
  }
79
+ /**
80
+ * A queue of BeginFrames pending visualization.
81
+ * BeginFrames are added into this queue as they occur; later when their
82
+ * corresponding DrawFrames occur (or lack thereof), the BeginFrames are removed
83
+ * from the queue and their timestamps are used for visualization.
84
+ **/
78
85
  export declare class TimelineFrameBeginFrameQueue {
79
86
  private queueFrames;
80
87
  private mapFrames;
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Chromium Authors. All rights reserved.
1
+ // Copyright 2023 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
  import * as Platform from '../../../core/platform/platform.js';
@@ -20,7 +20,7 @@ import * as Threads from './Threads.js';
20
20
  * In time we expect to migrate this code to a more "typical" handler.
21
21
  */
22
22
  let model = null;
23
- const relevantFrameEvents = [];
23
+ let relevantFrameEvents = [];
24
24
  function isFrameEvent(event) {
25
25
  return (Types.Events.isSetLayerId(event) || Types.Events.isBeginFrame(event) || Types.Events.isDroppedFrame(event) ||
26
26
  Types.Events.isRequestMainThreadFrame(event) || Types.Events.isBeginMainThreadFrame(event) ||
@@ -44,7 +44,7 @@ const MAIN_FRAME_MARKERS = new Set([
44
44
  ]);
45
45
  export function reset() {
46
46
  model = null;
47
- relevantFrameEvents.length = 0;
47
+ relevantFrameEvents = [];
48
48
  }
49
49
  export function handleEvent(event) {
50
50
  // This might seem like a wide set of events to filter for, but these are all
@@ -67,8 +67,8 @@ export async function finalize() {
67
67
  }
68
68
  export function data() {
69
69
  return {
70
- frames: model ? Array.from(model.frames()) : [],
71
- framesById: model ? { ...model.framesById() } : {},
70
+ frames: model?.frames() ?? [],
71
+ framesById: model?.framesById() ?? {},
72
72
  };
73
73
  }
74
74
  export function deps() {
@@ -410,7 +410,7 @@ export class PendingFrame {
410
410
  this.triggerTime = triggerTime;
411
411
  }
412
412
  }
413
- // The parameters of an impl-side BeginFrame.
413
+ /** The parameters of an impl-side BeginFrame. **/
414
414
  class BeginFrameInfo {
415
415
  seqId;
416
416
  startTime;
@@ -423,10 +423,12 @@ class BeginFrameInfo {
423
423
  this.isPartial = isPartial;
424
424
  }
425
425
  }
426
- // A queue of BeginFrames pending visualization.
427
- // BeginFrames are added into this queue as they occur; later when their
428
- // corresponding DrawFrames occur (or lack thereof), the BeginFrames are removed
429
- // from the queue and their timestamps are used for visualization.
426
+ /**
427
+ * A queue of BeginFrames pending visualization.
428
+ * BeginFrames are added into this queue as they occur; later when their
429
+ * corresponding DrawFrames occur (or lack thereof), the BeginFrames are removed
430
+ * from the queue and their timestamps are used for visualization.
431
+ **/
430
432
  export class TimelineFrameBeginFrameQueue {
431
433
  queueFrames = [];
432
434
  // Maps frameSeqId to BeginFrameInfo.
@@ -1 +1 @@
1
- {"version":3,"file":"FramesHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/FramesHandler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WAAW,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAC9B,MAAmD,EAAE,SAA6B,EAClF,OAA2B;IAC7B,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IACrH,MAAM,SAAS,GACX,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,IAAI,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7G,OAAO,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\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 {type AuctionWorkletsData, data as auctionWorkletsData} from './AuctionWorkletsHandler.js';\nimport {data as layerTreeHandlerData, type LayerTreeData} from './LayerTreeHandler.js';\nimport {data as metaHandlerData, type MetaHandlerData} from './MetaHandler.js';\nimport {data as rendererHandlerData, type RendererHandlerData} from './RendererHandler.js';\nimport * as Threads from './Threads.js';\nimport type {HandlerName} from './types.js';\n\n/**\n * IMPORTANT: this handler is slightly different to the rest. This is because\n * it is an adaptation of the TimelineFrameModel that has been used in DevTools\n * for many years. Rather than re-implement all the logic from scratch, instead\n * this handler gathers up the events and instantitates the class in the\n * finalize() method. Once the class has parsed all events, it is used to then\n * return the array of frames.\n *\n * In time we expect to migrate this code to a more \"typical\" handler.\n */\n\nlet model: TimelineFrameModel|null = null;\nconst relevantFrameEvents: Types.Events.Event[] = [];\n\ntype FrameEvent = Types.Events.BeginFrame|Types.Events.DroppedFrame|Types.Events.RequestMainThreadFrame|\n Types.Events.BeginMainThreadFrame|Types.Events.Commit|Types.Events.CompositeLayers|\n Types.Events.ActivateLayerTree|Types.Events.NeedsBeginFrameChanged|Types.Events.DrawFrame;\n\nfunction isFrameEvent(event: Types.Events.Event): event is FrameEvent {\n return (\n Types.Events.isSetLayerId(event) || Types.Events.isBeginFrame(event) || Types.Events.isDroppedFrame(event) ||\n Types.Events.isRequestMainThreadFrame(event) || Types.Events.isBeginMainThreadFrame(event) ||\n Types.Events.isNeedsBeginFrameChanged(event) ||\n // Note that \"Commit\" is the replacement for \"CompositeLayers\" so in a trace\n // we wouldn't expect to see a combination of these. All \"new\" trace\n // recordings use \"Commit\", but we can easily support \"CompositeLayers\" too\n // to not break older traces being imported.\n Types.Events.isCommit(event) || Types.Events.isCompositeLayers(event) ||\n Types.Events.isActivateLayerTree(event) || Types.Events.isDrawFrame(event));\n}\n\nfunction entryIsTopLevel(entry: Types.Events.Event): boolean {\n const devtoolsTimelineCategory = 'disabled-by-default-devtools.timeline';\n return entry.name === Types.Events.Name.RUN_TASK && entry.cat.includes(devtoolsTimelineCategory);\n}\n\nconst MAIN_FRAME_MARKERS = new Set<Types.Events.Name>([\n Types.Events.Name.SCHEDULE_STYLE_RECALCULATION,\n Types.Events.Name.INVALIDATE_LAYOUT,\n Types.Events.Name.BEGIN_MAIN_THREAD_FRAME,\n Types.Events.Name.SCROLL_LAYER,\n]);\n\nexport function reset(): void {\n model = null;\n relevantFrameEvents.length = 0;\n}\nexport function handleEvent(event: Types.Events.Event): void {\n // This might seem like a wide set of events to filter for, but these are all\n // the types of events that we care about in the TimelineFrameModel class at\n // the bottom of this file. Previously we would take a copy of an array of\n // all trace events, but on a few test traces, this set of filtered events\n // accounts for about 10% of the total events, so it's a big performance win\n // to deal with a much smaller subset of the data.\n if (isFrameEvent(event) || Types.Events.isLayerTreeHostImplSnapshot(event) || entryIsTopLevel(event) ||\n MAIN_FRAME_MARKERS.has(event.name as Types.Events.Name) || Types.Events.isPaint(event)) {\n relevantFrameEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n // We have to sort the events by timestamp, because the model code expects to\n // process events in order.\n Helpers.Trace.sortTraceEventsInPlace(relevantFrameEvents);\n\n const modelForTrace = new TimelineFrameModel(\n relevantFrameEvents,\n rendererHandlerData(),\n auctionWorkletsData(),\n metaHandlerData(),\n layerTreeHandlerData(),\n );\n model = modelForTrace;\n}\n\nexport interface FramesData {\n frames: readonly Types.Events.LegacyTimelineFrame[];\n framesById: Readonly<Record<number, Types.Events.LegacyTimelineFrame|undefined>>;\n}\n\nexport function data(): FramesData {\n return {\n frames: model ? Array.from(model.frames()) : [],\n framesById: model ? {...model.framesById()} : {},\n };\n}\n\nexport function deps(): HandlerName[] {\n return ['Meta', 'Renderer', 'AuctionWorklets', 'LayerTree'];\n}\n\nexport class TimelineFrameModel {\n #frames: TimelineFrame[] = [];\n #frameById: Record<number, TimelineFrame> = {};\n #beginFrameQueue: TimelineFrameBeginFrameQueue = new TimelineFrameBeginFrameQueue();\n #lastFrame: TimelineFrame|null = null;\n #mainFrameCommitted = false;\n #mainFrameRequested = false;\n #lastLayerTree: Types.Events.LegacyFrameLayerTreeData|null = null;\n #framePendingActivation: PendingFrame|null = null;\n #framePendingCommit: PendingFrame|null = null;\n #lastBeginFrame: number|null = null;\n #lastNeedsBeginFrame: number|null = null;\n #lastTaskBeginTime: Types.Timing.Micro|null = null;\n #layerTreeId: number|null = null;\n #activeProcessId: Types.Events.ProcessID|null = null;\n #activeThreadId: Types.Events.ThreadID|null = null;\n #layerTreeData: LayerTreeData;\n\n constructor(\n allEvents: readonly Types.Events.Event[], rendererData: RendererHandlerData,\n auctionWorkletsData: AuctionWorkletsData, metaData: MetaHandlerData, layerTreeData: LayerTreeData) {\n // We only care about getting threads from the Renderer, not Samples,\n // because Frames don't exist in a CPU Profile (which won't have Renderer\n // threads.)\n const mainThreads = Threads.threadsInRenderer(rendererData, auctionWorkletsData).filter(thread => {\n return thread.type === Threads.ThreadType.MAIN_THREAD && thread.processIsOnMainFrame;\n });\n const threadData = mainThreads.map(thread => {\n return {\n tid: thread.tid,\n pid: thread.pid,\n startTime: thread.entries[0].ts,\n };\n });\n\n this.#layerTreeData = layerTreeData;\n this.#addTraceEvents(allEvents, threadData, metaData.mainFrameId);\n }\n\n framesById(): Readonly<Record<number, TimelineFrame|undefined>> {\n return this.#frameById;\n }\n\n frames(): TimelineFrame[] {\n return this.#frames;\n }\n\n #handleBeginFrame(startTime: Types.Timing.Micro, seqId: number): void {\n if (!this.#lastFrame) {\n this.#startFrame(startTime, seqId);\n }\n this.#lastBeginFrame = startTime;\n\n this.#beginFrameQueue.addFrameIfNotExists(seqId, startTime, false, false);\n }\n\n #handleDroppedFrame(startTime: Types.Timing.Micro, seqId: number, isPartial: boolean): void {\n if (!this.#lastFrame) {\n this.#startFrame(startTime, seqId);\n }\n\n // This line handles the case where no BeginFrame event is issued for\n // the dropped frame. In this situation, add a BeginFrame to the queue\n // as if it actually occurred.\n this.#beginFrameQueue.addFrameIfNotExists(seqId, startTime, true, isPartial);\n this.#beginFrameQueue.setDropped(seqId, true);\n this.#beginFrameQueue.setPartial(seqId, isPartial);\n }\n\n #handleDrawFrame(startTime: Types.Timing.Micro, seqId: number): void {\n if (!this.#lastFrame) {\n this.#startFrame(startTime, seqId);\n return;\n }\n\n // - if it wasn't drawn, it didn't happen!\n // - only show frames that either did not wait for the main thread frame or had one committed.\n if (this.#mainFrameCommitted || !this.#mainFrameRequested) {\n if (this.#lastNeedsBeginFrame) {\n const idleTimeEnd = this.#framePendingActivation ? this.#framePendingActivation.triggerTime :\n (this.#lastBeginFrame || this.#lastNeedsBeginFrame);\n if (idleTimeEnd > this.#lastFrame.startTime) {\n this.#lastFrame.idle = true;\n this.#lastBeginFrame = null;\n }\n this.#lastNeedsBeginFrame = null;\n }\n\n const framesToVisualize = this.#beginFrameQueue.processPendingBeginFramesOnDrawFrame(seqId);\n\n // Visualize the current frame and all pending frames before it.\n for (const frame of framesToVisualize) {\n const isLastFrameIdle = this.#lastFrame.idle;\n\n // If |frame| is the first frame after an idle period, the CPU time\n // will be logged (\"committed\") under |frame| if applicable.\n this.#startFrame(frame.startTime, seqId);\n if (isLastFrameIdle && this.#framePendingActivation) {\n this.#commitPendingFrame();\n }\n if (frame.isDropped) {\n this.#lastFrame.dropped = true;\n }\n if (frame.isPartial) {\n this.#lastFrame.isPartial = true;\n }\n }\n }\n this.#mainFrameCommitted = false;\n }\n\n #handleActivateLayerTree(): void {\n if (!this.#lastFrame) {\n return;\n }\n if (this.#framePendingActivation && !this.#lastNeedsBeginFrame) {\n this.#commitPendingFrame();\n }\n }\n\n #handleRequestMainThreadFrame(): void {\n if (!this.#lastFrame) {\n return;\n }\n this.#mainFrameRequested = true;\n }\n\n #handleCommit(): void {\n if (!this.#framePendingCommit) {\n return;\n }\n this.#framePendingActivation = this.#framePendingCommit;\n this.#framePendingCommit = null;\n this.#mainFrameRequested = false;\n this.#mainFrameCommitted = true;\n }\n\n #handleLayerTreeSnapshot(layerTree: Types.Events.LegacyFrameLayerTreeData): void {\n this.#lastLayerTree = layerTree;\n }\n\n #handleNeedFrameChanged(startTime: Types.Timing.Micro, needsBeginFrame: boolean): void {\n if (needsBeginFrame) {\n this.#lastNeedsBeginFrame = startTime;\n }\n }\n\n #startFrame(startTime: Types.Timing.Micro, seqId: number): void {\n if (this.#lastFrame) {\n this.#flushFrame(this.#lastFrame, startTime);\n }\n this.#lastFrame =\n new TimelineFrame(seqId, startTime, Types.Timing.Micro(startTime - metaHandlerData().traceBounds.min));\n }\n\n #flushFrame(frame: TimelineFrame, endTime: Types.Timing.Micro): void {\n frame.setLayerTree(this.#lastLayerTree);\n frame.setEndTime(endTime);\n if (this.#lastLayerTree) {\n this.#lastLayerTree.paints = frame.paints;\n }\n const lastFrame = this.#frames[this.#frames.length - 1];\n if (this.#frames.length && lastFrame &&\n (frame.startTime !== lastFrame.endTime || frame.startTime > frame.endTime)) {\n console.assert(\n false, `Inconsistent frame time for frame ${this.#frames.length} (${frame.startTime} - ${frame.endTime})`);\n }\n const newFramesLength = this.#frames.push(frame);\n frame.setIndex(newFramesLength - 1);\n if (typeof frame.mainFrameId === 'number') {\n this.#frameById[frame.mainFrameId] = frame;\n }\n }\n\n #commitPendingFrame(): void {\n if (!this.#framePendingActivation || !this.#lastFrame) {\n return;\n }\n\n this.#lastFrame.paints = this.#framePendingActivation.paints;\n this.#lastFrame.mainFrameId = this.#framePendingActivation.mainFrameId;\n this.#framePendingActivation = null;\n }\n\n #addTraceEvents(\n events: readonly Types.Events.Event[], threadData: Array<{\n pid: Types.Events.ProcessID,\n tid: Types.Events.ThreadID,\n startTime: Types.Timing.Micro,\n }>,\n mainFrameId: string): void {\n let j = 0;\n this.#activeThreadId = threadData.length && threadData[0].tid || null;\n this.#activeProcessId = threadData.length && threadData[0].pid || null;\n for (let i = 0; i < events.length; ++i) {\n while (j + 1 < threadData.length && threadData[j + 1].startTime <= events[i].ts) {\n this.#activeThreadId = threadData[++j].tid;\n this.#activeProcessId = threadData[j].pid;\n }\n this.#addTraceEvent(events[i], mainFrameId);\n }\n this.#activeThreadId = null;\n this.#activeProcessId = null;\n }\n\n #addTraceEvent(event: Types.Events.Event, mainFrameId: string): void {\n if (Types.Events.isSetLayerId(event) && event.args.data.frame === mainFrameId) {\n this.#layerTreeId = event.args.data.layerTreeId;\n } else if (Types.Events.isLayerTreeHostImplSnapshot(event) && Number(event.id) === this.#layerTreeId) {\n this.#handleLayerTreeSnapshot({\n entry: event,\n paints: [],\n });\n } else {\n if (isFrameEvent(event)) {\n this.#processCompositorEvents(event);\n }\n // Make sure we only use events from the main thread: we check the PID as\n // well in case two processes have a thread with the same TID.\n if (event.tid === this.#activeThreadId && event.pid === this.#activeProcessId) {\n this.#addMainThreadTraceEvent(event);\n }\n }\n }\n\n #processCompositorEvents(entry: FrameEvent): void {\n if (entry.args['layerTreeId'] !== this.#layerTreeId) {\n return;\n }\n if (Types.Events.isBeginFrame(entry)) {\n this.#handleBeginFrame(entry.ts, entry.args['frameSeqId']);\n } else if (Types.Events.isDrawFrame(entry)) {\n this.#handleDrawFrame(entry.ts, entry.args['frameSeqId']);\n } else if (Types.Events.isActivateLayerTree(entry)) {\n this.#handleActivateLayerTree();\n } else if (Types.Events.isRequestMainThreadFrame(entry)) {\n this.#handleRequestMainThreadFrame();\n } else if (Types.Events.isNeedsBeginFrameChanged(entry)) {\n // needsBeginFrame property will either be 0 or 1, which represents\n // true/false in this case, hence the Boolean() wrapper.\n this.#handleNeedFrameChanged(entry.ts, entry.args['data'] && Boolean(entry.args['data']['needsBeginFrame']));\n } else if (Types.Events.isDroppedFrame(entry)) {\n this.#handleDroppedFrame(entry.ts, entry.args['frameSeqId'], Boolean(entry.args['hasPartialUpdate']));\n }\n }\n\n #addMainThreadTraceEvent(entry: Types.Events.Event): void {\n if (entryIsTopLevel(entry)) {\n this.#lastTaskBeginTime = entry.ts;\n }\n if (!this.#framePendingCommit && MAIN_FRAME_MARKERS.has(entry.name as Types.Events.Name)) {\n this.#framePendingCommit = new PendingFrame(this.#lastTaskBeginTime || entry.ts);\n }\n if (!this.#framePendingCommit) {\n return;\n }\n\n if (Types.Events.isBeginMainThreadFrame(entry) && entry.args.data.frameId) {\n this.#framePendingCommit.mainFrameId = entry.args.data.frameId;\n }\n if (Types.Events.isPaint(entry)) {\n const snapshot = this.#layerTreeData.paintsToSnapshots.get(entry);\n if (snapshot) {\n this.#framePendingCommit.paints.push(new LayerPaintEvent(entry, snapshot));\n }\n }\n // Commit will be replacing CompositeLayers but CompositeLayers is kept\n // around for backwards compatibility.\n if ((Types.Events.isCompositeLayers(entry) || Types.Events.isCommit(entry)) &&\n entry.args['layerTreeId'] === this.#layerTreeId) {\n this.#handleCommit();\n }\n }\n}\n\n/**\n * Legacy class that represents TimelineFrames that was ported from the old SDK.\n * This class is purposefully not exported as it breaks the abstraction that\n * every event shown on the timeline is a trace event. Instead, we use the Type\n * LegacyTimelineFrame to represent frames in the codebase. These do implement\n * the right interface to be treated just like they were a trace event.\n */\nclass TimelineFrame implements Types.Events.LegacyTimelineFrame {\n // These fields exist to satisfy the base Event type which all\n // \"trace events\" must implement. They aren't used, but doing this means we\n // can pass `TimelineFrame` instances into places that expect\n // Types.Events.Event.\n cat = 'devtools.legacy_frame';\n name = 'frame';\n ph = Types.Events.Phase.COMPLETE;\n ts: Types.Timing.Micro;\n pid = Types.Events.ProcessID(-1);\n tid = Types.Events.ThreadID(-1);\n\n index = -1;\n startTime: Types.Timing.Micro;\n startTimeOffset: Types.Timing.Micro;\n endTime: Types.Timing.Micro;\n duration: Types.Timing.Micro;\n idle: boolean;\n dropped: boolean;\n isPartial: boolean;\n layerTree: Types.Events.LegacyFrameLayerTreeData|null;\n paints: LayerPaintEvent[];\n mainFrameId: number|undefined;\n readonly seqId: number;\n\n constructor(seqId: number, startTime: Types.Timing.Micro, startTimeOffset: Types.Timing.Micro) {\n this.seqId = seqId;\n this.startTime = startTime;\n this.ts = startTime;\n this.startTimeOffset = startTimeOffset;\n this.endTime = this.startTime;\n this.duration = Types.Timing.Micro(0);\n this.idle = false;\n this.dropped = false;\n this.isPartial = false;\n this.layerTree = null;\n this.paints = [];\n this.mainFrameId = undefined;\n }\n\n setIndex(i: number): void {\n this.index = i;\n }\n\n setEndTime(endTime: Types.Timing.Micro): void {\n this.endTime = endTime;\n this.duration = Types.Timing.Micro(this.endTime - this.startTime);\n }\n\n setLayerTree(layerTree: Types.Events.LegacyFrameLayerTreeData|null): void {\n this.layerTree = layerTree;\n }\n\n /**\n * Fake the `dur` field to meet the expected value given that we pretend\n * these TimelineFrame classes are trace events across the codebase.\n */\n get dur(): Types.Timing.Micro {\n return this.duration;\n }\n}\n\nexport class LayerPaintEvent implements Types.Events.LegacyLayerPaintEvent {\n readonly #event: Types.Events.Paint;\n #snapshot: Types.Events.DisplayItemListSnapshot;\n\n constructor(event: Types.Events.Paint, snapshot: Types.Events.DisplayItemListSnapshot) {\n this.#event = event;\n this.#snapshot = snapshot;\n }\n\n layerId(): number {\n return this.#event.args.data.layerId;\n }\n\n event(): Types.Events.Paint {\n return this.#event;\n }\n\n picture(): Types.Events.LegacyLayerPaintEventPicture|null {\n const rect = this.#snapshot.args.snapshot.params?.layer_rect;\n const pictureData = this.#snapshot.args.snapshot.skp64;\n return rect && pictureData ? {rect, serializedPicture: pictureData} : null;\n }\n}\n\nexport class PendingFrame {\n paints: LayerPaintEvent[];\n mainFrameId: number|undefined;\n triggerTime: number;\n constructor(triggerTime: number) {\n this.paints = [];\n this.mainFrameId = undefined;\n this.triggerTime = triggerTime;\n }\n}\n\n// The parameters of an impl-side BeginFrame.\nclass BeginFrameInfo {\n seqId: number;\n startTime: Types.Timing.Micro;\n isDropped: boolean;\n isPartial: boolean;\n constructor(seqId: number, startTime: Types.Timing.Micro, isDropped: boolean, isPartial: boolean) {\n this.seqId = seqId;\n this.startTime = startTime;\n this.isDropped = isDropped;\n this.isPartial = isPartial;\n }\n}\n\n// A queue of BeginFrames pending visualization.\n// BeginFrames are added into this queue as they occur; later when their\n// corresponding DrawFrames occur (or lack thereof), the BeginFrames are removed\n// from the queue and their timestamps are used for visualization.\nexport class TimelineFrameBeginFrameQueue {\n private queueFrames: number[] = [];\n\n // Maps frameSeqId to BeginFrameInfo.\n private mapFrames: Record<number, BeginFrameInfo> = {};\n\n // Add a BeginFrame to the queue, if it does not already exit.\n addFrameIfNotExists(seqId: number, startTime: Types.Timing.Micro, isDropped: boolean, isPartial: boolean): void {\n if (!(seqId in this.mapFrames)) {\n this.mapFrames[seqId] = new BeginFrameInfo(seqId, startTime, isDropped, isPartial);\n this.queueFrames.push(seqId);\n }\n }\n\n // Set a BeginFrame in queue as dropped.\n setDropped(seqId: number, isDropped: boolean): void {\n if (seqId in this.mapFrames) {\n this.mapFrames[seqId].isDropped = isDropped;\n }\n }\n\n setPartial(seqId: number, isPartial: boolean): void {\n if (seqId in this.mapFrames) {\n this.mapFrames[seqId].isPartial = isPartial;\n }\n }\n\n processPendingBeginFramesOnDrawFrame(seqId: number): BeginFrameInfo[] {\n const framesToVisualize: BeginFrameInfo[] = [];\n\n // Do not visualize this frame in the rare case where the current DrawFrame\n // does not have a corresponding BeginFrame.\n if (seqId in this.mapFrames) {\n // Pop all BeginFrames before the current frame, and add only the dropped\n // ones in |frames_to_visualize|.\n // Non-dropped frames popped here are BeginFrames that are never\n // drawn (but not considered dropped either for some reason).\n // Those frames do not require an proactive visualization effort and will\n // be naturally presented as continuationss of other frames.\n while (this.queueFrames[0] !== seqId) {\n const currentSeqId = this.queueFrames[0];\n if (this.mapFrames[currentSeqId].isDropped) {\n framesToVisualize.push(this.mapFrames[currentSeqId]);\n }\n\n delete this.mapFrames[currentSeqId];\n this.queueFrames.shift();\n }\n\n // Pop the BeginFrame associated with the current DrawFrame.\n framesToVisualize.push(this.mapFrames[seqId]);\n delete this.mapFrames[seqId];\n this.queueFrames.shift();\n }\n return framesToVisualize;\n }\n}\n\nexport function framesWithinWindow(\n frames: readonly Types.Events.LegacyTimelineFrame[], startTime: Types.Timing.Micro,\n endTime: Types.Timing.Micro): Types.Events.LegacyTimelineFrame[] {\n const firstFrame = Platform.ArrayUtilities.lowerBound(frames, startTime || 0, (time, frame) => time - frame.endTime);\n const lastFrame =\n Platform.ArrayUtilities.lowerBound(frames, endTime || Infinity, (time, frame) => time - frame.startTime);\n return frames.slice(firstFrame, lastFrame);\n}\n"]}
1
+ {"version":3,"file":"FramesHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/FramesHandler.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,EA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CAAC,MAAM,EAAE,OAAO,IAAI,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7G,OAAO,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAC7C,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 * as Platform from '../../../core/platform/platform.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {type AuctionWorkletsData, data as auctionWorkletsData} from './AuctionWorkletsHandler.js';\nimport {data as layerTreeHandlerData, type LayerTreeData} from './LayerTreeHandler.js';\nimport {data as metaHandlerData, type MetaHandlerData} from './MetaHandler.js';\nimport {data as rendererHandlerData, type RendererHandlerData} from './RendererHandler.js';\nimport * as Threads from './Threads.js';\nimport type {HandlerName} from './types.js';\n\n/**\n * IMPORTANT: this handler is slightly different to the rest. This is because\n * it is an adaptation of the TimelineFrameModel that has been used in DevTools\n * for many years. Rather than re-implement all the logic from scratch, instead\n * this handler gathers up the events and instantitates the class in the\n * finalize() method. Once the class has parsed all events, it is used to then\n * return the array of frames.\n *\n * In time we expect to migrate this code to a more \"typical\" handler.\n */\n\nlet model: TimelineFrameModel|null = null;\nlet relevantFrameEvents: Types.Events.Event[] = [];\n\ntype FrameEvent = Types.Events.BeginFrame|Types.Events.DroppedFrame|Types.Events.RequestMainThreadFrame|\n Types.Events.BeginMainThreadFrame|Types.Events.Commit|Types.Events.CompositeLayers|\n Types.Events.ActivateLayerTree|Types.Events.NeedsBeginFrameChanged|Types.Events.DrawFrame;\n\nfunction isFrameEvent(event: Types.Events.Event): event is FrameEvent {\n return (\n Types.Events.isSetLayerId(event) || Types.Events.isBeginFrame(event) || Types.Events.isDroppedFrame(event) ||\n Types.Events.isRequestMainThreadFrame(event) || Types.Events.isBeginMainThreadFrame(event) ||\n Types.Events.isNeedsBeginFrameChanged(event) ||\n // Note that \"Commit\" is the replacement for \"CompositeLayers\" so in a trace\n // we wouldn't expect to see a combination of these. All \"new\" trace\n // recordings use \"Commit\", but we can easily support \"CompositeLayers\" too\n // to not break older traces being imported.\n Types.Events.isCommit(event) || Types.Events.isCompositeLayers(event) ||\n Types.Events.isActivateLayerTree(event) || Types.Events.isDrawFrame(event));\n}\n\nfunction entryIsTopLevel(entry: Types.Events.Event): boolean {\n const devtoolsTimelineCategory = 'disabled-by-default-devtools.timeline';\n return entry.name === Types.Events.Name.RUN_TASK && entry.cat.includes(devtoolsTimelineCategory);\n}\n\nconst MAIN_FRAME_MARKERS = new Set<Types.Events.Name>([\n Types.Events.Name.SCHEDULE_STYLE_RECALCULATION,\n Types.Events.Name.INVALIDATE_LAYOUT,\n Types.Events.Name.BEGIN_MAIN_THREAD_FRAME,\n Types.Events.Name.SCROLL_LAYER,\n]);\n\nexport function reset(): void {\n model = null;\n relevantFrameEvents = [];\n}\nexport function handleEvent(event: Types.Events.Event): void {\n // This might seem like a wide set of events to filter for, but these are all\n // the types of events that we care about in the TimelineFrameModel class at\n // the bottom of this file. Previously we would take a copy of an array of\n // all trace events, but on a few test traces, this set of filtered events\n // accounts for about 10% of the total events, so it's a big performance win\n // to deal with a much smaller subset of the data.\n if (isFrameEvent(event) || Types.Events.isLayerTreeHostImplSnapshot(event) || entryIsTopLevel(event) ||\n MAIN_FRAME_MARKERS.has(event.name as Types.Events.Name) || Types.Events.isPaint(event)) {\n relevantFrameEvents.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n // We have to sort the events by timestamp, because the model code expects to\n // process events in order.\n Helpers.Trace.sortTraceEventsInPlace(relevantFrameEvents);\n\n const modelForTrace = new TimelineFrameModel(\n relevantFrameEvents,\n rendererHandlerData(),\n auctionWorkletsData(),\n metaHandlerData(),\n layerTreeHandlerData(),\n );\n model = modelForTrace;\n}\n\nexport interface FramesData {\n frames: readonly Types.Events.LegacyTimelineFrame[];\n framesById: Readonly<Record<number, Types.Events.LegacyTimelineFrame|undefined>>;\n}\n\nexport function data(): FramesData {\n return {\n frames: model?.frames() ?? [],\n framesById: model?.framesById() ?? {},\n };\n}\n\nexport function deps(): HandlerName[] {\n return ['Meta', 'Renderer', 'AuctionWorklets', 'LayerTree'];\n}\n\nexport class TimelineFrameModel {\n #frames: TimelineFrame[] = [];\n #frameById: Record<number, TimelineFrame> = {};\n #beginFrameQueue: TimelineFrameBeginFrameQueue = new TimelineFrameBeginFrameQueue();\n #lastFrame: TimelineFrame|null = null;\n #mainFrameCommitted = false;\n #mainFrameRequested = false;\n #lastLayerTree: Types.Events.LegacyFrameLayerTreeData|null = null;\n #framePendingActivation: PendingFrame|null = null;\n #framePendingCommit: PendingFrame|null = null;\n #lastBeginFrame: number|null = null;\n #lastNeedsBeginFrame: number|null = null;\n #lastTaskBeginTime: Types.Timing.Micro|null = null;\n #layerTreeId: number|null = null;\n #activeProcessId: Types.Events.ProcessID|null = null;\n #activeThreadId: Types.Events.ThreadID|null = null;\n #layerTreeData: LayerTreeData;\n\n constructor(\n allEvents: readonly Types.Events.Event[], rendererData: RendererHandlerData,\n auctionWorkletsData: AuctionWorkletsData, metaData: MetaHandlerData, layerTreeData: LayerTreeData) {\n // We only care about getting threads from the Renderer, not Samples,\n // because Frames don't exist in a CPU Profile (which won't have Renderer\n // threads.)\n const mainThreads = Threads.threadsInRenderer(rendererData, auctionWorkletsData).filter(thread => {\n return thread.type === Threads.ThreadType.MAIN_THREAD && thread.processIsOnMainFrame;\n });\n const threadData = mainThreads.map(thread => {\n return {\n tid: thread.tid,\n pid: thread.pid,\n startTime: thread.entries[0].ts,\n };\n });\n\n this.#layerTreeData = layerTreeData;\n this.#addTraceEvents(allEvents, threadData, metaData.mainFrameId);\n }\n\n framesById(): Readonly<Record<number, TimelineFrame|undefined>> {\n return this.#frameById;\n }\n\n frames(): TimelineFrame[] {\n return this.#frames;\n }\n\n #handleBeginFrame(startTime: Types.Timing.Micro, seqId: number): void {\n if (!this.#lastFrame) {\n this.#startFrame(startTime, seqId);\n }\n this.#lastBeginFrame = startTime;\n\n this.#beginFrameQueue.addFrameIfNotExists(seqId, startTime, false, false);\n }\n\n #handleDroppedFrame(startTime: Types.Timing.Micro, seqId: number, isPartial: boolean): void {\n if (!this.#lastFrame) {\n this.#startFrame(startTime, seqId);\n }\n\n // This line handles the case where no BeginFrame event is issued for\n // the dropped frame. In this situation, add a BeginFrame to the queue\n // as if it actually occurred.\n this.#beginFrameQueue.addFrameIfNotExists(seqId, startTime, true, isPartial);\n this.#beginFrameQueue.setDropped(seqId, true);\n this.#beginFrameQueue.setPartial(seqId, isPartial);\n }\n\n #handleDrawFrame(startTime: Types.Timing.Micro, seqId: number): void {\n if (!this.#lastFrame) {\n this.#startFrame(startTime, seqId);\n return;\n }\n\n // - if it wasn't drawn, it didn't happen!\n // - only show frames that either did not wait for the main thread frame or had one committed.\n if (this.#mainFrameCommitted || !this.#mainFrameRequested) {\n if (this.#lastNeedsBeginFrame) {\n const idleTimeEnd = this.#framePendingActivation ? this.#framePendingActivation.triggerTime :\n (this.#lastBeginFrame || this.#lastNeedsBeginFrame);\n if (idleTimeEnd > this.#lastFrame.startTime) {\n this.#lastFrame.idle = true;\n this.#lastBeginFrame = null;\n }\n this.#lastNeedsBeginFrame = null;\n }\n\n const framesToVisualize = this.#beginFrameQueue.processPendingBeginFramesOnDrawFrame(seqId);\n\n // Visualize the current frame and all pending frames before it.\n for (const frame of framesToVisualize) {\n const isLastFrameIdle = this.#lastFrame.idle;\n\n // If |frame| is the first frame after an idle period, the CPU time\n // will be logged (\"committed\") under |frame| if applicable.\n this.#startFrame(frame.startTime, seqId);\n if (isLastFrameIdle && this.#framePendingActivation) {\n this.#commitPendingFrame();\n }\n if (frame.isDropped) {\n this.#lastFrame.dropped = true;\n }\n if (frame.isPartial) {\n this.#lastFrame.isPartial = true;\n }\n }\n }\n this.#mainFrameCommitted = false;\n }\n\n #handleActivateLayerTree(): void {\n if (!this.#lastFrame) {\n return;\n }\n if (this.#framePendingActivation && !this.#lastNeedsBeginFrame) {\n this.#commitPendingFrame();\n }\n }\n\n #handleRequestMainThreadFrame(): void {\n if (!this.#lastFrame) {\n return;\n }\n this.#mainFrameRequested = true;\n }\n\n #handleCommit(): void {\n if (!this.#framePendingCommit) {\n return;\n }\n this.#framePendingActivation = this.#framePendingCommit;\n this.#framePendingCommit = null;\n this.#mainFrameRequested = false;\n this.#mainFrameCommitted = true;\n }\n\n #handleLayerTreeSnapshot(layerTree: Types.Events.LegacyFrameLayerTreeData): void {\n this.#lastLayerTree = layerTree;\n }\n\n #handleNeedFrameChanged(startTime: Types.Timing.Micro, needsBeginFrame: boolean): void {\n if (needsBeginFrame) {\n this.#lastNeedsBeginFrame = startTime;\n }\n }\n\n #startFrame(startTime: Types.Timing.Micro, seqId: number): void {\n if (this.#lastFrame) {\n this.#flushFrame(this.#lastFrame, startTime);\n }\n this.#lastFrame =\n new TimelineFrame(seqId, startTime, Types.Timing.Micro(startTime - metaHandlerData().traceBounds.min));\n }\n\n #flushFrame(frame: TimelineFrame, endTime: Types.Timing.Micro): void {\n frame.setLayerTree(this.#lastLayerTree);\n frame.setEndTime(endTime);\n if (this.#lastLayerTree) {\n this.#lastLayerTree.paints = frame.paints;\n }\n const lastFrame = this.#frames[this.#frames.length - 1];\n if (this.#frames.length && lastFrame &&\n (frame.startTime !== lastFrame.endTime || frame.startTime > frame.endTime)) {\n console.assert(\n false, `Inconsistent frame time for frame ${this.#frames.length} (${frame.startTime} - ${frame.endTime})`);\n }\n const newFramesLength = this.#frames.push(frame);\n frame.setIndex(newFramesLength - 1);\n if (typeof frame.mainFrameId === 'number') {\n this.#frameById[frame.mainFrameId] = frame;\n }\n }\n\n #commitPendingFrame(): void {\n if (!this.#framePendingActivation || !this.#lastFrame) {\n return;\n }\n\n this.#lastFrame.paints = this.#framePendingActivation.paints;\n this.#lastFrame.mainFrameId = this.#framePendingActivation.mainFrameId;\n this.#framePendingActivation = null;\n }\n\n #addTraceEvents(\n events: readonly Types.Events.Event[], threadData: Array<{\n pid: Types.Events.ProcessID,\n tid: Types.Events.ThreadID,\n startTime: Types.Timing.Micro,\n }>,\n mainFrameId: string): void {\n let j = 0;\n this.#activeThreadId = threadData.length && threadData[0].tid || null;\n this.#activeProcessId = threadData.length && threadData[0].pid || null;\n for (let i = 0; i < events.length; ++i) {\n while (j + 1 < threadData.length && threadData[j + 1].startTime <= events[i].ts) {\n this.#activeThreadId = threadData[++j].tid;\n this.#activeProcessId = threadData[j].pid;\n }\n this.#addTraceEvent(events[i], mainFrameId);\n }\n this.#activeThreadId = null;\n this.#activeProcessId = null;\n }\n\n #addTraceEvent(event: Types.Events.Event, mainFrameId: string): void {\n if (Types.Events.isSetLayerId(event) && event.args.data.frame === mainFrameId) {\n this.#layerTreeId = event.args.data.layerTreeId;\n } else if (Types.Events.isLayerTreeHostImplSnapshot(event) && Number(event.id) === this.#layerTreeId) {\n this.#handleLayerTreeSnapshot({\n entry: event,\n paints: [],\n });\n } else {\n if (isFrameEvent(event)) {\n this.#processCompositorEvents(event);\n }\n // Make sure we only use events from the main thread: we check the PID as\n // well in case two processes have a thread with the same TID.\n if (event.tid === this.#activeThreadId && event.pid === this.#activeProcessId) {\n this.#addMainThreadTraceEvent(event);\n }\n }\n }\n\n #processCompositorEvents(entry: FrameEvent): void {\n if (entry.args['layerTreeId'] !== this.#layerTreeId) {\n return;\n }\n if (Types.Events.isBeginFrame(entry)) {\n this.#handleBeginFrame(entry.ts, entry.args['frameSeqId']);\n } else if (Types.Events.isDrawFrame(entry)) {\n this.#handleDrawFrame(entry.ts, entry.args['frameSeqId']);\n } else if (Types.Events.isActivateLayerTree(entry)) {\n this.#handleActivateLayerTree();\n } else if (Types.Events.isRequestMainThreadFrame(entry)) {\n this.#handleRequestMainThreadFrame();\n } else if (Types.Events.isNeedsBeginFrameChanged(entry)) {\n // needsBeginFrame property will either be 0 or 1, which represents\n // true/false in this case, hence the Boolean() wrapper.\n this.#handleNeedFrameChanged(entry.ts, entry.args['data'] && Boolean(entry.args['data']['needsBeginFrame']));\n } else if (Types.Events.isDroppedFrame(entry)) {\n this.#handleDroppedFrame(entry.ts, entry.args['frameSeqId'], Boolean(entry.args['hasPartialUpdate']));\n }\n }\n\n #addMainThreadTraceEvent(entry: Types.Events.Event): void {\n if (entryIsTopLevel(entry)) {\n this.#lastTaskBeginTime = entry.ts;\n }\n if (!this.#framePendingCommit && MAIN_FRAME_MARKERS.has(entry.name as Types.Events.Name)) {\n this.#framePendingCommit = new PendingFrame(this.#lastTaskBeginTime || entry.ts);\n }\n if (!this.#framePendingCommit) {\n return;\n }\n\n if (Types.Events.isBeginMainThreadFrame(entry) && entry.args.data.frameId) {\n this.#framePendingCommit.mainFrameId = entry.args.data.frameId;\n }\n if (Types.Events.isPaint(entry)) {\n const snapshot = this.#layerTreeData.paintsToSnapshots.get(entry);\n if (snapshot) {\n this.#framePendingCommit.paints.push(new LayerPaintEvent(entry, snapshot));\n }\n }\n // Commit will be replacing CompositeLayers but CompositeLayers is kept\n // around for backwards compatibility.\n if ((Types.Events.isCompositeLayers(entry) || Types.Events.isCommit(entry)) &&\n entry.args['layerTreeId'] === this.#layerTreeId) {\n this.#handleCommit();\n }\n }\n}\n\n/**\n * Legacy class that represents TimelineFrames that was ported from the old SDK.\n * This class is purposefully not exported as it breaks the abstraction that\n * every event shown on the timeline is a trace event. Instead, we use the Type\n * LegacyTimelineFrame to represent frames in the codebase. These do implement\n * the right interface to be treated just like they were a trace event.\n */\nclass TimelineFrame implements Types.Events.LegacyTimelineFrame {\n // These fields exist to satisfy the base Event type which all\n // \"trace events\" must implement. They aren't used, but doing this means we\n // can pass `TimelineFrame` instances into places that expect\n // Types.Events.Event.\n cat = 'devtools.legacy_frame';\n name = 'frame';\n ph = Types.Events.Phase.COMPLETE;\n ts: Types.Timing.Micro;\n pid = Types.Events.ProcessID(-1);\n tid = Types.Events.ThreadID(-1);\n\n index = -1;\n startTime: Types.Timing.Micro;\n startTimeOffset: Types.Timing.Micro;\n endTime: Types.Timing.Micro;\n duration: Types.Timing.Micro;\n idle: boolean;\n dropped: boolean;\n isPartial: boolean;\n layerTree: Types.Events.LegacyFrameLayerTreeData|null;\n paints: LayerPaintEvent[];\n mainFrameId: number|undefined;\n readonly seqId: number;\n\n constructor(seqId: number, startTime: Types.Timing.Micro, startTimeOffset: Types.Timing.Micro) {\n this.seqId = seqId;\n this.startTime = startTime;\n this.ts = startTime;\n this.startTimeOffset = startTimeOffset;\n this.endTime = this.startTime;\n this.duration = Types.Timing.Micro(0);\n this.idle = false;\n this.dropped = false;\n this.isPartial = false;\n this.layerTree = null;\n this.paints = [];\n this.mainFrameId = undefined;\n }\n\n setIndex(i: number): void {\n this.index = i;\n }\n\n setEndTime(endTime: Types.Timing.Micro): void {\n this.endTime = endTime;\n this.duration = Types.Timing.Micro(this.endTime - this.startTime);\n }\n\n setLayerTree(layerTree: Types.Events.LegacyFrameLayerTreeData|null): void {\n this.layerTree = layerTree;\n }\n\n /**\n * Fake the `dur` field to meet the expected value given that we pretend\n * these TimelineFrame classes are trace events across the codebase.\n */\n get dur(): Types.Timing.Micro {\n return this.duration;\n }\n}\n\nexport class LayerPaintEvent implements Types.Events.LegacyLayerPaintEvent {\n readonly #event: Types.Events.Paint;\n #snapshot: Types.Events.DisplayItemListSnapshot;\n\n constructor(event: Types.Events.Paint, snapshot: Types.Events.DisplayItemListSnapshot) {\n this.#event = event;\n this.#snapshot = snapshot;\n }\n\n layerId(): number {\n return this.#event.args.data.layerId;\n }\n\n event(): Types.Events.Paint {\n return this.#event;\n }\n\n picture(): Types.Events.LegacyLayerPaintEventPicture|null {\n const rect = this.#snapshot.args.snapshot.params?.layer_rect;\n const pictureData = this.#snapshot.args.snapshot.skp64;\n return rect && pictureData ? {rect, serializedPicture: pictureData} : null;\n }\n}\n\nexport class PendingFrame {\n paints: LayerPaintEvent[];\n mainFrameId: number|undefined;\n triggerTime: number;\n constructor(triggerTime: number) {\n this.paints = [];\n this.mainFrameId = undefined;\n this.triggerTime = triggerTime;\n }\n}\n\n/** The parameters of an impl-side BeginFrame. **/\nclass BeginFrameInfo {\n seqId: number;\n startTime: Types.Timing.Micro;\n isDropped: boolean;\n isPartial: boolean;\n constructor(seqId: number, startTime: Types.Timing.Micro, isDropped: boolean, isPartial: boolean) {\n this.seqId = seqId;\n this.startTime = startTime;\n this.isDropped = isDropped;\n this.isPartial = isPartial;\n }\n}\n\n/**\n * A queue of BeginFrames pending visualization.\n * BeginFrames are added into this queue as they occur; later when their\n * corresponding DrawFrames occur (or lack thereof), the BeginFrames are removed\n * from the queue and their timestamps are used for visualization.\n **/\nexport class TimelineFrameBeginFrameQueue {\n private queueFrames: number[] = [];\n\n // Maps frameSeqId to BeginFrameInfo.\n private mapFrames: Record<number, BeginFrameInfo> = {};\n\n // Add a BeginFrame to the queue, if it does not already exit.\n addFrameIfNotExists(seqId: number, startTime: Types.Timing.Micro, isDropped: boolean, isPartial: boolean): void {\n if (!(seqId in this.mapFrames)) {\n this.mapFrames[seqId] = new BeginFrameInfo(seqId, startTime, isDropped, isPartial);\n this.queueFrames.push(seqId);\n }\n }\n\n // Set a BeginFrame in queue as dropped.\n setDropped(seqId: number, isDropped: boolean): void {\n if (seqId in this.mapFrames) {\n this.mapFrames[seqId].isDropped = isDropped;\n }\n }\n\n setPartial(seqId: number, isPartial: boolean): void {\n if (seqId in this.mapFrames) {\n this.mapFrames[seqId].isPartial = isPartial;\n }\n }\n\n processPendingBeginFramesOnDrawFrame(seqId: number): BeginFrameInfo[] {\n const framesToVisualize: BeginFrameInfo[] = [];\n\n // Do not visualize this frame in the rare case where the current DrawFrame\n // does not have a corresponding BeginFrame.\n if (seqId in this.mapFrames) {\n // Pop all BeginFrames before the current frame, and add only the dropped\n // ones in |frames_to_visualize|.\n // Non-dropped frames popped here are BeginFrames that are never\n // drawn (but not considered dropped either for some reason).\n // Those frames do not require an proactive visualization effort and will\n // be naturally presented as continuationss of other frames.\n while (this.queueFrames[0] !== seqId) {\n const currentSeqId = this.queueFrames[0];\n if (this.mapFrames[currentSeqId].isDropped) {\n framesToVisualize.push(this.mapFrames[currentSeqId]);\n }\n\n delete this.mapFrames[currentSeqId];\n this.queueFrames.shift();\n }\n\n // Pop the BeginFrame associated with the current DrawFrame.\n framesToVisualize.push(this.mapFrames[seqId]);\n delete this.mapFrames[seqId];\n this.queueFrames.shift();\n }\n return framesToVisualize;\n }\n}\n\nexport function framesWithinWindow(\n frames: readonly Types.Events.LegacyTimelineFrame[], startTime: Types.Timing.Micro,\n endTime: Types.Timing.Micro): Types.Events.LegacyTimelineFrame[] {\n const firstFrame = Platform.ArrayUtilities.lowerBound(frames, startTime || 0, (time, frame) => time - frame.endTime);\n const lastFrame =\n Platform.ArrayUtilities.lowerBound(frames, endTime || Infinity, (time, frame) => time - frame.startTime);\n return frames.slice(firstFrame, lastFrame);\n}\n"]}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Chromium Authors. All rights reserved.
1
+ // Copyright 2022 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
  import * as Helpers from '../helpers/helpers.js';
@@ -6,10 +6,10 @@ import * as Types from '../types/types.js';
6
6
  import { data as metaHandlerData } from './MetaHandler.js';
7
7
  // Each thread contains events. Events indicate the thread and process IDs, which are
8
8
  // used to store the event in the correct process thread entry below.
9
- const eventsInProcessThread = new Map();
9
+ let eventsInProcessThread = new Map();
10
10
  let mainGPUThreadTasks = [];
11
11
  export function reset() {
12
- eventsInProcessThread.clear();
12
+ eventsInProcessThread = new Map();
13
13
  mainGPUThreadTasks = [];
14
14
  }
15
15
  export function handleEvent(event) {
@@ -1 +1 @@
1
- {"version":3,"file":"GPUHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/GPUHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAGzD,qFAAqF;AACrF,qEAAqE;AACrE,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAA8E,CAAC;AAEpH,IAAI,kBAAkB,GAA2B,EAAE,CAAC;AAEpD,MAAM,UAAU,KAAK;IACnB,qBAAqB,CAAC,KAAK,EAAE,CAAC;IAC9B,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAyB;IACnD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO;IACT,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,EAAC,YAAY,EAAE,WAAW,EAAC,GAAG,eAAe,EAAE,CAAC;IACtD,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACrE,IAAI,oBAAoB,IAAI,WAAW,EAAE,CAAC;QACxC,kBAAkB,GAAG,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IACnE,CAAC;AACH,CAAC;AAMD,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,kBAAkB;KACnB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\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 {data as metaHandlerData} from './MetaHandler.js';\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.\nconst eventsInProcessThread = new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.GPUTask[]>>();\n\nlet mainGPUThreadTasks: Types.Events.GPUTask[] = [];\n\nexport function reset(): void {\n eventsInProcessThread.clear();\n mainGPUThreadTasks = [];\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (!Types.Events.isGPUTask(event)) {\n return;\n }\n\n Helpers.Trace.addEventToProcessThread(event, eventsInProcessThread);\n}\n\nexport async function finalize(): Promise<void> {\n const {gpuProcessId, gpuThreadId} = metaHandlerData();\n const gpuThreadsForProcess = eventsInProcessThread.get(gpuProcessId);\n if (gpuThreadsForProcess && gpuThreadId) {\n mainGPUThreadTasks = gpuThreadsForProcess.get(gpuThreadId) || [];\n }\n}\n\nexport interface GPUHandlerReturnData {\n mainGPUThreadTasks: readonly Types.Events.GPUTask[];\n}\n\nexport function data(): GPUHandlerReturnData {\n return {\n mainGPUThreadTasks,\n };\n}\n\nexport function deps(): HandlerName[] {\n return ['Meta'];\n}\n"]}
1
+ {"version":3,"file":"GPUHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/GPUHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAGzD,qFAAqF;AACrF,qEAAqE;AACrE,IAAI,qBAAqB,GAAG,IAAI,GAAG,EAA8E,CAAC;AAElH,IAAI,kBAAkB,GAA2B,EAAE,CAAC;AAEpD,MAAM,UAAU,KAAK;IACnB,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;IAClC,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAyB;IACnD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO;IACT,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,EAAC,YAAY,EAAE,WAAW,EAAC,GAAG,eAAe,EAAE,CAAC;IACtD,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACrE,IAAI,oBAAoB,IAAI,WAAW,EAAE,CAAC;QACxC,kBAAkB,GAAG,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IACnE,CAAC;AACH,CAAC;AAMD,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,kBAAkB;KACnB,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 {data as metaHandlerData} from './MetaHandler.js';\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 eventsInProcessThread = new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.GPUTask[]>>();\n\nlet mainGPUThreadTasks: Types.Events.GPUTask[] = [];\n\nexport function reset(): void {\n eventsInProcessThread = new Map();\n mainGPUThreadTasks = [];\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (!Types.Events.isGPUTask(event)) {\n return;\n }\n\n Helpers.Trace.addEventToProcessThread(event, eventsInProcessThread);\n}\n\nexport async function finalize(): Promise<void> {\n const {gpuProcessId, gpuThreadId} = metaHandlerData();\n const gpuThreadsForProcess = eventsInProcessThread.get(gpuProcessId);\n if (gpuThreadsForProcess && gpuThreadId) {\n mainGPUThreadTasks = gpuThreadsForProcess.get(gpuThreadId) || [];\n }\n}\n\nexport interface GPUHandlerReturnData {\n mainGPUThreadTasks: readonly Types.Events.GPUTask[];\n}\n\nexport function data(): GPUHandlerReturnData {\n return {\n mainGPUThreadTasks,\n };\n}\n\nexport function deps(): HandlerName[] {\n return ['Meta'];\n}\n"]}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Chromium Authors. All rights reserved.
1
+ // Copyright 2024 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
  import * as Platform from '../../../core/platform/platform.js';
@@ -20,28 +20,28 @@ import { data as metaHandlerData } from './MetaHandler.js';
20
20
  * use the PaintImage event associated with it via the `LazyPixelRef` key.
21
21
  */
22
22
  // Track paintImageEvents across threads.
23
- const paintImageEvents = new Map();
24
- const decodeLazyPixelRefEvents = new Map();
23
+ let paintImageEvents = new Map();
24
+ let decodeLazyPixelRefEvents = new Map();
25
25
  // A DrawLazyPixelRef event will contain a numerical reference in
26
26
  // args.LazyPixelRef. As we parse each DrawLazyPixelRef, we can assign it to a
27
27
  // paint event. Later we want to look up paint events by this reference, so we
28
28
  // store them in this map.
29
- const paintImageByLazyPixelRef = new Map();
29
+ let paintImageByLazyPixelRef = new Map();
30
30
  // When we find events that we want to tie to a particular PaintImage event, we add them to this map.
31
31
  // These are currently only DecodeImage and ResizeImage events, but the type is
32
32
  // deliberately generic as in the future we might want to add more events that
33
33
  // have a relationship to a individual PaintImage event.
34
- const eventToPaintImage = new Map();
35
- const urlToPaintImage = new Map();
36
- const paintEventToCorrectedDisplaySize = new Map();
34
+ let eventToPaintImage = new Map();
35
+ let urlToPaintImage = new Map();
36
+ let paintEventToCorrectedDisplaySize = new Map();
37
37
  let didCorrectForHostDpr = false;
38
38
  export function reset() {
39
- paintImageEvents.clear();
40
- decodeLazyPixelRefEvents.clear();
41
- paintImageByLazyPixelRef.clear();
42
- eventToPaintImage.clear();
43
- urlToPaintImage.clear();
44
- paintEventToCorrectedDisplaySize.clear();
39
+ paintImageEvents = new Map();
40
+ decodeLazyPixelRefEvents = new Map();
41
+ paintImageByLazyPixelRef = new Map();
42
+ eventToPaintImage = new Map();
43
+ urlToPaintImage = new Map();
44
+ paintEventToCorrectedDisplaySize = new Map();
45
45
  didCorrectForHostDpr = false;
46
46
  }
47
47
  export function handleEvent(event) {
@@ -1 +1 @@
1
- {"version":3,"file":"ImagePaintingHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/ImagePaintingHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAGzD;;;;;;;;;;;;;;GAcG;AAEH,yCAAyC;AACzC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAiF,CAAC;AAClH,MAAM,wBAAwB,GAC1B,IAAI,GAAG,EAAyF,CAAC;AAErG,iEAAiE;AACjE,8EAA8E;AAC9E,8EAA8E;AAC9E,0BAA0B;AAC1B,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAmC,CAAC;AAE5E,qGAAqG;AACrG,+EAA+E;AAC/E,8EAA8E;AAC9E,wDAAwD;AACxD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA+C,CAAC;AAEjF,MAAM,eAAe,GAAG,IAAI,GAAG,EAAqC,CAAC;AAErE,MAAM,gCAAgC,GAAG,IAAI,GAAG,EAA4D,CAAC;AAE7G,IAAI,oBAAoB,GAAG,KAAK,CAAC;AAEjC,MAAM,UAAU,KAAK;IACnB,gBAAgB,CAAC,KAAK,EAAE,CAAC;IACzB,wBAAwB,CAAC,KA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AAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAC7E,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAC/E,MAAM,KAAK,GAAG,cAAc,GAAG,WAAW,CAAC;gBAC3C,MAAM,MAAM,GAAG,eAAe,GAAG,WAAW,CAAC;gBAC7C,gCAAgC,CAAC,GAAG,CAAC,UAAU,EAAE,EAAC,KAAK,EAAE,MAAM,EAAC,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IAED,oBAAoB,GAAG,IAAI,CAAC;AAC9B,CAAC;AAWD,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,4BAA4B,EAAE,wBAAwB;QACtD,kBAAkB,EAAE,iBAAiB;QACrC,qBAAqB,EAAE,eAAe;QACtC,gCAAgC;QAChC,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Types from '../types/types.js';\n\nimport {data as metaHandlerData} from './MetaHandler.js';\nimport type {FinalizeOptions} from './types.js';\n\n/**\n * This handler is responsible for the relationships between:\n * DecodeImage/ResizeImage, PaintImage and DrawLazyPixelRef events.\n *\n * When we get a DecodeImage event, we want to associate it to a PaintImage\n * event, primarily so we can determine the NodeID of the image that was\n * decoded.\n * We can do this in two ways:\n *\n * 1. If there is a PaintImage event on the same thread, use that\n * (if there are multiple, use the latest one).\n *\n * 2. If not, we can find the DecodeLazyPixelRef event on the same thread, and\n * use the PaintImage event associated with it via the `LazyPixelRef` key.\n */\n\n// Track paintImageEvents across threads.\nconst paintImageEvents = new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.PaintImage[]>>();\nconst decodeLazyPixelRefEvents =\n new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.DecodeLazyPixelRef[]>>();\n\n// A DrawLazyPixelRef event will contain a numerical reference in\n// args.LazyPixelRef. As we parse each DrawLazyPixelRef, we can assign it to a\n// paint event. Later we want to look up paint events by this reference, so we\n// store them in this map.\nconst paintImageByLazyPixelRef = new Map<number, Types.Events.PaintImage>();\n\n// When we find events that we want to tie to a particular PaintImage event, we add them to this map.\n// These are currently only DecodeImage and ResizeImage events, but the type is\n// deliberately generic as in the future we might want to add more events that\n// have a relationship to a individual PaintImage event.\nconst eventToPaintImage = new Map<Types.Events.Event, Types.Events.PaintImage>();\n\nconst urlToPaintImage = new Map<string, Types.Events.PaintImage[]>();\n\nconst paintEventToCorrectedDisplaySize = new Map<Types.Events.PaintImage, {width: number, height: number}>();\n\nlet didCorrectForHostDpr = false;\n\nexport function reset(): void {\n paintImageEvents.clear();\n decodeLazyPixelRefEvents.clear();\n paintImageByLazyPixelRef.clear();\n eventToPaintImage.clear();\n urlToPaintImage.clear();\n paintEventToCorrectedDisplaySize.clear();\n didCorrectForHostDpr = false;\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (Types.Events.isPaintImage(event)) {\n const forProcess = paintImageEvents.get(event.pid) || new Map<Types.Events.ThreadID, Types.Events.PaintImage[]>();\n const forThread = forProcess.get(event.tid) || [];\n forThread.push(event);\n forProcess.set(event.tid, forThread);\n paintImageEvents.set(event.pid, forProcess);\n\n if (event.args.data.url) {\n const paintsForUrl = Platform.MapUtilities.getWithDefault(urlToPaintImage, event.args.data.url, () => []);\n paintsForUrl.push(event);\n }\n\n return;\n }\n\n if (Types.Events.isDecodeLazyPixelRef(event) && typeof event.args?.LazyPixelRef !== 'undefined') {\n // Store these because we use them to tie DecodeImage to a PaintEvent.\n const forProcess =\n decodeLazyPixelRefEvents.get(event.pid) || new Map<Types.Events.ThreadID, Types.Events.DecodeLazyPixelRef[]>();\n const forThread = forProcess.get(event.tid) || [];\n forThread.push(event);\n forProcess.set(event.tid, forThread);\n decodeLazyPixelRefEvents.set(event.pid, forProcess);\n }\n\n // If we see a DrawLazyPixelRef event, we need to find the last PaintImage\n // event on the thread and associate it to the LazyPixelRef that is supplied\n // in the DrawLazyPixelRef event.\n // This means that later on if we see a DecodeLazyPixelRef event with the\n // same LazyPixelRef key, we can find its associated PaintImage event by\n // looking it up.\n if (Types.Events.isDrawLazyPixelRef(event) && typeof event.args?.LazyPixelRef !== 'undefined') {\n const lastPaintEvent = paintImageEvents.get(event.pid)?.get(event.tid)?.at(-1);\n if (!lastPaintEvent) {\n return;\n }\n paintImageByLazyPixelRef.set(event.args.LazyPixelRef, lastPaintEvent);\n return;\n }\n\n if (Types.Events.isDecodeImage(event)) {\n // When we see a DecodeImage, we want to associate it to a PaintImage\n // event. We try two approaches:\n //\n // 1. If the thread of the DecodeImage event has a previous PaintImage\n // event, that is the associated event.\n //\n // 2. If that is false, we then look on the thread for a DecodeLazyPixelRef\n // event. If we find that, we then look for its associated PaintImage\n // event, which we associate via DrawLazyPixelRef events (the code block\n // above this one)\n //\n // 1. Find a PaintImage event on the same thread. If we find it, that's our association done.\n const lastPaintImageEventOnThread = paintImageEvents.get(event.pid)?.get(event.tid)?.at(-1);\n if (lastPaintImageEventOnThread) {\n eventToPaintImage.set(event, lastPaintImageEventOnThread);\n return;\n }\n\n // 2. Find the last DecodeLazyPixelRef event and, if we find it, find its associated PaintImage event.\n const lastDecodeLazyPixelRef = decodeLazyPixelRefEvents.get(event.pid)?.get(event.tid)?.at(-1);\n if (typeof lastDecodeLazyPixelRef?.args?.LazyPixelRef === 'undefined') {\n return;\n }\n\n const paintEvent = paintImageByLazyPixelRef.get(lastDecodeLazyPixelRef.args.LazyPixelRef);\n if (!paintEvent) {\n return;\n }\n eventToPaintImage.set(event, paintEvent);\n }\n}\n\nexport async function finalize(options: FinalizeOptions): Promise<void> {\n // Painting in Chrome never uses the emulated DPR, but instead used the host's DPR.\n // We need to correct for that for our responsive image checks in the ImageDelivery\n // insight.\n // See: crbug.com/427552461 crbug.com/416580500#comment5\n\n if (!options.metadata?.hostDPR) {\n return;\n }\n\n // Note: this isn't necessarily emulated (for desktop+no DPR emulation, it's equal\n // to host DPR).\n const {devicePixelRatio: emulatedDpr} = metaHandlerData();\n if (!emulatedDpr) {\n return;\n }\n\n for (const byThread of paintImageEvents.values()) {\n for (const paintEvents of byThread.values()) {\n for (const paintEvent of paintEvents) {\n const cssPixelsWidth = paintEvent.args.data.width / options.metadata.hostDPR;\n const cssPixelsHeight = paintEvent.args.data.height / options.metadata.hostDPR;\n const width = cssPixelsWidth * emulatedDpr;\n const height = cssPixelsHeight * emulatedDpr;\n paintEventToCorrectedDisplaySize.set(paintEvent, {width, height});\n }\n }\n }\n\n didCorrectForHostDpr = true;\n}\n\nexport interface ImagePaintData {\n paintImageByDrawLazyPixelRef: Map<number, Types.Events.PaintImage>;\n paintImageForEvent: Map<Types.Events.Event, Types.Events.PaintImage>;\n paintImageEventForUrl: Map<string, Types.Events.PaintImage[]>;\n paintEventToCorrectedDisplaySize: Map<Types.Events.PaintImage, {width: number, height: number}>;\n /** Go read the comment in finalize(). */\n didCorrectForHostDpr: boolean;\n}\n\nexport function data(): ImagePaintData {\n return {\n paintImageByDrawLazyPixelRef: paintImageByLazyPixelRef,\n paintImageForEvent: eventToPaintImage,\n paintImageEventForUrl: urlToPaintImage,\n paintEventToCorrectedDisplaySize,\n didCorrectForHostDpr,\n };\n}\n"]}
1
+ {"version":3,"file":"ImagePaintingHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/ImagePaintingHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAGzD;;;;;;;;;;;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,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Types from '../types/types.js';\n\nimport {data as metaHandlerData} from './MetaHandler.js';\nimport type {FinalizeOptions} from './types.js';\n\n/**\n * This handler is responsible for the relationships between:\n * DecodeImage/ResizeImage, PaintImage and DrawLazyPixelRef events.\n *\n * When we get a DecodeImage event, we want to associate it to a PaintImage\n * event, primarily so we can determine the NodeID of the image that was\n * decoded.\n * We can do this in two ways:\n *\n * 1. If there is a PaintImage event on the same thread, use that\n * (if there are multiple, use the latest one).\n *\n * 2. If not, we can find the DecodeLazyPixelRef event on the same thread, and\n * use the PaintImage event associated with it via the `LazyPixelRef` key.\n */\n\n// Track paintImageEvents across threads.\nlet paintImageEvents = new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.PaintImage[]>>();\nlet decodeLazyPixelRefEvents =\n new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.DecodeLazyPixelRef[]>>();\n\n// A DrawLazyPixelRef event will contain a numerical reference in\n// args.LazyPixelRef. As we parse each DrawLazyPixelRef, we can assign it to a\n// paint event. Later we want to look up paint events by this reference, so we\n// store them in this map.\nlet paintImageByLazyPixelRef = new Map<number, Types.Events.PaintImage>();\n\n// When we find events that we want to tie to a particular PaintImage event, we add them to this map.\n// These are currently only DecodeImage and ResizeImage events, but the type is\n// deliberately generic as in the future we might want to add more events that\n// have a relationship to a individual PaintImage event.\nlet eventToPaintImage = new Map<Types.Events.Event, Types.Events.PaintImage>();\n\nlet urlToPaintImage = new Map<string, Types.Events.PaintImage[]>();\n\nlet paintEventToCorrectedDisplaySize = new Map<Types.Events.PaintImage, {width: number, height: number}>();\n\nlet didCorrectForHostDpr = false;\n\nexport function reset(): void {\n paintImageEvents = new Map();\n decodeLazyPixelRefEvents = new Map();\n paintImageByLazyPixelRef = new Map();\n eventToPaintImage = new Map();\n urlToPaintImage = new Map();\n paintEventToCorrectedDisplaySize = new Map();\n didCorrectForHostDpr = false;\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n if (Types.Events.isPaintImage(event)) {\n const forProcess = paintImageEvents.get(event.pid) || new Map<Types.Events.ThreadID, Types.Events.PaintImage[]>();\n const forThread = forProcess.get(event.tid) || [];\n forThread.push(event);\n forProcess.set(event.tid, forThread);\n paintImageEvents.set(event.pid, forProcess);\n\n if (event.args.data.url) {\n const paintsForUrl = Platform.MapUtilities.getWithDefault(urlToPaintImage, event.args.data.url, () => []);\n paintsForUrl.push(event);\n }\n\n return;\n }\n\n if (Types.Events.isDecodeLazyPixelRef(event) && typeof event.args?.LazyPixelRef !== 'undefined') {\n // Store these because we use them to tie DecodeImage to a PaintEvent.\n const forProcess =\n decodeLazyPixelRefEvents.get(event.pid) || new Map<Types.Events.ThreadID, Types.Events.DecodeLazyPixelRef[]>();\n const forThread = forProcess.get(event.tid) || [];\n forThread.push(event);\n forProcess.set(event.tid, forThread);\n decodeLazyPixelRefEvents.set(event.pid, forProcess);\n }\n\n // If we see a DrawLazyPixelRef event, we need to find the last PaintImage\n // event on the thread and associate it to the LazyPixelRef that is supplied\n // in the DrawLazyPixelRef event.\n // This means that later on if we see a DecodeLazyPixelRef event with the\n // same LazyPixelRef key, we can find its associated PaintImage event by\n // looking it up.\n if (Types.Events.isDrawLazyPixelRef(event) && typeof event.args?.LazyPixelRef !== 'undefined') {\n const lastPaintEvent = paintImageEvents.get(event.pid)?.get(event.tid)?.at(-1);\n if (!lastPaintEvent) {\n return;\n }\n paintImageByLazyPixelRef.set(event.args.LazyPixelRef, lastPaintEvent);\n return;\n }\n\n if (Types.Events.isDecodeImage(event)) {\n // When we see a DecodeImage, we want to associate it to a PaintImage\n // event. We try two approaches:\n //\n // 1. If the thread of the DecodeImage event has a previous PaintImage\n // event, that is the associated event.\n //\n // 2. If that is false, we then look on the thread for a DecodeLazyPixelRef\n // event. If we find that, we then look for its associated PaintImage\n // event, which we associate via DrawLazyPixelRef events (the code block\n // above this one)\n //\n // 1. Find a PaintImage event on the same thread. If we find it, that's our association done.\n const lastPaintImageEventOnThread = paintImageEvents.get(event.pid)?.get(event.tid)?.at(-1);\n if (lastPaintImageEventOnThread) {\n eventToPaintImage.set(event, lastPaintImageEventOnThread);\n return;\n }\n\n // 2. Find the last DecodeLazyPixelRef event and, if we find it, find its associated PaintImage event.\n const lastDecodeLazyPixelRef = decodeLazyPixelRefEvents.get(event.pid)?.get(event.tid)?.at(-1);\n if (typeof lastDecodeLazyPixelRef?.args?.LazyPixelRef === 'undefined') {\n return;\n }\n\n const paintEvent = paintImageByLazyPixelRef.get(lastDecodeLazyPixelRef.args.LazyPixelRef);\n if (!paintEvent) {\n return;\n }\n eventToPaintImage.set(event, paintEvent);\n }\n}\n\nexport async function finalize(options: FinalizeOptions): Promise<void> {\n // Painting in Chrome never uses the emulated DPR, but instead used the host's DPR.\n // We need to correct for that for our responsive image checks in the ImageDelivery\n // insight.\n // See: crbug.com/427552461 crbug.com/416580500#comment5\n\n if (!options.metadata?.hostDPR) {\n return;\n }\n\n // Note: this isn't necessarily emulated (for desktop+no DPR emulation, it's equal\n // to host DPR).\n const {devicePixelRatio: emulatedDpr} = metaHandlerData();\n if (!emulatedDpr) {\n return;\n }\n\n for (const byThread of paintImageEvents.values()) {\n for (const paintEvents of byThread.values()) {\n for (const paintEvent of paintEvents) {\n const cssPixelsWidth = paintEvent.args.data.width / options.metadata.hostDPR;\n const cssPixelsHeight = paintEvent.args.data.height / options.metadata.hostDPR;\n const width = cssPixelsWidth * emulatedDpr;\n const height = cssPixelsHeight * emulatedDpr;\n paintEventToCorrectedDisplaySize.set(paintEvent, {width, height});\n }\n }\n }\n\n didCorrectForHostDpr = true;\n}\n\nexport interface ImagePaintData {\n paintImageByDrawLazyPixelRef: Map<number, Types.Events.PaintImage>;\n paintImageForEvent: Map<Types.Events.Event, Types.Events.PaintImage>;\n paintImageEventForUrl: Map<string, Types.Events.PaintImage[]>;\n paintEventToCorrectedDisplaySize: Map<Types.Events.PaintImage, {width: number, height: number}>;\n /** Go read the comment in finalize(). */\n didCorrectForHostDpr: boolean;\n}\n\nexport function data(): ImagePaintData {\n return {\n paintImageByDrawLazyPixelRef: paintImageByLazyPixelRef,\n paintImageForEvent: eventToPaintImage,\n paintImageEventForUrl: urlToPaintImage,\n paintEventToCorrectedDisplaySize,\n didCorrectForHostDpr,\n };\n}\n"]}
@@ -1,44 +1,38 @@
1
- // Copyright 2023 The Chromium Authors. All rights reserved.
1
+ // Copyright 2023 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
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
6
  import { data as AsyncJSCallsHandlerData } from './AsyncJSCallsHandler.js';
7
7
  import { data as flowsHandlerData } from './FlowsHandler.js';
8
- const lastScheduleStyleRecalcByFrame = new Map();
8
+ let lastScheduleStyleRecalcByFrame = new Map();
9
9
  // This tracks the last event that is considered to have invalidated the layout
10
10
  // for a given frame.
11
11
  // Note that although there is an InvalidateLayout event, there are also other
12
12
  // events (ScheduleStyleRecalculation) that could be the reason a layout was
13
13
  // invalidated.
14
- const lastInvalidationEventForFrame = new Map();
15
- // Important: although the event is called UpdateLayoutTree, in the UI we
16
- // present these to the user as "Recalculate Style". So don't get confused!
17
- // These are the same - just UpdateLayoutTree is what the event from Chromium
18
- // is called.
19
- const lastUpdateLayoutTreeByFrame = new Map();
14
+ let lastInvalidationEventForFrame = new Map();
15
+ let lastRecalcByFrame = new Map();
20
16
  // These two maps store the same data but in different directions.
21
17
  // For a given event, tell me what its initiator was. An event can only have one initiator.
22
- const eventToInitiatorMap = new Map();
18
+ let eventToInitiatorMap = new Map();
23
19
  // For a given event, tell me what events it initiated. An event can initiate
24
20
  // multiple events, hence why the value for this map is an array.
25
- const initiatorToEventsMap = new Map();
26
- const requestAnimationFrameEventsById = new Map();
27
- const timerInstallEventsById = new Map();
28
- const requestIdleCallbackEventsById = new Map();
29
- const webSocketCreateEventsById = new Map();
30
- const schedulePostTaskCallbackEventsById = new Map();
21
+ let initiatorToEventsMap = new Map();
22
+ let timerInstallEventsById = new Map();
23
+ let requestIdleCallbackEventsById = new Map();
24
+ let webSocketCreateEventsById = new Map();
25
+ let schedulePostTaskCallbackEventsById = new Map();
31
26
  export function reset() {
32
- lastScheduleStyleRecalcByFrame.clear();
33
- lastInvalidationEventForFrame.clear();
34
- lastUpdateLayoutTreeByFrame.clear();
35
- timerInstallEventsById.clear();
36
- eventToInitiatorMap.clear();
37
- initiatorToEventsMap.clear();
38
- requestAnimationFrameEventsById.clear();
39
- requestIdleCallbackEventsById.clear();
40
- webSocketCreateEventsById.clear();
41
- schedulePostTaskCallbackEventsById.clear();
27
+ lastScheduleStyleRecalcByFrame = new Map();
28
+ lastInvalidationEventForFrame = new Map();
29
+ lastRecalcByFrame = new Map();
30
+ timerInstallEventsById = new Map();
31
+ eventToInitiatorMap = new Map();
32
+ initiatorToEventsMap = new Map();
33
+ requestIdleCallbackEventsById = new Map();
34
+ webSocketCreateEventsById = new Map();
35
+ schedulePostTaskCallbackEventsById = new Map();
42
36
  }
43
37
  function storeInitiator(data) {
44
38
  eventToInitiatorMap.set(data.event, data.initiator);
@@ -60,14 +54,11 @@ export function handleEvent(event) {
60
54
  if (Types.Events.isScheduleStyleRecalculation(event)) {
61
55
  lastScheduleStyleRecalcByFrame.set(event.args.data.frame, event);
62
56
  }
63
- else if (Types.Events.isUpdateLayoutTree(event)) {
64
- // IMPORTANT: although the trace event is called UpdateLayoutTree, this
65
- // represents a Styles Recalculation. This event in the timeline is shown to
66
- // the user as "Recalculate Styles."
57
+ else if (Types.Events.isRecalcStyle(event)) {
67
58
  if (event.args.beginData) {
68
- // Store the last UpdateLayout event: we use this when we see an
59
+ // Store the last RecalcStyle event: we use this when we see an
69
60
  // InvalidateLayout and try to figure out its initiator.
70
- lastUpdateLayoutTreeByFrame.set(event.args.beginData.frame, event);
61
+ lastRecalcByFrame.set(event.args.beginData.frame, event);
71
62
  // If this frame has seen a ScheduleStyleRecalc event, then that event is
72
63
  // considered to be the initiator of this StylesRecalc.
73
64
  const scheduledStyleForFrame = lastScheduleStyleRecalcByFrame.get(event.args.beginData.frame);
@@ -87,16 +78,16 @@ export function handleEvent(event) {
87
78
  // cause of this layout invalidation.
88
79
  if (!lastInvalidationEventForFrame.has(event.args.data.frame)) {
89
80
  // 1. If we have not had an invalidation event for this frame
90
- // 2. AND we have had an UpdateLayoutTree for this frame
91
- // 3. AND the UpdateLayoutTree event ended AFTER the InvalidateLayout startTime
92
- // 4. AND we have an initiator for the UpdateLayoutTree event
93
- // 5. Then we set the last invalidation event for this frame to be the UpdateLayoutTree's initiator.
94
- const lastUpdateLayoutTreeForFrame = lastUpdateLayoutTreeByFrame.get(event.args.data.frame);
95
- if (lastUpdateLayoutTreeForFrame) {
96
- const { endTime } = Helpers.Timing.eventTimingsMicroSeconds(lastUpdateLayoutTreeForFrame);
97
- const initiatorOfUpdateLayout = eventToInitiatorMap.get(lastUpdateLayoutTreeForFrame);
98
- if (initiatorOfUpdateLayout && endTime && endTime > event.ts) {
99
- invalidationInitiator = initiatorOfUpdateLayout;
81
+ // 2. AND we have had an RecalcStyle for this frame
82
+ // 3. AND the RecalcStyle event ended AFTER the InvalidateLayout startTime
83
+ // 4. AND we have an initiator for the RecalcStyle event
84
+ // 5. Then we set the last invalidation event for this frame to be the RecalcStyle's initiator.
85
+ const lastRecalcStyleForFrame = lastRecalcByFrame.get(event.args.data.frame);
86
+ if (lastRecalcStyleForFrame) {
87
+ const { endTime } = Helpers.Timing.eventTimingsMicroSeconds(lastRecalcStyleForFrame);
88
+ const initiatorOfRecalcStyle = eventToInitiatorMap.get(lastRecalcStyleForFrame);
89
+ if (initiatorOfRecalcStyle && endTime && endTime > event.ts) {
90
+ invalidationInitiator = initiatorOfRecalcStyle;
100
91
  }
101
92
  }
102
93
  }