@paulirish/trace_engine 0.0.10 → 0.0.12

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 (256) hide show
  1. package/README.md +1 -1
  2. package/analyze-trace.mjs +1 -1
  3. package/core/platform/DevToolsPath.d.ts +4 -13
  4. package/core/platform/DevToolsPath.js +7 -4
  5. package/core/platform/DevToolsPath.js.map +1 -7
  6. package/core/platform/MimeType.d.ts +27 -0
  7. package/core/platform/MimeType.js +119 -86
  8. package/core/platform/MimeType.js.map +1 -7
  9. package/core/platform/Timing.d.ts +7 -0
  10. package/core/platform/Timing.js +7 -4
  11. package/core/platform/Timing.js.map +1 -7
  12. package/core/platform/UIString.d.ts +2 -5
  13. package/core/platform/UIString.js +5 -2
  14. package/core/platform/UIString.js.map +1 -7
  15. package/core/platform/UserVisibleError.js +19 -10
  16. package/core/platform/UserVisibleError.js.map +1 -7
  17. package/core/platform/array-utilities.d.ts +48 -10
  18. package/core/platform/array-utilities.js +160 -124
  19. package/core/platform/array-utilities.js.map +1 -7
  20. package/core/platform/brand.d.ts +14 -0
  21. package/core/platform/brand.js +5 -1
  22. package/core/platform/brand.js.map +1 -7
  23. package/core/platform/date-utilities.js +10 -6
  24. package/core/platform/date-utilities.js.map +1 -7
  25. package/core/platform/dom-utilities.d.ts +3 -1
  26. package/core/platform/dom-utilities.js +94 -83
  27. package/core/platform/dom-utilities.js.map +1 -7
  28. package/core/platform/keyboard-utilities.d.ts +2 -0
  29. package/core/platform/keyboard-utilities.js +15 -24
  30. package/core/platform/keyboard-utilities.js.map +1 -7
  31. package/core/platform/map-utilities.d.ts +4 -0
  32. package/core/platform/map-utilities.js +66 -60
  33. package/core/platform/map-utilities.js.map +1 -7
  34. package/core/platform/number-utilities.js +66 -55
  35. package/core/platform/number-utilities.js.map +1 -7
  36. package/core/platform/platform.d.ts +5 -1
  37. package/core/platform/platform.js +54 -37
  38. package/core/platform/platform.js.map +1 -7
  39. package/core/platform/promise-utilities.d.ts +10 -0
  40. package/core/platform/promise-utilities.js +16 -8
  41. package/core/platform/promise-utilities.js.map +1 -7
  42. package/core/platform/set-utilities.js +20 -17
  43. package/core/platform/set-utilities.js.map +1 -7
  44. package/core/platform/string-utilities.d.ts +32 -1
  45. package/core/platform/string-utilities.js +453 -379
  46. package/core/platform/string-utilities.js.map +1 -7
  47. package/core/platform/typescript-utilities.d.ts +5 -5
  48. package/core/platform/typescript-utilities.js +19 -7
  49. package/core/platform/typescript-utilities.js.map +1 -7
  50. package/generated/protocol.d.ts +2081 -347
  51. package/generated/protocol.js +5 -2230
  52. package/models/cpu_profile/CPUProfileDataModel.d.ts +77 -0
  53. package/models/cpu_profile/CPUProfileDataModel.js +492 -359
  54. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -7
  55. package/models/cpu_profile/ProfileTreeModel.d.ts +29 -0
  56. package/models/cpu_profile/ProfileTreeModel.js +87 -82
  57. package/models/cpu_profile/ProfileTreeModel.js.map +1 -7
  58. package/models/cpu_profile/cpu_profile.d.ts +3 -0
  59. package/models/cpu_profile/cpu_profile.js +7 -7
  60. package/models/cpu_profile/cpu_profile.js.map +1 -7
  61. package/models/trace/EntriesFilter.d.ts +55 -0
  62. package/models/trace/EntriesFilter.js +227 -166
  63. package/models/trace/EntriesFilter.js.map +1 -7
  64. package/models/trace/LegacyTracingModel.js.map +1 -7
  65. package/models/trace/ModelImpl.d.ts +110 -0
  66. package/models/trace/ModelImpl.js +161 -102
  67. package/models/trace/ModelImpl.js.map +1 -7
  68. package/models/trace/Processor.d.ts +36 -0
  69. package/models/trace/Processor.js +197 -163
  70. package/models/trace/Processor.js.map +1 -7
  71. package/models/trace/TracingManager.js.map +1 -7
  72. package/models/trace/extras/FetchNodes.d.ts +46 -0
  73. package/models/trace/extras/FetchNodes.js +132 -91
  74. package/models/trace/extras/FetchNodes.js.map +1 -7
  75. package/models/trace/extras/FilmStrip.d.ts +19 -0
  76. package/models/trace/extras/FilmStrip.js +38 -31
  77. package/models/trace/extras/FilmStrip.js.map +1 -7
  78. package/models/trace/extras/MainThreadActivity.d.ts +2 -0
  79. package/models/trace/extras/MainThreadActivity.js +72 -56
  80. package/models/trace/extras/MainThreadActivity.js.map +1 -7
  81. package/models/trace/extras/Metadata.d.ts +2 -0
  82. package/models/trace/extras/Metadata.js +42 -26
  83. package/models/trace/extras/Metadata.js.map +1 -7
  84. package/models/trace/extras/extras.js.map +1 -7
  85. package/models/trace/handlers/AnimationHandler.d.ts +8 -0
  86. package/models/trace/handlers/AnimationHandler.js +22 -20
  87. package/models/trace/handlers/AnimationHandler.js.map +1 -7
  88. package/models/trace/handlers/AuctionWorkletsHandler.d.ts +8 -0
  89. package/models/trace/handlers/AuctionWorkletsHandler.js +143 -89
  90. package/models/trace/handlers/AuctionWorkletsHandler.js.map +1 -7
  91. package/models/trace/handlers/FramesHandler.d.ts +76 -0
  92. package/models/trace/handlers/FramesHandler.js +424 -355
  93. package/models/trace/handlers/FramesHandler.js.map +1 -7
  94. package/models/trace/handlers/GPUHandler.d.ts +11 -0
  95. package/models/trace/handlers/GPUHandler.js +41 -37
  96. package/models/trace/handlers/GPUHandler.js.map +1 -7
  97. package/models/trace/handlers/InitiatorsHandler.d.ts +10 -0
  98. package/models/trace/handlers/InitiatorsHandler.js +164 -113
  99. package/models/trace/handlers/InitiatorsHandler.js.map +1 -7
  100. package/models/trace/handlers/InvalidationsHandler.d.ts +10 -0
  101. package/models/trace/handlers/InvalidationsHandler.js +101 -79
  102. package/models/trace/handlers/InvalidationsHandler.js.map +1 -7
  103. package/models/trace/handlers/LargestImagePaintHandler.d.ts +5 -0
  104. package/models/trace/handlers/LargestImagePaintHandler.js +32 -12
  105. package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -7
  106. package/models/trace/handlers/LargestTextPaintHandler.d.ts +5 -0
  107. package/models/trace/handlers/LargestTextPaintHandler.js +20 -12
  108. package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -7
  109. package/models/trace/handlers/LayerTreeHandler.d.ts +13 -0
  110. package/models/trace/handlers/LayerTreeHandler.js +96 -70
  111. package/models/trace/handlers/LayerTreeHandler.js.map +1 -7
  112. package/models/trace/handlers/LayoutShiftsHandler.d.ts +44 -0
  113. package/models/trace/handlers/LayoutShiftsHandler.js +304 -227
  114. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -7
  115. package/models/trace/handlers/MemoryHandler.d.ts +7 -0
  116. package/models/trace/handlers/MemoryHandler.js +14 -11
  117. package/models/trace/handlers/MemoryHandler.js.map +1 -7
  118. package/models/trace/handlers/MetaHandler.d.ts +37 -0
  119. package/models/trace/handlers/MetaHandler.js +314 -226
  120. package/models/trace/handlers/MetaHandler.js.map +1 -7
  121. package/models/trace/handlers/ModelHandlers.d.ts +21 -0
  122. package/models/trace/handlers/ModelHandlers.js +25 -22
  123. package/models/trace/handlers/ModelHandlers.js.map +1 -7
  124. package/models/trace/handlers/NetworkRequestsHandler.d.ts +17 -0
  125. package/models/trace/handlers/NetworkRequestsHandler.js +342 -218
  126. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -7
  127. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +67 -0
  128. package/models/trace/handlers/PageLoadMetricsHandler.js +357 -284
  129. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -7
  130. package/models/trace/handlers/RendererHandler.d.ts +101 -0
  131. package/models/trace/handlers/RendererHandler.js +295 -191
  132. package/models/trace/handlers/RendererHandler.js.map +1 -7
  133. package/models/trace/handlers/SamplesHandler.d.ts +46 -0
  134. package/models/trace/handlers/SamplesHandler.js +195 -158
  135. package/models/trace/handlers/SamplesHandler.js.map +1 -7
  136. package/models/trace/handlers/ScreenshotsHandler.d.ts +7 -0
  137. package/models/trace/handlers/ScreenshotsHandler.js +63 -41
  138. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -7
  139. package/models/trace/handlers/Threads.d.ts +33 -0
  140. package/models/trace/handlers/Threads.js +85 -67
  141. package/models/trace/handlers/Threads.js.map +1 -7
  142. package/models/trace/handlers/UserInteractionsHandler.d.ts +57 -0
  143. package/models/trace/handlers/UserInteractionsHandler.js +240 -141
  144. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -7
  145. package/models/trace/handlers/UserTimingsHandler.d.ts +28 -0
  146. package/models/trace/handlers/UserTimingsHandler.js +91 -80
  147. package/models/trace/handlers/UserTimingsHandler.js.map +1 -7
  148. package/models/trace/handlers/WarningsHandler.d.ts +14 -0
  149. package/models/trace/handlers/WarningsHandler.js +100 -62
  150. package/models/trace/handlers/WarningsHandler.js.map +1 -7
  151. package/models/trace/handlers/WorkersHandler.d.ts +11 -0
  152. package/models/trace/handlers/WorkersHandler.js +40 -38
  153. package/models/trace/handlers/WorkersHandler.js.map +1 -7
  154. package/models/trace/handlers/handlers.d.ts +3 -0
  155. package/models/trace/handlers/handlers.js +7 -4
  156. package/models/trace/handlers/handlers.js.map +1 -7
  157. package/models/trace/handlers/types.d.ts +45 -0
  158. package/models/trace/handlers/types.js +15 -15
  159. package/models/trace/handlers/types.js.map +1 -7
  160. package/models/trace/helpers/SamplesIntegrator.d.ts +49 -0
  161. package/models/trace/helpers/SamplesIntegrator.js +381 -204
  162. package/models/trace/helpers/SamplesIntegrator.js.map +1 -7
  163. package/models/trace/helpers/Timing.d.ts +26 -0
  164. package/models/trace/helpers/Timing.js +131 -110
  165. package/models/trace/helpers/Timing.js.map +1 -7
  166. package/models/trace/helpers/Trace.d.ts +37 -0
  167. package/models/trace/helpers/Trace.js +200 -166
  168. package/models/trace/helpers/Trace.js.map +1 -7
  169. package/models/trace/helpers/TreeHelpers.d.ts +90 -0
  170. package/models/trace/helpers/TreeHelpers.js +203 -100
  171. package/models/trace/helpers/TreeHelpers.js.map +1 -7
  172. package/models/trace/helpers/helpers.d.ts +4 -0
  173. package/models/trace/helpers/helpers.js +8 -5
  174. package/models/trace/helpers/helpers.js.map +1 -7
  175. package/models/trace/root-causes/LayoutShift.d.ts +119 -0
  176. package/models/trace/root-causes/LayoutShift.js +470 -323
  177. package/models/trace/root-causes/LayoutShift.js.map +1 -7
  178. package/models/trace/root-causes/RootCauses.d.ts +14 -0
  179. package/models/trace/root-causes/RootCauses.js +9 -6
  180. package/models/trace/root-causes/RootCauses.js.map +1 -7
  181. package/models/trace/root-causes/root-causes.d.ts +1 -0
  182. package/models/trace/root-causes/root-causes.js +5 -2
  183. package/models/trace/root-causes/root-causes.js.map +1 -7
  184. package/models/trace/trace.d.ts +11 -0
  185. package/models/trace/trace.js +17 -23
  186. package/models/trace/trace.js.map +1 -7
  187. package/models/trace/types/Configuration.d.ts +33 -0
  188. package/models/trace/types/Configuration.js +25 -14
  189. package/models/trace/types/Configuration.js.map +1 -7
  190. package/models/trace/types/File.d.ts +23 -0
  191. package/models/trace/types/File.js +5 -6
  192. package/models/trace/types/File.js.map +1 -7
  193. package/models/trace/types/Timing.d.ts +25 -0
  194. package/models/trace/types/Timing.js +10 -11
  195. package/models/trace/types/Timing.js.map +1 -7
  196. package/models/trace/types/TraceEvents.d.ts +1571 -0
  197. package/models/trace/types/TraceEvents.js +174 -381
  198. package/models/trace/types/TraceEvents.js.map +1 -7
  199. package/models/trace/types/types.d.ts +4 -0
  200. package/models/trace/types/types.js +8 -5
  201. package/models/trace/types/types.js.map +1 -7
  202. package/package.json +1 -1
  203. package/TracingManager.js +0 -0
  204. package/core/platform/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -40
  205. package/core/platform/platform.js.compressed +0 -0
  206. package/core/platform/platform.js.hash +0 -1
  207. package/core/platform/platform.prebundle.d.ts +0 -15
  208. package/core/platform/platform.prebundle.js +0 -50
  209. package/core/platform/platform.prebundle.js.map +0 -1
  210. package/core/platform/platform.prebundle.ts +0 -64
  211. package/extras/extras.js +0 -0
  212. package/models/trace/SDKServices.js +0 -104
  213. package/models/trace/SDKServices.js.map +0 -7
  214. package/models/trace/TraceProcessor.js +0 -133
  215. package/models/trace/TraceProcessor.js.map +0 -7
  216. package/models/trace/TreeManipulator.js +0 -85
  217. package/models/trace/TreeManipulator.js.map +0 -7
  218. package/models/trace/devtools_entrypoint-legacy-typescript-tsconfig.json +0 -43
  219. package/models/trace/frames/TimelineFrameModel.js +0 -392
  220. package/models/trace/frames/TimelineFrameModel.js.map +0 -7
  221. package/models/trace/frames/bundle-tsconfig.json +0 -1
  222. package/models/trace/frames/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -43
  223. package/models/trace/frames/frames-tsconfig.json +0 -58
  224. package/models/trace/frames/frames.js +0 -5
  225. package/models/trace/frames/frames.js.map +0 -7
  226. package/models/trace/handlers/Migration.js +0 -27
  227. package/models/trace/handlers/Migration.js.map +0 -7
  228. package/models/trace/handlers/UberFramesHandler.js +0 -293
  229. package/models/trace/handlers/UberFramesHandler.js.map +0 -7
  230. package/models/trace/legacy-tsconfig.json +0 -1
  231. package/models/trace/sdk_services/DOMNodeLookup.js +0 -41
  232. package/models/trace/sdk_services/DOMNodeLookup.js.map +0 -7
  233. package/models/trace/sdk_services/LayoutShifts.js +0 -68
  234. package/models/trace/sdk_services/LayoutShifts.js.map +0 -7
  235. package/models/trace/sdk_services/bundle-tsconfig.json +0 -1
  236. package/models/trace/sdk_services/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -41
  237. package/models/trace/sdk_services/sdk_services-tsconfig.json +0 -57
  238. package/models/trace/sdk_services/sdk_services.js +0 -7
  239. package/models/trace/sdk_services/sdk_services.js.map +0 -7
  240. package/models/trace/trace-legacy.js +0 -16
  241. package/models/trace/trace-legacy.js.map +0 -7
  242. package/models/trace/worker/Processor.js +0 -143
  243. package/models/trace/worker/Processor.js.map +0 -7
  244. package/models/trace/worker/Types.js +0 -1
  245. package/models/trace/worker/Types.js.map +0 -7
  246. package/models/trace/worker/bundle-tsconfig.json +0 -1
  247. package/models/trace/worker/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -41
  248. package/models/trace/worker/devtools_entrypoint-worker_entrypoint-typescript-tsconfig.json +0 -41
  249. package/models/trace/worker/processor-tsconfig.json +0 -45
  250. package/models/trace/worker/worker.js +0 -7
  251. package/models/trace/worker/worker.js.map +0 -7
  252. package/models/trace/worker/worker_entrypoint-tsconfig.json +0 -1
  253. package/models/trace/worker/worker_entrypoint.js +0 -36
  254. package/models/trace/worker/worker_entrypoint.js.map +0 -7
  255. package/trace.mjs +0 -6980
  256. package/trace.mjs.map +0 -8
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../../front_end/models/trace/handlers/LayoutShiftsHandler.ts"],
4
- "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 Platform from '../../../core/platform/platform.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {data as metaHandlerData} from './MetaHandler.js';\nimport {ScoreClassification} from './PageLoadMetricsHandler.js';\nimport {HandlerState, type TraceEventHandlerName} from './types.js';\n\n// We start with a score of zero and step through all Layout Shift records from\n// all renderers. Each record not only tells us which renderer it is, but also\n// the unweighted and weighted scores. The unweighted score is the score we would\n// get if the renderer were the only one in the viewport. The weighted score, on\n// the other hand, accounts for how much of the viewport that particular render\n// takes up when the shift happened. An ad frame in the corner of the viewport\n// that shifts is considered less disruptive, therefore, than if it were taking\n// up the whole viewport.\n//\n// Next, we step through all the records from all renderers and add the weighted\n// score to a running total across all of the renderers. We create a new \"cluster\"\n// and reset the running total when:\n//\n// 1. We observe a outermost frame navigation, or\n// 2. When there's a gap between records of > 1s, or\n// 3. When there's more than 5 seconds of continuous layout shifting.\n//\n// Note that for it to be Cumulative Layout Shift in the sense described in the\n// documentation we would need to guarantee that we are tracking from navigation\n// to unload. However, we don't make any such guarantees here (since a developer\n// can record and stop when they please), so we support the cluster approach,\n// and we can give them a score, but it is effectively a \"session\" score, a\n// score for the given recording, and almost certainly not the\n// navigation-to-unload CLS score.\n\ninterface LayoutShifts {\n clusters: LayoutShiftCluster[];\n sessionMaxScore: number;\n // The session window which contains the SessionMaxScore\n clsWindowID: number;\n // We use these to calculate root causes for a given LayoutShift\n prePaintEvents: Types.TraceEvents.TraceEventPrePaint[];\n layoutInvalidationEvents: Types.TraceEvents.TraceEventLayoutInvalidationTracking[];\n scheduleStyleInvalidationEvents: Types.TraceEvents.TraceEventScheduleStyleInvalidationTracking[];\n styleRecalcInvalidationEvents: Types.TraceEvents.TraceEventStyleRecalcInvalidationTracking[];\n scoreRecords: ScoreRecord[];\n backendNodeIds: Protocol.DOM.BackendNodeId[];\n}\n\n// This represents the maximum #time we will allow a cluster to go before we\n// reset it.\nexport const MAX_CLUSTER_DURATION = Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(5000));\n\n// This represents the maximum #time we will allow between layout shift events\n// before considering it to be the start of a new cluster.\nexport const MAX_SHIFT_TIME_DELTA = Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(1000));\n\n// Layout shifts are reported globally to the developer, irrespective of which\n// frame they originated in. However, each process does have its own individual\n// CLS score, so we need to segment by process. This means Layout Shifts from\n// sites with one process (no subframes, or subframes from the same origin)\n// will be reported together. In the case of multiple renderers (frames across\n// different origins), we offer the developer the ability to switch renderer in\n// the UI.\nconst layoutShiftEvents: Types.TraceEvents.TraceEventLayoutShift[] = [];\n\n// These events denote potential node resizings. We store them to link captured\n// layout shifts to the resizing of unsized elements.\nconst layoutInvalidationEvents: Types.TraceEvents.TraceEventLayoutInvalidationTracking[] = [];\nconst scheduleStyleInvalidationEvents: Types.TraceEvents.TraceEventScheduleStyleInvalidationTracking[] = [];\nconst styleRecalcInvalidationEvents: Types.TraceEvents.TraceEventStyleRecalcInvalidationTracking[] = [];\n\nconst backendNodeIds = new Set<Protocol.DOM.BackendNodeId>();\n\n// Layout shifts happen during PrePaint as part of the rendering lifecycle.\n// We determine if a LayoutInvalidation event is a potential root cause of a layout\n// shift if the next PrePaint after the LayoutInvalidation is the parent\n// node of such shift.\nconst prePaintEvents: Types.TraceEvents.TraceEventPrePaint[] = [];\n\nlet sessionMaxScore = 0;\n\nlet clsWindowID = -1;\n\nconst clusters: LayoutShiftCluster[] = [];\n\n// Represents a point in time in which a LS score change\n// was recorded.\ntype ScoreRecord = {\n ts: number,\n score: number,\n};\n\n// The complete timeline of LS score changes in a trace.\n// Includes drops to 0 when session windows end.\nconst scoreRecords: ScoreRecord[] = [];\n\nlet handlerState = HandlerState.UNINITIALIZED;\n\nexport function initialize(): void {\n if (handlerState !== HandlerState.UNINITIALIZED) {\n throw new Error('LayoutShifts Handler was not reset');\n }\n handlerState = HandlerState.INITIALIZED;\n}\n\nexport function reset(): void {\n handlerState = HandlerState.UNINITIALIZED;\n layoutShiftEvents.length = 0;\n layoutInvalidationEvents.length = 0;\n scheduleStyleInvalidationEvents.length = 0;\n styleRecalcInvalidationEvents.length = 0;\n prePaintEvents.length = 0;\n backendNodeIds.clear();\n clusters.length = 0;\n sessionMaxScore = 0;\n scoreRecords.length = 0;\n clsWindowID = -1;\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Handler is not initialized');\n }\n\n if (Types.TraceEvents.isTraceEventLayoutShift(event) && !event.args.data?.had_recent_input) {\n layoutShiftEvents.push(event);\n return;\n }\n if (Types.TraceEvents.isTraceEventLayoutInvalidationTracking(event)) {\n layoutInvalidationEvents.push(event);\n return;\n }\n if (Types.TraceEvents.isTraceEventScheduleStyleInvalidationTracking(event)) {\n scheduleStyleInvalidationEvents.push(event);\n }\n if (Types.TraceEvents.isTraceEventStyleRecalcInvalidationTracking(event)) {\n styleRecalcInvalidationEvents.push(event);\n }\n if (Types.TraceEvents.isTraceEventPrePaint(event)) {\n prePaintEvents.push(event);\n return;\n }\n}\n\nfunction traceWindowFromTime(time: Types.Timing.MicroSeconds): Types.Timing.TraceWindowMicroSeconds {\n return {\n min: time,\n max: time,\n range: Types.Timing.MicroSeconds(0),\n };\n}\n\nfunction updateTraceWindowMax(\n traceWindow: Types.Timing.TraceWindowMicroSeconds, newMax: Types.Timing.MicroSeconds): void {\n traceWindow.max = newMax;\n traceWindow.range = Types.Timing.MicroSeconds(traceWindow.max - traceWindow.min);\n}\n\nfunction buildScoreRecords(): void {\n const {traceBounds} = metaHandlerData();\n scoreRecords.push({ts: traceBounds.min, score: 0});\n\n for (const cluster of clusters) {\n let clusterScore = 0;\n if (cluster.events[0].args.data) {\n scoreRecords.push({ts: cluster.clusterWindow.min, score: cluster.events[0].args.data.weighted_score_delta});\n }\n for (let i = 0; i < cluster.events.length; i++) {\n const event = cluster.events[i];\n if (!event.args.data) {\n continue;\n }\n clusterScore += event.args.data.weighted_score_delta;\n scoreRecords.push({ts: event.ts, score: clusterScore});\n }\n scoreRecords.push({ts: cluster.clusterWindow.max, score: 0});\n }\n}\n\n/**\n * Collects backend node ids coming from LayoutShift and LayoutInvalidation\n * events.\n */\nfunction collectNodes(): void {\n backendNodeIds.clear();\n\n // Collect the node ids present in the shifts.\n for (const layoutShift of layoutShiftEvents) {\n if (!layoutShift.args.data?.impacted_nodes) {\n continue;\n }\n for (const node of layoutShift.args.data.impacted_nodes) {\n backendNodeIds.add(node.node_id);\n }\n }\n\n // Collect the node ids present in LayoutInvalidation & scheduleStyleInvalidation events.\n for (const layoutInvalidation of layoutInvalidationEvents) {\n if (!layoutInvalidation.args.data?.nodeId) {\n continue;\n }\n backendNodeIds.add(layoutInvalidation.args.data.nodeId);\n }\n for (const scheduleStyleInvalidation of scheduleStyleInvalidationEvents) {\n if (!scheduleStyleInvalidation.args.data?.nodeId) {\n continue;\n }\n backendNodeIds.add(scheduleStyleInvalidation.args.data.nodeId);\n }\n}\n\nexport async function finalize(): Promise<void> {\n // Ensure the events are sorted by #time ascending.\n layoutShiftEvents.sort((a, b) => a.ts - b.ts);\n prePaintEvents.sort((a, b) => a.ts - b.ts);\n layoutInvalidationEvents.sort((a, b) => a.ts - b.ts);\n\n // Each function transforms the data used by the next, as such the invoke order\n // is important.\n await buildLayoutShiftsClusters();\n buildScoreRecords();\n collectNodes();\n handlerState = HandlerState.FINALIZED;\n}\n\nasync function buildLayoutShiftsClusters(): Promise<void> {\n const {navigationsByFrameId, mainFrameId, traceBounds} = metaHandlerData();\n const navigations = navigationsByFrameId.get(mainFrameId) || [];\n if (layoutShiftEvents.length === 0) {\n return;\n }\n let firstShiftTime = layoutShiftEvents[0].ts;\n let lastShiftTime = layoutShiftEvents[0].ts;\n let lastShiftNavigation = null;\n // Now step through each and create clusters.\n // A cluster is equivalent to a session window (see https://web.dev/cls/#what-is-cls).\n // To make the line chart clear, we explicitly demark the limits of each session window\n // by starting the cumulative score of the window at the time of the first layout shift\n // and ending it (dropping the line back to 0) when the window ends according to the\n // thresholds (MAX_CLUSTER_DURATION, MAX_SHIFT_TIME_DELTA).\n for (const event of layoutShiftEvents) {\n // First detect if either the cluster duration or the #time between this and\n // the last shift has been exceeded.\n const clusterDurationExceeded = event.ts - firstShiftTime > MAX_CLUSTER_DURATION;\n const maxTimeDeltaSinceLastShiftExceeded = event.ts - lastShiftTime > MAX_SHIFT_TIME_DELTA;\n\n // Next take a look at navigations. If between this and the last shift we have navigated,\n // note it.\n const currentShiftNavigation = Platform.ArrayUtilities.nearestIndexFromEnd(navigations, nav => nav.ts < event.ts);\n const hasNavigated = lastShiftNavigation !== currentShiftNavigation && currentShiftNavigation !== null;\n\n // If any of the above criteria are met or if we don't have any cluster yet we should\n // start a new one.\n if (clusterDurationExceeded || maxTimeDeltaSinceLastShiftExceeded || hasNavigated || !clusters.length) {\n // The cluster starts #time should be the timestamp of the first layout shift in it.\n const clusterStartTime = event.ts;\n\n // If the last session window ended because the max delta time between shifts\n // was exceeded set the endtime to MAX_SHIFT_TIME_DELTA microseconds after the\n // last shift in the session.\n const endTimeByMaxSessionDuration = clusterDurationExceeded ? firstShiftTime + MAX_CLUSTER_DURATION : Infinity;\n\n // If the last session window ended because the max session duration was\n // surpassed, set the endtime so that the window length = MAX_CLUSTER_DURATION;\n const endTimeByMaxShiftGap = maxTimeDeltaSinceLastShiftExceeded ? lastShiftTime + MAX_SHIFT_TIME_DELTA : Infinity;\n\n // If there was a navigation during the last window, close it at the time\n // of the navigation.\n const endTimeByNavigation = hasNavigated ? navigations[currentShiftNavigation].ts : Infinity;\n\n // End the previous cluster at the time of the first of the criteria above that was met.\n const previousClusterEndTime = Math.min(endTimeByMaxSessionDuration, endTimeByMaxShiftGap, endTimeByNavigation);\n\n // If there is an existing cluster update its closing time.\n if (clusters.length > 0) {\n const currentCluster = clusters[clusters.length - 1];\n updateTraceWindowMax(currentCluster.clusterWindow, Types.Timing.MicroSeconds(previousClusterEndTime));\n }\n\n clusters.push({\n events: [],\n clusterWindow: traceWindowFromTime(clusterStartTime),\n clusterCumulativeScore: 0,\n scoreWindows: {\n good: traceWindowFromTime(clusterStartTime),\n needsImprovement: null,\n bad: null,\n },\n });\n\n firstShiftTime = clusterStartTime;\n }\n\n // Given the above we should have a cluster available, so pick the most\n // recent one and append the shift, bump its score and window values accordingly.\n const currentCluster = clusters[clusters.length - 1];\n const timeFromNavigation = currentShiftNavigation !== null ?\n Types.Timing.MicroSeconds(event.ts - navigations[currentShiftNavigation].ts) :\n undefined;\n\n currentCluster.clusterCumulativeScore += event.args.data ? event.args.data.weighted_score_delta : 0;\n if (!event.args.data) {\n continue;\n }\n const shift: Types.TraceEvents.SyntheticLayoutShift = {\n ...event,\n args: {\n frame: event.args.frame,\n data: {\n ...event.args.data,\n rawEvent: event,\n },\n },\n parsedData: {\n timeFromNavigation,\n cumulativeWeightedScoreInWindow: currentCluster.clusterCumulativeScore,\n // The score of the session window is temporarily set to 0 just\n // to initialize it. Since we need to get the score of all shifts\n // in the session window to determine its value, its definite\n // value is set when stepping through the built clusters.\n sessionWindowData: {cumulativeWindowScore: 0, id: clusters.length},\n },\n };\n currentCluster.events.push(shift);\n updateTraceWindowMax(currentCluster.clusterWindow, event.ts);\n\n lastShiftTime = event.ts;\n lastShiftNavigation = currentShiftNavigation;\n }\n\n // Now step through each cluster and set up the times at which the value\n // goes from Good, to needs improvement, to Bad. Note that if there is a\n // large jump we may go from Good to Bad without ever creating a Needs\n // Improvement window at all.\n for (const cluster of clusters) {\n let weightedScore = 0;\n let windowID = -1;\n // If this is the last cluster update its window. The cluster duration is determined\n // by the minimum between: time to next navigation, trace end time, time to maximum\n // cluster duration and time to maximum gap between layout shifts.\n if (cluster === clusters[clusters.length - 1]) {\n const clusterEndByMaxDuration = MAX_CLUSTER_DURATION + cluster.clusterWindow.min;\n const clusterEndByMaxGap = cluster.clusterWindow.max + MAX_SHIFT_TIME_DELTA;\n const nextNavigationIndex =\n Platform.ArrayUtilities.nearestIndexFromBeginning(navigations, nav => nav.ts > cluster.clusterWindow.max);\n const nextNavigationTime = nextNavigationIndex ? navigations[nextNavigationIndex].ts : Infinity;\n const clusterEnd = Math.min(clusterEndByMaxDuration, clusterEndByMaxGap, traceBounds.max, nextNavigationTime);\n updateTraceWindowMax(cluster.clusterWindow, Types.Timing.MicroSeconds(clusterEnd));\n }\n for (const shift of cluster.events) {\n weightedScore += shift.args.data ? shift.args.data.weighted_score_delta : 0;\n windowID = shift.parsedData.sessionWindowData.id;\n const ts = shift.ts;\n // Update the the CLS score of this shift's session window now that\n // we have it.\n shift.parsedData.sessionWindowData.cumulativeWindowScore = cluster.clusterCumulativeScore;\n if (weightedScore < LayoutShiftsThreshold.NEEDS_IMPROVEMENT) {\n // Expand the Good window.\n updateTraceWindowMax(cluster.scoreWindows.good, ts);\n } else if (\n weightedScore >= LayoutShiftsThreshold.NEEDS_IMPROVEMENT && weightedScore < LayoutShiftsThreshold.BAD) {\n if (!cluster.scoreWindows.needsImprovement) {\n // Close the Good window, and open the needs improvement window.\n updateTraceWindowMax(cluster.scoreWindows.good, Types.Timing.MicroSeconds(ts - 1));\n cluster.scoreWindows.needsImprovement = traceWindowFromTime(ts);\n }\n\n // Expand the needs improvement window.\n updateTraceWindowMax(cluster.scoreWindows.needsImprovement, ts);\n } else if (weightedScore >= LayoutShiftsThreshold.BAD) {\n if (!cluster.scoreWindows.bad) {\n // We may jump from Good to Bad here, so update whichever window is open.\n if (cluster.scoreWindows.needsImprovement) {\n updateTraceWindowMax(cluster.scoreWindows.needsImprovement, Types.Timing.MicroSeconds(ts - 1));\n } else {\n updateTraceWindowMax(cluster.scoreWindows.good, Types.Timing.MicroSeconds(ts - 1));\n }\n\n cluster.scoreWindows.bad = traceWindowFromTime(shift.ts);\n }\n\n // Expand the Bad window.\n updateTraceWindowMax(cluster.scoreWindows.bad, ts);\n }\n\n // At this point the windows are set by the timestamps of the events, but the\n // next cluster begins at the timestamp of its first event. As such we now\n // need to expand the score window to the end of the cluster, and we do so\n // by using the Bad widow if it's there, or the NI window, or finally the\n // Good window.\n if (cluster.scoreWindows.bad) {\n updateTraceWindowMax(cluster.scoreWindows.bad, cluster.clusterWindow.max);\n } else if (cluster.scoreWindows.needsImprovement) {\n updateTraceWindowMax(cluster.scoreWindows.needsImprovement, cluster.clusterWindow.max);\n } else {\n updateTraceWindowMax(cluster.scoreWindows.good, cluster.clusterWindow.max);\n }\n }\n if (weightedScore > sessionMaxScore) {\n clsWindowID = windowID;\n sessionMaxScore = weightedScore;\n }\n }\n}\n\nexport function data(): LayoutShifts {\n if (handlerState !== HandlerState.FINALIZED) {\n throw new Error('Layout Shifts Handler is not finalized');\n }\n\n return {\n clusters: [...clusters],\n sessionMaxScore: sessionMaxScore,\n clsWindowID,\n prePaintEvents: [...prePaintEvents],\n layoutInvalidationEvents: [...layoutInvalidationEvents],\n scheduleStyleInvalidationEvents: [...scheduleStyleInvalidationEvents],\n styleRecalcInvalidationEvents: [],\n scoreRecords: [...scoreRecords],\n backendNodeIds: [...backendNodeIds],\n };\n}\n\nexport function deps(): TraceEventHandlerName[] {\n return ['Screenshots', 'Meta'];\n}\n\nexport function stateForLayoutShiftScore(score: number): ScoreClassification {\n let state = ScoreClassification.GOOD;\n if (score >= LayoutShiftsThreshold.NEEDS_IMPROVEMENT) {\n state = ScoreClassification.OK;\n }\n\n if (score >= LayoutShiftsThreshold.BAD) {\n state = ScoreClassification.BAD;\n }\n\n return state;\n}\n\nexport interface LayoutShiftCluster {\n clusterWindow: Types.Timing.TraceWindowMicroSeconds;\n clusterCumulativeScore: number;\n events: Types.TraceEvents.SyntheticLayoutShift[];\n // For convenience we split apart the cluster into good, NI, and bad windows.\n // Since a cluster may remain in the good window, we mark NI and bad as being\n // possibly null.\n scoreWindows: {\n good: Types.Timing.TraceWindowMicroSeconds,\n needsImprovement: Types.Timing.TraceWindowMicroSeconds|null,\n bad: Types.Timing.TraceWindowMicroSeconds|null,\n };\n}\n\n// Based on https://web.dev/cls/\nexport const enum LayoutShiftsThreshold {\n GOOD = 0,\n NEEDS_IMPROVEMENT = 0.1,\n BAD = 0.25,\n}\n"],
5
- "mappings": "AAIA;AAEA;AACA;AAEA;AACA;AACA;AA2CO,aAAM,uBAAuB,QAAQ,OAAO,2BAA2B,MAAM,OAAO,aAAa;AAIjG,aAAM,uBAAuB,QAAQ,OAAO,2BAA2B,MAAM,OAAO,aAAa;AASxG,MAAM,oBAA+D;AAIrE,MAAM,2BAAqF;AAC3F,MAAM,kCAAmG;AACzG,MAAM,gCAA+F;AAErG,MAAM,iBAAiB,oBAAI;AAM3B,MAAM,iBAAyD;AAE/D,IAAI,kBAAkB;AAEtB,IAAI,cAAc;AAElB,MAAM,WAAiC;AAWvC,MAAM,eAA8B;AAEpC,IAAI,eAAe,aAAa;AAEzB,6BAA4B;AACjC,MAAI,iBAAiB,aAAa,eAAe;AAC/C,UAAM,IAAI,MAAM;AAAA;AAElB,iBAAe,aAAa;AAAA;AAGvB,wBAAuB;AAC5B,iBAAe,aAAa;AAC5B,oBAAkB,SAAS;AAC3B,2BAAyB,SAAS;AAClC,kCAAgC,SAAS;AACzC,gCAA8B,SAAS;AACvC,iBAAe,SAAS;AACxB,iBAAe;AACf,WAAS,SAAS;AAClB,oBAAkB;AAClB,eAAa,SAAS;AACtB,gBAAc;AAAA;AAG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AAQ,aAAa,KAAK;AAC5B,6BAAqB,QAAQ,aAAa,KAAK,QAAQ,cAAc;AAAA,iBAC5D,QAAQ,aAAa,kBAAkB;AAChD,6BAAqB,QAAQ,aAAa,kBAAkB,QAAQ,cAAc;AAAA,aAC7E;AACL,6BAAqB,QAAQ,aAAa,MAAM,QAAQ,cAAc;AAAA;AAAA;AAG1E,QAAI,gBAAgB,iBAAiB;AACnC,oBAAc;AACd,wBAAkB;AAAA;AAAA;AAAA;AAKjB,uBAA8B;AACnC,MAAI,iBAAiB,aAAa,WAAW;AAC3C,UAAM,IAAI,MAAM;AAAA;AAGlB,SAAO;AAAA,IACL,UAAU,CAAC,GAAG;AAAA,IACd;AAAA,IACA;AAAA,IACA,gBAAgB,CAAC,GAAG;AAAA,IACpB,0BAA0B,CAAC,GAAG;AAAA,IAC9B,iCAAiC,CAAC,GAAG;AAAA,IACrC,+BAA+B;AAAA,IAC/B,cAAc,CAAC,GAAG;AAAA,IAClB,gBAAgB,CAAC,GAAG;AAAA;AAAA;AAIjB,uBAAyC;AAC9C,SAAO,CAAC,eAAe;AAAA;AAGlB,yCAAkC,OAAoC;AAC3E,MAAI,QAAQ,oBAAoB;AAChC,MAAI,SAAS,sBAAsB,mBAAmB;AACpD,YAAQ,oBAAoB;AAAA;AAG9B,MAAI,SAAS,sBAAsB,KAAK;AACtC,YAAQ,oBAAoB;AAAA;AAG9B,SAAO;AAAA;AAkBF,WAAW,wBAAX,kBAAW,2BAAX;AACL,0DAAO,KAAP;AACA,uEAAoB,OAApB;AACA,yDAAM,QAAN;AAHgB;AAAA;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"LayoutShiftsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/LayoutShiftsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,OAAO,MAAM,uBAAu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IAAI,YAAY,mCAA2B,EAAE;QAC3C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC3D;IAED,OAAO;QACL,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC;QACvB,eAAe,EAAE,eAAe;QAChC,WAAW;QACX,cAAc,EAAE,CAAC,GAAG,cAAc,CAAC;QACnC,wBAAwB,EAAE,CAAC,GAAG,wBAAwB,CAAC;QACvD,+BAA+B,EAAE,CAAC,GAAG,+BAA+B,CAAC;QACrE,6BAA6B,EAAE,EAAE;QACjC,YAAY,EAAE,CAAC,GAAG,YAAY,CAAC;QAC/B,cAAc,EAAE,CAAC,GAAG,cAAc,CAAC;KACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,IAAI,KAAK,wCAA2B,CAAC;IACrC,IAAI,KAAK,qDAA2C,EAAE;QACpD,KAAK,oCAAyB,CAAC;KAChC;IAED,IAAI,KAAK,wCAA6B,EAAE;QACtC,KAAK,sCAA0B,CAAC;KACjC;IAED,OAAO,KAAK,CAAC;AACf,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 Platform from '../../../core/platform/platform.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {data as metaHandlerData} from './MetaHandler.js';\nimport {ScoreClassification} from './PageLoadMetricsHandler.js';\nimport {HandlerState, type TraceEventHandlerName} from './types.js';\n\n// We start with a score of zero and step through all Layout Shift records from\n// all renderers. Each record not only tells us which renderer it is, but also\n// the unweighted and weighted scores. The unweighted score is the score we would\n// get if the renderer were the only one in the viewport. The weighted score, on\n// the other hand, accounts for how much of the viewport that particular render\n// takes up when the shift happened. An ad frame in the corner of the viewport\n// that shifts is considered less disruptive, therefore, than if it were taking\n// up the whole viewport.\n//\n// Next, we step through all the records from all renderers and add the weighted\n// score to a running total across all of the renderers. We create a new \"cluster\"\n// and reset the running total when:\n//\n// 1. We observe a outermost frame navigation, or\n// 2. When there's a gap between records of > 1s, or\n// 3. When there's more than 5 seconds of continuous layout shifting.\n//\n// Note that for it to be Cumulative Layout Shift in the sense described in the\n// documentation we would need to guarantee that we are tracking from navigation\n// to unload. However, we don't make any such guarantees here (since a developer\n// can record and stop when they please), so we support the cluster approach,\n// and we can give them a score, but it is effectively a \"session\" score, a\n// score for the given recording, and almost certainly not the\n// navigation-to-unload CLS score.\n\ninterface LayoutShifts {\n clusters: LayoutShiftCluster[];\n sessionMaxScore: number;\n // The session window which contains the SessionMaxScore\n clsWindowID: number;\n // We use these to calculate root causes for a given LayoutShift\n prePaintEvents: Types.TraceEvents.TraceEventPrePaint[];\n layoutInvalidationEvents: Types.TraceEvents.TraceEventLayoutInvalidationTracking[];\n scheduleStyleInvalidationEvents: Types.TraceEvents.TraceEventScheduleStyleInvalidationTracking[];\n styleRecalcInvalidationEvents: Types.TraceEvents.TraceEventStyleRecalcInvalidationTracking[];\n scoreRecords: ScoreRecord[];\n backendNodeIds: Protocol.DOM.BackendNodeId[];\n}\n\n// This represents the maximum #time we will allow a cluster to go before we\n// reset it.\nexport const MAX_CLUSTER_DURATION = Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(5000));\n\n// This represents the maximum #time we will allow between layout shift events\n// before considering it to be the start of a new cluster.\nexport const MAX_SHIFT_TIME_DELTA = Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(1000));\n\n// Layout shifts are reported globally to the developer, irrespective of which\n// frame they originated in. However, each process does have its own individual\n// CLS score, so we need to segment by process. This means Layout Shifts from\n// sites with one process (no subframes, or subframes from the same origin)\n// will be reported together. In the case of multiple renderers (frames across\n// different origins), we offer the developer the ability to switch renderer in\n// the UI.\nconst layoutShiftEvents: Types.TraceEvents.TraceEventLayoutShift[] = [];\n\n// These events denote potential node resizings. We store them to link captured\n// layout shifts to the resizing of unsized elements.\nconst layoutInvalidationEvents: Types.TraceEvents.TraceEventLayoutInvalidationTracking[] = [];\nconst scheduleStyleInvalidationEvents: Types.TraceEvents.TraceEventScheduleStyleInvalidationTracking[] = [];\nconst styleRecalcInvalidationEvents: Types.TraceEvents.TraceEventStyleRecalcInvalidationTracking[] = [];\n\nconst backendNodeIds = new Set<Protocol.DOM.BackendNodeId>();\n\n// Layout shifts happen during PrePaint as part of the rendering lifecycle.\n// We determine if a LayoutInvalidation event is a potential root cause of a layout\n// shift if the next PrePaint after the LayoutInvalidation is the parent\n// node of such shift.\nconst prePaintEvents: Types.TraceEvents.TraceEventPrePaint[] = [];\n\nlet sessionMaxScore = 0;\n\nlet clsWindowID = -1;\n\nconst clusters: LayoutShiftCluster[] = [];\n\n// Represents a point in time in which a LS score change\n// was recorded.\ntype ScoreRecord = {\n ts: number,\n score: number,\n};\n\n// The complete timeline of LS score changes in a trace.\n// Includes drops to 0 when session windows end.\nconst scoreRecords: ScoreRecord[] = [];\n\nlet handlerState = HandlerState.UNINITIALIZED;\n\nexport function initialize(): void {\n if (handlerState !== HandlerState.UNINITIALIZED) {\n throw new Error('LayoutShifts Handler was not reset');\n }\n handlerState = HandlerState.INITIALIZED;\n}\n\nexport function reset(): void {\n handlerState = HandlerState.UNINITIALIZED;\n layoutShiftEvents.length = 0;\n layoutInvalidationEvents.length = 0;\n scheduleStyleInvalidationEvents.length = 0;\n styleRecalcInvalidationEvents.length = 0;\n prePaintEvents.length = 0;\n backendNodeIds.clear();\n clusters.length = 0;\n sessionMaxScore = 0;\n scoreRecords.length = 0;\n clsWindowID = -1;\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Handler is not initialized');\n }\n\n if (Types.TraceEvents.isTraceEventLayoutShift(event) && !event.args.data?.had_recent_input) {\n layoutShiftEvents.push(event);\n return;\n }\n if (Types.TraceEvents.isTraceEventLayoutInvalidationTracking(event)) {\n layoutInvalidationEvents.push(event);\n return;\n }\n if (Types.TraceEvents.isTraceEventScheduleStyleInvalidationTracking(event)) {\n scheduleStyleInvalidationEvents.push(event);\n }\n if (Types.TraceEvents.isTraceEventStyleRecalcInvalidationTracking(event)) {\n styleRecalcInvalidationEvents.push(event);\n }\n if (Types.TraceEvents.isTraceEventPrePaint(event)) {\n prePaintEvents.push(event);\n return;\n }\n}\n\nfunction traceWindowFromTime(time: Types.Timing.MicroSeconds): Types.Timing.TraceWindowMicroSeconds {\n return {\n min: time,\n max: time,\n range: Types.Timing.MicroSeconds(0),\n };\n}\n\nfunction updateTraceWindowMax(\n traceWindow: Types.Timing.TraceWindowMicroSeconds, newMax: Types.Timing.MicroSeconds): void {\n traceWindow.max = newMax;\n traceWindow.range = Types.Timing.MicroSeconds(traceWindow.max - traceWindow.min);\n}\n\nfunction buildScoreRecords(): void {\n const {traceBounds} = metaHandlerData();\n scoreRecords.push({ts: traceBounds.min, score: 0});\n\n for (const cluster of clusters) {\n let clusterScore = 0;\n if (cluster.events[0].args.data) {\n scoreRecords.push({ts: cluster.clusterWindow.min, score: cluster.events[0].args.data.weighted_score_delta});\n }\n for (let i = 0; i < cluster.events.length; i++) {\n const event = cluster.events[i];\n if (!event.args.data) {\n continue;\n }\n clusterScore += event.args.data.weighted_score_delta;\n scoreRecords.push({ts: event.ts, score: clusterScore});\n }\n scoreRecords.push({ts: cluster.clusterWindow.max, score: 0});\n }\n}\n\n/**\n * Collects backend node ids coming from LayoutShift and LayoutInvalidation\n * events.\n */\nfunction collectNodes(): void {\n backendNodeIds.clear();\n\n // Collect the node ids present in the shifts.\n for (const layoutShift of layoutShiftEvents) {\n if (!layoutShift.args.data?.impacted_nodes) {\n continue;\n }\n for (const node of layoutShift.args.data.impacted_nodes) {\n backendNodeIds.add(node.node_id);\n }\n }\n\n // Collect the node ids present in LayoutInvalidation & scheduleStyleInvalidation events.\n for (const layoutInvalidation of layoutInvalidationEvents) {\n if (!layoutInvalidation.args.data?.nodeId) {\n continue;\n }\n backendNodeIds.add(layoutInvalidation.args.data.nodeId);\n }\n for (const scheduleStyleInvalidation of scheduleStyleInvalidationEvents) {\n if (!scheduleStyleInvalidation.args.data?.nodeId) {\n continue;\n }\n backendNodeIds.add(scheduleStyleInvalidation.args.data.nodeId);\n }\n}\n\nexport async function finalize(): Promise<void> {\n // Ensure the events are sorted by #time ascending.\n layoutShiftEvents.sort((a, b) => a.ts - b.ts);\n prePaintEvents.sort((a, b) => a.ts - b.ts);\n layoutInvalidationEvents.sort((a, b) => a.ts - b.ts);\n\n // Each function transforms the data used by the next, as such the invoke order\n // is important.\n await buildLayoutShiftsClusters();\n buildScoreRecords();\n collectNodes();\n handlerState = HandlerState.FINALIZED;\n}\n\nasync function buildLayoutShiftsClusters(): Promise<void> {\n const {navigationsByFrameId, mainFrameId, traceBounds} = metaHandlerData();\n const navigations = navigationsByFrameId.get(mainFrameId) || [];\n if (layoutShiftEvents.length === 0) {\n return;\n }\n let firstShiftTime = layoutShiftEvents[0].ts;\n let lastShiftTime = layoutShiftEvents[0].ts;\n let lastShiftNavigation = null;\n // Now step through each and create clusters.\n // A cluster is equivalent to a session window (see https://web.dev/cls/#what-is-cls).\n // To make the line chart clear, we explicitly demark the limits of each session window\n // by starting the cumulative score of the window at the time of the first layout shift\n // and ending it (dropping the line back to 0) when the window ends according to the\n // thresholds (MAX_CLUSTER_DURATION, MAX_SHIFT_TIME_DELTA).\n for (const event of layoutShiftEvents) {\n // First detect if either the cluster duration or the #time between this and\n // the last shift has been exceeded.\n const clusterDurationExceeded = event.ts - firstShiftTime > MAX_CLUSTER_DURATION;\n const maxTimeDeltaSinceLastShiftExceeded = event.ts - lastShiftTime > MAX_SHIFT_TIME_DELTA;\n\n // Next take a look at navigations. If between this and the last shift we have navigated,\n // note it.\n const currentShiftNavigation = Platform.ArrayUtilities.nearestIndexFromEnd(navigations, nav => nav.ts < event.ts);\n const hasNavigated = lastShiftNavigation !== currentShiftNavigation && currentShiftNavigation !== null;\n\n // If any of the above criteria are met or if we don't have any cluster yet we should\n // start a new one.\n if (clusterDurationExceeded || maxTimeDeltaSinceLastShiftExceeded || hasNavigated || !clusters.length) {\n // The cluster starts #time should be the timestamp of the first layout shift in it.\n const clusterStartTime = event.ts;\n\n // If the last session window ended because the max delta time between shifts\n // was exceeded set the endtime to MAX_SHIFT_TIME_DELTA microseconds after the\n // last shift in the session.\n const endTimeByMaxSessionDuration = clusterDurationExceeded ? firstShiftTime + MAX_CLUSTER_DURATION : Infinity;\n\n // If the last session window ended because the max session duration was\n // surpassed, set the endtime so that the window length = MAX_CLUSTER_DURATION;\n const endTimeByMaxShiftGap = maxTimeDeltaSinceLastShiftExceeded ? lastShiftTime + MAX_SHIFT_TIME_DELTA : Infinity;\n\n // If there was a navigation during the last window, close it at the time\n // of the navigation.\n const endTimeByNavigation = hasNavigated ? navigations[currentShiftNavigation].ts : Infinity;\n\n // End the previous cluster at the time of the first of the criteria above that was met.\n const previousClusterEndTime = Math.min(endTimeByMaxSessionDuration, endTimeByMaxShiftGap, endTimeByNavigation);\n\n // If there is an existing cluster update its closing time.\n if (clusters.length > 0) {\n const currentCluster = clusters[clusters.length - 1];\n updateTraceWindowMax(currentCluster.clusterWindow, Types.Timing.MicroSeconds(previousClusterEndTime));\n }\n\n clusters.push({\n events: [],\n clusterWindow: traceWindowFromTime(clusterStartTime),\n clusterCumulativeScore: 0,\n scoreWindows: {\n good: traceWindowFromTime(clusterStartTime),\n needsImprovement: null,\n bad: null,\n },\n });\n\n firstShiftTime = clusterStartTime;\n }\n\n // Given the above we should have a cluster available, so pick the most\n // recent one and append the shift, bump its score and window values accordingly.\n const currentCluster = clusters[clusters.length - 1];\n const timeFromNavigation = currentShiftNavigation !== null ?\n Types.Timing.MicroSeconds(event.ts - navigations[currentShiftNavigation].ts) :\n undefined;\n\n currentCluster.clusterCumulativeScore += event.args.data ? event.args.data.weighted_score_delta : 0;\n if (!event.args.data) {\n continue;\n }\n const shift: Types.TraceEvents.SyntheticLayoutShift = {\n ...event,\n args: {\n frame: event.args.frame,\n data: {\n ...event.args.data,\n rawEvent: event,\n },\n },\n parsedData: {\n timeFromNavigation,\n cumulativeWeightedScoreInWindow: currentCluster.clusterCumulativeScore,\n // The score of the session window is temporarily set to 0 just\n // to initialize it. Since we need to get the score of all shifts\n // in the session window to determine its value, its definite\n // value is set when stepping through the built clusters.\n sessionWindowData: {cumulativeWindowScore: 0, id: clusters.length},\n },\n };\n currentCluster.events.push(shift);\n updateTraceWindowMax(currentCluster.clusterWindow, event.ts);\n\n lastShiftTime = event.ts;\n lastShiftNavigation = currentShiftNavigation;\n }\n\n // Now step through each cluster and set up the times at which the value\n // goes from Good, to needs improvement, to Bad. Note that if there is a\n // large jump we may go from Good to Bad without ever creating a Needs\n // Improvement window at all.\n for (const cluster of clusters) {\n let weightedScore = 0;\n let windowID = -1;\n // If this is the last cluster update its window. The cluster duration is determined\n // by the minimum between: time to next navigation, trace end time, time to maximum\n // cluster duration and time to maximum gap between layout shifts.\n if (cluster === clusters[clusters.length - 1]) {\n const clusterEndByMaxDuration = MAX_CLUSTER_DURATION + cluster.clusterWindow.min;\n const clusterEndByMaxGap = cluster.clusterWindow.max + MAX_SHIFT_TIME_DELTA;\n const nextNavigationIndex =\n Platform.ArrayUtilities.nearestIndexFromBeginning(navigations, nav => nav.ts > cluster.clusterWindow.max);\n const nextNavigationTime = nextNavigationIndex ? navigations[nextNavigationIndex].ts : Infinity;\n const clusterEnd = Math.min(clusterEndByMaxDuration, clusterEndByMaxGap, traceBounds.max, nextNavigationTime);\n updateTraceWindowMax(cluster.clusterWindow, Types.Timing.MicroSeconds(clusterEnd));\n }\n for (const shift of cluster.events) {\n weightedScore += shift.args.data ? shift.args.data.weighted_score_delta : 0;\n windowID = shift.parsedData.sessionWindowData.id;\n const ts = shift.ts;\n // Update the the CLS score of this shift's session window now that\n // we have it.\n shift.parsedData.sessionWindowData.cumulativeWindowScore = cluster.clusterCumulativeScore;\n if (weightedScore < LayoutShiftsThreshold.NEEDS_IMPROVEMENT) {\n // Expand the Good window.\n updateTraceWindowMax(cluster.scoreWindows.good, ts);\n } else if (\n weightedScore >= LayoutShiftsThreshold.NEEDS_IMPROVEMENT && weightedScore < LayoutShiftsThreshold.BAD) {\n if (!cluster.scoreWindows.needsImprovement) {\n // Close the Good window, and open the needs improvement window.\n updateTraceWindowMax(cluster.scoreWindows.good, Types.Timing.MicroSeconds(ts - 1));\n cluster.scoreWindows.needsImprovement = traceWindowFromTime(ts);\n }\n\n // Expand the needs improvement window.\n updateTraceWindowMax(cluster.scoreWindows.needsImprovement, ts);\n } else if (weightedScore >= LayoutShiftsThreshold.BAD) {\n if (!cluster.scoreWindows.bad) {\n // We may jump from Good to Bad here, so update whichever window is open.\n if (cluster.scoreWindows.needsImprovement) {\n updateTraceWindowMax(cluster.scoreWindows.needsImprovement, Types.Timing.MicroSeconds(ts - 1));\n } else {\n updateTraceWindowMax(cluster.scoreWindows.good, Types.Timing.MicroSeconds(ts - 1));\n }\n\n cluster.scoreWindows.bad = traceWindowFromTime(shift.ts);\n }\n\n // Expand the Bad window.\n updateTraceWindowMax(cluster.scoreWindows.bad, ts);\n }\n\n // At this point the windows are set by the timestamps of the events, but the\n // next cluster begins at the timestamp of its first event. As such we now\n // need to expand the score window to the end of the cluster, and we do so\n // by using the Bad widow if it's there, or the NI window, or finally the\n // Good window.\n if (cluster.scoreWindows.bad) {\n updateTraceWindowMax(cluster.scoreWindows.bad, cluster.clusterWindow.max);\n } else if (cluster.scoreWindows.needsImprovement) {\n updateTraceWindowMax(cluster.scoreWindows.needsImprovement, cluster.clusterWindow.max);\n } else {\n updateTraceWindowMax(cluster.scoreWindows.good, cluster.clusterWindow.max);\n }\n }\n if (weightedScore > sessionMaxScore) {\n clsWindowID = windowID;\n sessionMaxScore = weightedScore;\n }\n }\n}\n\nexport function data(): LayoutShifts {\n if (handlerState !== HandlerState.FINALIZED) {\n throw new Error('Layout Shifts Handler is not finalized');\n }\n\n return {\n clusters: [...clusters],\n sessionMaxScore: sessionMaxScore,\n clsWindowID,\n prePaintEvents: [...prePaintEvents],\n layoutInvalidationEvents: [...layoutInvalidationEvents],\n scheduleStyleInvalidationEvents: [...scheduleStyleInvalidationEvents],\n styleRecalcInvalidationEvents: [],\n scoreRecords: [...scoreRecords],\n backendNodeIds: [...backendNodeIds],\n };\n}\n\nexport function deps(): TraceEventHandlerName[] {\n return ['Screenshots', 'Meta'];\n}\n\nexport function stateForLayoutShiftScore(score: number): ScoreClassification {\n let state = ScoreClassification.GOOD;\n if (score >= LayoutShiftsThreshold.NEEDS_IMPROVEMENT) {\n state = ScoreClassification.OK;\n }\n\n if (score >= LayoutShiftsThreshold.BAD) {\n state = ScoreClassification.BAD;\n }\n\n return state;\n}\n\nexport interface LayoutShiftCluster {\n clusterWindow: Types.Timing.TraceWindowMicroSeconds;\n clusterCumulativeScore: number;\n events: Types.TraceEvents.SyntheticLayoutShift[];\n // For convenience we split apart the cluster into good, NI, and bad windows.\n // Since a cluster may remain in the good window, we mark NI and bad as being\n // possibly null.\n scoreWindows: {\n good: Types.Timing.TraceWindowMicroSeconds,\n needsImprovement: Types.Timing.TraceWindowMicroSeconds|null,\n bad: Types.Timing.TraceWindowMicroSeconds|null,\n };\n}\n\n// Based on https://web.dev/cls/\nexport const enum LayoutShiftsThreshold {\n GOOD = 0,\n NEEDS_IMPROVEMENT = 0.1,\n BAD = 0.25,\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import * as Types from '../types/types.js';
2
+ export interface MemoryData {
3
+ updateCountersByProcess: Map<Types.TraceEvents.ProcessID, Types.TraceEvents.TraceEventUpdateCounters[]>;
4
+ }
5
+ export declare function reset(): void;
6
+ export declare function handleEvent(event: Types.TraceEvents.TraceEventData): void;
7
+ export declare function data(): MemoryData;
@@ -1,17 +1,20 @@
1
- import * as Platform from "../../../core/platform/platform.js";
2
- import * as Types from "../types/types.js";
3
- const updateCountersByProcess = /* @__PURE__ */ new Map();
1
+ // Copyright 2023 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+ import * as Platform from '../../../core/platform/platform.js';
5
+ import * as Types from '../types/types.js';
6
+ const updateCountersByProcess = new Map();
4
7
  export function reset() {
5
- updateCountersByProcess.clear();
8
+ updateCountersByProcess.clear();
6
9
  }
7
10
  export function handleEvent(event) {
8
- if (Types.TraceEvents.isTraceEventUpdateCounters(event)) {
9
- const countersForProcess = Platform.MapUtilities.getWithDefault(updateCountersByProcess, event.pid, () => []);
10
- countersForProcess.push(event);
11
- updateCountersByProcess.set(event.pid, countersForProcess);
12
- }
11
+ if (Types.TraceEvents.isTraceEventUpdateCounters(event)) {
12
+ const countersForProcess = Platform.MapUtilities.getWithDefault(updateCountersByProcess, event.pid, () => []);
13
+ countersForProcess.push(event);
14
+ updateCountersByProcess.set(event.pid, countersForProcess);
15
+ }
13
16
  }
14
17
  export function data() {
15
- return { updateCountersByProcess: new Map(updateCountersByProcess) };
18
+ return { updateCountersByProcess: new Map(updateCountersByProcess) };
16
19
  }
17
- //# sourceMappingURL=MemoryHandler.js.map
20
+ //# sourceMappingURL=MemoryHandler.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../../front_end/models/trace/handlers/MemoryHandler.ts"],
4
- "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 Types from '../types/types.js';\n\nexport interface MemoryData {\n updateCountersByProcess: Map<Types.TraceEvents.ProcessID, Types.TraceEvents.TraceEventUpdateCounters[]>;\n}\n\nconst updateCountersByProcess: MemoryData['updateCountersByProcess'] = new Map();\n\nexport function reset(): void {\n updateCountersByProcess.clear();\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (Types.TraceEvents.isTraceEventUpdateCounters(event)) {\n const countersForProcess = Platform.MapUtilities.getWithDefault(updateCountersByProcess, event.pid, () => []);\n countersForProcess.push(event);\n updateCountersByProcess.set(event.pid, countersForProcess);\n }\n}\n\nexport function data(): MemoryData {\n return {updateCountersByProcess: new Map(updateCountersByProcess)};\n}\n"],
5
- "mappings": "AAIA;AACA;AAMA,MAAM,0BAAiE,oBAAI;AAEpE,wBAAuB;AAC5B,0BAAwB;AAAA;AAGnB,4BAAqB,OAA+C;AACzE,MAAI,MAAM,YAAY,2BAA2B,QAAQ;AACvD,UAAM,qBAAqB,SAAS,aAAa,eAAe,yBAAyB,MAAM,KAAK,MAAM;AAC1G,uBAAmB,KAAK;AACxB,4BAAwB,IAAI,MAAM,KAAK;AAAA;AAAA;AAIpC,uBAA4B;AACjC,SAAO,EAAC,yBAAyB,IAAI,IAAI;AAAA;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"MemoryHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/MemoryHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAM3C,MAAM,uBAAuB,GAA0C,IAAI,GAAG,EAAE,CAAC;AAEjF,MAAM,UAAU,KAAK;IACnB,uBAAuB,CAAC,KAAK,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAuC;IACjE,IAAI,KAAK,CAAC,WAAW,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE;QACvD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,uBAAuB,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9G,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;KAC5D;AACH,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,EAAC,uBAAuB,EAAE,IAAI,GAAG,CAAC,uBAAuB,CAAC,EAAC,CAAC;AACrE,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 Types from '../types/types.js';\n\nexport interface MemoryData {\n updateCountersByProcess: Map<Types.TraceEvents.ProcessID, Types.TraceEvents.TraceEventUpdateCounters[]>;\n}\n\nconst updateCountersByProcess: MemoryData['updateCountersByProcess'] = new Map();\n\nexport function reset(): void {\n updateCountersByProcess.clear();\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (Types.TraceEvents.isTraceEventUpdateCounters(event)) {\n const countersForProcess = Platform.MapUtilities.getWithDefault(updateCountersByProcess, event.pid, () => []);\n countersForProcess.push(event);\n updateCountersByProcess.set(event.pid, countersForProcess);\n }\n}\n\nexport function data(): MemoryData {\n return {updateCountersByProcess: new Map(updateCountersByProcess)};\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import * as Types from '../types/types.js';
2
+ export declare function reset(): void;
3
+ export declare function initialize(): void;
4
+ export declare function handleEvent(event: Types.TraceEvents.TraceEventData): void;
5
+ export declare function finalize(): Promise<void>;
6
+ export type MetaHandlerData = {
7
+ traceIsGeneric: boolean;
8
+ traceBounds: Types.Timing.TraceWindowMicroSeconds;
9
+ browserProcessId: Types.TraceEvents.ProcessID;
10
+ processNames: Map<Types.TraceEvents.ProcessID, Types.TraceEvents.TraceEventProcessName>;
11
+ browserThreadId: Types.TraceEvents.ThreadID;
12
+ gpuProcessId: Types.TraceEvents.ProcessID;
13
+ gpuThreadId?: Types.TraceEvents.ThreadID;
14
+ viewportRect?: DOMRect;
15
+ navigationsByFrameId: Map<string, Types.TraceEvents.TraceEventNavigationStart[]>;
16
+ navigationsByNavigationId: Map<string, Types.TraceEvents.TraceEventNavigationStart>;
17
+ threadsInProcess: Map<Types.TraceEvents.ProcessID, Map<Types.TraceEvents.ThreadID, Types.TraceEvents.TraceEventThreadName>>;
18
+ mainFrameId: string;
19
+ mainFrameURL: string;
20
+ /**
21
+ * A frame can have multiple renderer processes, at the same time,
22
+ * a renderer process can have multiple URLs. This map tracks the
23
+ * processes active on a given frame, with the time window in which
24
+ * they were active. Because a renderer process might have multiple
25
+ * URLs, each process in each frame has an array of windows, with an
26
+ * entry for each URL it had.
27
+ */
28
+ rendererProcessesByFrame: FrameProcessData;
29
+ topLevelRendererIds: Set<Types.TraceEvents.ProcessID>;
30
+ frameByProcessId: Map<Types.TraceEvents.ProcessID, Map<string, Types.TraceEvents.TraceFrame>>;
31
+ mainFrameNavigations: Types.TraceEvents.TraceEventNavigationStart[];
32
+ };
33
+ export type FrameProcessData = Map<string, Map<Types.TraceEvents.ProcessID, {
34
+ frame: Types.TraceEvents.TraceFrame;
35
+ window: Types.Timing.TraceWindowMicroSeconds;
36
+ }[]>>;
37
+ export declare function data(): MetaHandlerData;