@paulirish/trace_engine 0.0.67 → 0.0.68

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 (132) hide show
  1. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  2. package/core/common/ParsedURL.d.ts +0 -2
  3. package/core/common/ParsedURL.js +3 -3
  4. package/core/common/ParsedURL.js.map +1 -1
  5. package/core/platform/StringUtilities.d.ts +15 -4
  6. package/core/platform/StringUtilities.js +48 -12
  7. package/core/platform/StringUtilities.js.map +1 -1
  8. package/generated/protocol.d.ts +34 -6
  9. package/generated/protocol.js +8 -0
  10. package/locales/af.json +9 -6
  11. package/locales/am.json +16 -13
  12. package/locales/ar.json +53 -50
  13. package/locales/as.json +66 -63
  14. package/locales/az.json +19 -16
  15. package/locales/be.json +43 -40
  16. package/locales/bg.json +14 -11
  17. package/locales/bn.json +73 -70
  18. package/locales/bs.json +20 -17
  19. package/locales/ca.json +74 -71
  20. package/locales/cs.json +10 -7
  21. package/locales/cy.json +18 -15
  22. package/locales/da.json +9 -6
  23. package/locales/de.json +7 -4
  24. package/locales/el.json +11 -8
  25. package/locales/en-GB.json +70 -67
  26. package/locales/en-US.json +3 -6
  27. package/locales/en-XL.json +3 -6
  28. package/locales/es-419.json +61 -58
  29. package/locales/es.json +41 -38
  30. package/locales/et.json +45 -42
  31. package/locales/eu.json +15 -12
  32. package/locales/fa.json +36 -33
  33. package/locales/fi.json +8 -5
  34. package/locales/fil.json +31 -28
  35. package/locales/fr-CA.json +25 -22
  36. package/locales/fr.json +15 -12
  37. package/locales/gl.json +30 -27
  38. package/locales/gu.json +36 -33
  39. package/locales/he.json +69 -66
  40. package/locales/hi.json +31 -28
  41. package/locales/hr.json +23 -20
  42. package/locales/hu.json +53 -50
  43. package/locales/hy.json +16 -13
  44. package/locales/id.json +65 -62
  45. package/locales/is.json +8 -5
  46. package/locales/it.json +41 -38
  47. package/locales/ja.json +12 -9
  48. package/locales/ka.json +65 -62
  49. package/locales/kk.json +41 -38
  50. package/locales/km.json +15 -12
  51. package/locales/kn.json +25 -22
  52. package/locales/ko.json +8 -5
  53. package/locales/ky.json +19 -16
  54. package/locales/lo.json +30 -27
  55. package/locales/lt.json +6 -3
  56. package/locales/lv.json +31 -28
  57. package/locales/mk.json +74 -71
  58. package/locales/ml.json +16 -13
  59. package/locales/mn.json +37 -34
  60. package/locales/mr.json +9 -6
  61. package/locales/ms.json +12 -9
  62. package/locales/my.json +59 -56
  63. package/locales/ne.json +63 -60
  64. package/locales/nl.json +30 -27
  65. package/locales/no.json +14 -11
  66. package/locales/or.json +51 -48
  67. package/locales/pa.json +21 -18
  68. package/locales/pl.json +29 -26
  69. package/locales/pt-PT.json +9 -6
  70. package/locales/pt.json +14 -11
  71. package/locales/ro.json +8 -5
  72. package/locales/ru.json +37 -34
  73. package/locales/si.json +33 -30
  74. package/locales/sk.json +62 -59
  75. package/locales/sl.json +10 -7
  76. package/locales/sq.json +18 -15
  77. package/locales/sr-Latn.json +14 -11
  78. package/locales/sr.json +14 -11
  79. package/locales/sv.json +10 -7
  80. package/locales/sw.json +66 -63
  81. package/locales/ta.json +36 -33
  82. package/locales/te.json +35 -32
  83. package/locales/th.json +35 -32
  84. package/locales/tr.json +14 -11
  85. package/locales/uk.json +20 -17
  86. package/locales/ur.json +10 -7
  87. package/locales/uz.json +12 -9
  88. package/locales/vi.json +40 -37
  89. package/locales/zh-HK.json +35 -32
  90. package/locales/zh-TW.json +32 -29
  91. package/locales/zh.json +70 -67
  92. package/locales/zu.json +50 -47
  93. package/models/cpu_profile/CPUProfileDataModel.d.ts +0 -33
  94. package/models/cpu_profile/CPUProfileDataModel.js +14 -14
  95. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
  96. package/models/cpu_profile/ProfileTreeModel.d.ts +1 -2
  97. package/models/cpu_profile/ProfileTreeModel.js +4 -4
  98. package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
  99. package/models/trace/EventsSerializer.js +1 -6
  100. package/models/trace/EventsSerializer.js.map +1 -1
  101. package/models/trace/LanternComputationData.js +36 -10
  102. package/models/trace/LanternComputationData.js.map +1 -1
  103. package/models/trace/ModelImpl.js +0 -2
  104. package/models/trace/ModelImpl.js.map +1 -1
  105. package/models/trace/Processor.js +1 -1
  106. package/models/trace/Processor.js.map +1 -1
  107. package/models/trace/extras/TraceTree.js +35 -9
  108. package/models/trace/extras/TraceTree.js.map +1 -1
  109. package/models/trace/handlers/FlowsHandler.js +25 -19
  110. package/models/trace/handlers/FlowsHandler.js.map +1 -1
  111. package/models/trace/handlers/InitiatorsHandler.js +22 -34
  112. package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
  113. package/models/trace/handlers/LayoutShiftsHandler.js +2 -6
  114. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  115. package/models/trace/handlers/NetworkRequestsHandler.js +12 -6
  116. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  117. package/models/trace/handlers/SamplesHandler.js +7 -4
  118. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  119. package/models/trace/helpers/SyntheticEvents.d.ts +0 -8
  120. package/models/trace/helpers/SyntheticEvents.js +10 -33
  121. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  122. package/models/trace/insights/RenderBlocking.js +3 -1
  123. package/models/trace/insights/RenderBlocking.js.map +1 -1
  124. package/models/trace/lantern/metrics/LargestContentfulPaint.d.ts +5 -1
  125. package/models/trace/lantern/metrics/LargestContentfulPaint.js +113 -1
  126. package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -1
  127. package/models/trace/lantern/simulation/Simulator.js +4 -0
  128. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  129. package/models/trace/lantern/types/Lantern.d.ts +4 -0
  130. package/models/trace/lantern/types/Lantern.js.map +1 -1
  131. package/package.json +1 -1
  132. package/third_party/legacy-javascript/lib/legacy-javascript.js +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ModelImpl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AAC;CACF;AAcD,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,sDAAmC,CAAA;AACrC,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAiBD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAEtB,IAAI;IADvB,MAAM,CAAU,SAAS,GAAG,aAAa,CAAC;IAC1C,YAAmB,IAA0B;QAC3C,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;oBADjB,IAAI;IAEvB,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,KAAK,eAAe,CAAC,QAAQ,CAAC;AACrD,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../core/platform/platform.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport type * as Insights from './insights/insights.js';\nimport {TraceParseProgressEvent, TraceProcessor} from './Processor.js';\nimport * as Types from './types/types.js';\n\n/**\n * The Model is responsible for parsing arrays of raw trace events and storing the\n * resulting data. It can store multiple traces at once, and can return the data for\n * any of them.\n *\n * Most uses of this class should be through `createWithAllHandlers`, but\n * `createWithSubsetOfHandlers` can be used to run just some handlers.\n **/\nexport class Model extends EventTarget {\n readonly #traces: ParsedTrace[] = [];\n readonly #nextNumberByDomain = new Map<string, number>();\n\n readonly #recordingsAvailable: string[] = [];\n #lastRecordingIndex = 0;\n #processor: TraceProcessor;\n #config: Types.Configuration.Configuration = Types.Configuration.defaults();\n\n static createWithAllHandlers(config?: Types.Configuration.Configuration): Model {\n return new Model(Handlers.ModelHandlers, config);\n }\n\n /**\n * Runs only the provided handlers.\n *\n * Callers must ensure they are providing all dependant handlers (although Meta is included automatically),\n * and must know that the result of `.parsedTrace` will be limited to the handlers provided, even though\n * the type won't reflect that.\n */\n static createWithSubsetOfHandlers(\n traceHandlers: Partial<Handlers.Types.Handlers>, config?: Types.Configuration.Configuration): Model {\n return new Model(traceHandlers as Handlers.Types.Handlers, config);\n }\n\n constructor(handlers: Handlers.Types.Handlers, config?: Types.Configuration.Configuration) {\n super();\n if (config) {\n this.#config = config;\n }\n this.#processor = new TraceProcessor(handlers, this.#config);\n }\n\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#config = config;\n this.#processor.updateConfiguration(config);\n }\n\n /**\n * Parses an array of trace events into a structured object containing all the\n * information parsed by the trace handlers.\n * You can `await` this function to pause execution until parsing is complete,\n * or instead rely on the `ModuleUpdateEvent` that is dispatched when the\n * parsing is finished.\n *\n * Once parsed, you then have to call the `parsedTrace` method, providing an\n * index of the trace you want to have the data for. This is because any model\n * can store a number of traces. Each trace is given an index, which starts at 0\n * and increments by one as a new trace is parsed.\n *\n * @example\n * // Awaiting the parse method() to block until parsing complete\n * await this.traceModel.parse(events);\n * const data = this.traceModel.parsedTrace(0)\n * @example\n * // Using an event listener to be notified when tracing is complete.\n * this.traceModel.addEventListener(Trace.ModelUpdateEvent.eventName, (event) => {\n * if(event.data.data === 'done') {\n * // trace complete\n * const data = this.traceModel.parsedTrace(0);\n * }\n * });\n * void this.traceModel.parse(events);\n **/\n async parse(traceEvents: readonly Types.Events.Event[], config: Types.Configuration.ParseOptions = {}):\n Promise<void> {\n if (config.showAllEvents === undefined) {\n config.showAllEvents = this.#config.showAllEvents;\n }\n\n const metadata = config.metadata || {};\n // During parsing, periodically update any listeners on each processors'\n // progress (if they have any updates).\n const onTraceUpdate = (event: Event): void => {\n const {data} = event as TraceParseProgressEvent;\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.PROGRESS_UPDATE, data}));\n };\n\n this.#processor.addEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n\n // TODO(cjamcl): this.#processor.parse needs this to work. So it should either take it as input, or create it itself.\n const syntheticEventsManager = Helpers.SyntheticEvents.SyntheticEventsManager.createAndActivate(traceEvents);\n\n try {\n // Wait for all outstanding promises before finishing the async execution,\n // but perform all tasks in parallel.\n await this.#processor.parse(traceEvents, config);\n if (!this.#processor.data) {\n throw new Error('processor did not parse trace');\n }\n const file = this.#storeAndCreateParsedTraceFile(\n syntheticEventsManager, traceEvents, metadata, this.#processor.data, this.#processor.insights);\n // Reclaim memory used by the temporary event-to-index lookup map now that trace parsing is complete.\n syntheticEventsManager.clearRegistrationIndex();\n // We only push the file onto this.#traces here once we know it's valid\n // and there's been no errors in the parsing.\n this.#traces.push(file);\n } catch (e) {\n throw e;\n } finally {\n // All processors have finished parsing, no more updates are expected.\n this.#processor.removeEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n // Finally, update any listeners that all processors are 'done'.\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.COMPLETE, data: 'done'}));\n }\n }\n\n #storeAndCreateParsedTraceFile(\n syntheticEventsManager: Helpers.SyntheticEvents.SyntheticEventsManager,\n traceEvents: readonly Types.Events.Event[], metadata: Types.File.MetaData, data: Handlers.Types.HandlerData,\n traceInsights: Insights.Types.TraceInsightSets|null): ParsedTrace {\n this.#lastRecordingIndex++;\n let recordingName = `Trace ${this.#lastRecordingIndex}`;\n const origin = Helpers.Trace.extractOriginFromTrace(data.Meta.mainFrameURL);\n if (origin) {\n const nextSequenceForDomain = Platform.MapUtilities.getWithDefault(this.#nextNumberByDomain, origin, () => 1);\n recordingName = `${origin} (${nextSequenceForDomain})`;\n this.#nextNumberByDomain.set(origin, nextSequenceForDomain + 1);\n }\n this.#recordingsAvailable.push(recordingName);\n\n return {\n traceEvents,\n metadata,\n data,\n insights: traceInsights,\n syntheticEventsManager,\n };\n }\n\n lastTraceIndex(): number {\n return this.size() - 1;\n }\n\n /**\n * Returns the parsed trace data indexed by the order in which it was stored.\n * If no index is given, the last stored parsed data is returned.\n */\n parsedTrace(index: number = this.#traces.length - 1): ParsedTrace|null {\n return this.#traces.at(index) ?? null;\n }\n\n overrideModifications(index: number, newModifications: Types.File.Modifications): void {\n if (this.#traces[index]) {\n this.#traces[index].metadata.modifications = newModifications;\n }\n }\n\n syntheticTraceEventsManager(index: number = this.#traces.length - 1): Helpers.SyntheticEvents.SyntheticEventsManager\n |null {\n return this.#traces.at(index)?.syntheticEventsManager ?? null;\n }\n\n size(): number {\n return this.#traces.length;\n }\n\n deleteTraceByIndex(recordingIndex: number): void {\n this.#traces.splice(recordingIndex, 1);\n this.#recordingsAvailable.splice(recordingIndex, 1);\n }\n\n indexForTrace(trace: ParsedTrace): number {\n return this.#traces.indexOf(trace);\n }\n\n getRecordingsAvailable(): string[] {\n return this.#recordingsAvailable;\n }\n\n resetProcessor(): void {\n this.#processor.reset();\n }\n}\n\n/**\n * This parsed trace is used by the Model. It keeps multiple instances\n * of these so that the user can swap between them. The key is that it is\n * essentially the TraceFile plus whatever the model has parsed from it.\n */\nexport type ParsedTrace = Types.File.TraceFile&{\n data: Handlers.Types.HandlerData,\n /** Is null for CPU profiles. */\n insights: Insights.Types.TraceInsightSets | null,\n syntheticEventsManager: Helpers.SyntheticEvents.SyntheticEventsManager,\n};\n\nexport enum ModelUpdateType {\n COMPLETE = 'COMPLETE',\n PROGRESS_UPDATE = 'PROGRESS_UPDATE',\n}\n\nexport type ModelUpdateEventData = ModelUpdateEventComplete|ModelUpdateEventProgress;\n\nexport interface ModelUpdateEventComplete {\n type: ModelUpdateType.COMPLETE;\n data: 'done';\n}\nexport interface ModelUpdateEventProgress {\n type: ModelUpdateType.PROGRESS_UPDATE;\n data: TraceParseEventProgressData;\n}\n\nexport interface TraceParseEventProgressData {\n percent: number;\n}\n\nexport class ModelUpdateEvent extends Event {\n static readonly eventName = 'modelupdate';\n constructor(public data: ModelUpdateEventData) {\n super(ModelUpdateEvent.eventName);\n }\n}\n\nexport function isModelUpdateDataComplete(eventData: ModelUpdateEventData): eventData is ModelUpdateEventComplete {\n return eventData.type === ModelUpdateType.COMPLETE;\n}\n"]}
1
+ {"version":3,"file":"ModelImpl.js","sourceRoot":"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qB,CAAA;IACrB,sDAAmC,CAAA;AACrC,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAiBD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAEtB,IAAI;IADvB,MAAM,CAAU,SAAS,GAAG,aAAa,CAAC;IAC1C,YAAmB,IAA0B;QAC3C,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;oBADjB,IAAI;IAEvB,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,KAAK,eAAe,CAAC,QAAQ,CAAC;AACrD,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../core/platform/platform.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport type * as Insights from './insights/insights.js';\nimport {TraceParseProgressEvent, TraceProcessor} from './Processor.js';\nimport * as Types from './types/types.js';\n\n/**\n * The Model is responsible for parsing arrays of raw trace events and storing the\n * resulting data. It can store multiple traces at once, and can return the data for\n * any of them.\n *\n * Most uses of this class should be through `createWithAllHandlers`, but\n * `createWithSubsetOfHandlers` can be used to run just some handlers.\n **/\nexport class Model extends EventTarget {\n readonly #traces: ParsedTrace[] = [];\n readonly #nextNumberByDomain = new Map<string, number>();\n\n readonly #recordingsAvailable: string[] = [];\n #lastRecordingIndex = 0;\n #processor: TraceProcessor;\n #config: Types.Configuration.Configuration = Types.Configuration.defaults();\n\n static createWithAllHandlers(config?: Types.Configuration.Configuration): Model {\n return new Model(Handlers.ModelHandlers, config);\n }\n\n /**\n * Runs only the provided handlers.\n *\n * Callers must ensure they are providing all dependant handlers (although Meta is included automatically),\n * and must know that the result of `.parsedTrace` will be limited to the handlers provided, even though\n * the type won't reflect that.\n */\n static createWithSubsetOfHandlers(\n traceHandlers: Partial<Handlers.Types.Handlers>, config?: Types.Configuration.Configuration): Model {\n return new Model(traceHandlers as Handlers.Types.Handlers, config);\n }\n\n constructor(handlers: Handlers.Types.Handlers, config?: Types.Configuration.Configuration) {\n super();\n if (config) {\n this.#config = config;\n }\n this.#processor = new TraceProcessor(handlers, this.#config);\n }\n\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#config = config;\n this.#processor.updateConfiguration(config);\n }\n\n /**\n * Parses an array of trace events into a structured object containing all the\n * information parsed by the trace handlers.\n * You can `await` this function to pause execution until parsing is complete,\n * or instead rely on the `ModuleUpdateEvent` that is dispatched when the\n * parsing is finished.\n *\n * Once parsed, you then have to call the `parsedTrace` method, providing an\n * index of the trace you want to have the data for. This is because any model\n * can store a number of traces. Each trace is given an index, which starts at 0\n * and increments by one as a new trace is parsed.\n *\n * @example\n * // Awaiting the parse method() to block until parsing complete\n * await this.traceModel.parse(events);\n * const data = this.traceModel.parsedTrace(0)\n * @example\n * // Using an event listener to be notified when tracing is complete.\n * this.traceModel.addEventListener(Trace.ModelUpdateEvent.eventName, (event) => {\n * if(event.data.data === 'done') {\n * // trace complete\n * const data = this.traceModel.parsedTrace(0);\n * }\n * });\n * void this.traceModel.parse(events);\n **/\n async parse(traceEvents: readonly Types.Events.Event[], config: Types.Configuration.ParseOptions = {}):\n Promise<void> {\n if (config.showAllEvents === undefined) {\n config.showAllEvents = this.#config.showAllEvents;\n }\n\n const metadata = config.metadata || {};\n // During parsing, periodically update any listeners on each processors'\n // progress (if they have any updates).\n const onTraceUpdate = (event: Event): void => {\n const {data} = event as TraceParseProgressEvent;\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.PROGRESS_UPDATE, data}));\n };\n\n this.#processor.addEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n\n // TODO(cjamcl): this.#processor.parse needs this to work. So it should either take it as input, or create it itself.\n const syntheticEventsManager = Helpers.SyntheticEvents.SyntheticEventsManager.createAndActivate(traceEvents);\n\n try {\n // Wait for all outstanding promises before finishing the async execution,\n // but perform all tasks in parallel.\n await this.#processor.parse(traceEvents, config);\n if (!this.#processor.data) {\n throw new Error('processor did not parse trace');\n }\n const file = this.#storeAndCreateParsedTraceFile(\n syntheticEventsManager, traceEvents, metadata, this.#processor.data, this.#processor.insights);\n // We only push the file onto this.#traces here once we know it's valid\n // and there's been no errors in the parsing.\n this.#traces.push(file);\n } catch (e) {\n throw e;\n } finally {\n // All processors have finished parsing, no more updates are expected.\n this.#processor.removeEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n // Finally, update any listeners that all processors are 'done'.\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.COMPLETE, data: 'done'}));\n }\n }\n\n #storeAndCreateParsedTraceFile(\n syntheticEventsManager: Helpers.SyntheticEvents.SyntheticEventsManager,\n traceEvents: readonly Types.Events.Event[], metadata: Types.File.MetaData, data: Handlers.Types.HandlerData,\n traceInsights: Insights.Types.TraceInsightSets|null): ParsedTrace {\n this.#lastRecordingIndex++;\n let recordingName = `Trace ${this.#lastRecordingIndex}`;\n const origin = Helpers.Trace.extractOriginFromTrace(data.Meta.mainFrameURL);\n if (origin) {\n const nextSequenceForDomain = Platform.MapUtilities.getWithDefault(this.#nextNumberByDomain, origin, () => 1);\n recordingName = `${origin} (${nextSequenceForDomain})`;\n this.#nextNumberByDomain.set(origin, nextSequenceForDomain + 1);\n }\n this.#recordingsAvailable.push(recordingName);\n\n return {\n traceEvents,\n metadata,\n data,\n insights: traceInsights,\n syntheticEventsManager,\n };\n }\n\n lastTraceIndex(): number {\n return this.size() - 1;\n }\n\n /**\n * Returns the parsed trace data indexed by the order in which it was stored.\n * If no index is given, the last stored parsed data is returned.\n */\n parsedTrace(index: number = this.#traces.length - 1): ParsedTrace|null {\n return this.#traces.at(index) ?? null;\n }\n\n overrideModifications(index: number, newModifications: Types.File.Modifications): void {\n if (this.#traces[index]) {\n this.#traces[index].metadata.modifications = newModifications;\n }\n }\n\n syntheticTraceEventsManager(index: number = this.#traces.length - 1): Helpers.SyntheticEvents.SyntheticEventsManager\n |null {\n return this.#traces.at(index)?.syntheticEventsManager ?? null;\n }\n\n size(): number {\n return this.#traces.length;\n }\n\n deleteTraceByIndex(recordingIndex: number): void {\n this.#traces.splice(recordingIndex, 1);\n this.#recordingsAvailable.splice(recordingIndex, 1);\n }\n\n indexForTrace(trace: ParsedTrace): number {\n return this.#traces.indexOf(trace);\n }\n\n getRecordingsAvailable(): string[] {\n return this.#recordingsAvailable;\n }\n\n resetProcessor(): void {\n this.#processor.reset();\n }\n}\n\n/**\n * This parsed trace is used by the Model. It keeps multiple instances\n * of these so that the user can swap between them. The key is that it is\n * essentially the TraceFile plus whatever the model has parsed from it.\n */\nexport type ParsedTrace = Types.File.TraceFile&{\n data: Handlers.Types.HandlerData,\n /** Is null for CPU profiles. */\n insights: Insights.Types.TraceInsightSets | null,\n syntheticEventsManager: Helpers.SyntheticEvents.SyntheticEventsManager,\n};\n\nexport enum ModelUpdateType {\n COMPLETE = 'COMPLETE',\n PROGRESS_UPDATE = 'PROGRESS_UPDATE',\n}\n\nexport type ModelUpdateEventData = ModelUpdateEventComplete|ModelUpdateEventProgress;\n\nexport interface ModelUpdateEventComplete {\n type: ModelUpdateType.COMPLETE;\n data: 'done';\n}\nexport interface ModelUpdateEventProgress {\n type: ModelUpdateType.PROGRESS_UPDATE;\n data: TraceParseEventProgressData;\n}\n\nexport interface TraceParseEventProgressData {\n percent: number;\n}\n\nexport class ModelUpdateEvent extends Event {\n static readonly eventName = 'modelupdate';\n constructor(public data: ModelUpdateEventData) {\n super(ModelUpdateEvent.eventName);\n }\n}\n\nexport function isModelUpdateDataComplete(eventData: ModelUpdateEventData): eventData is ModelUpdateEventComplete {\n return eventData.type === ModelUpdateType.COMPLETE;\n}\n"]}
@@ -254,6 +254,7 @@ export class TraceProcessor extends EventTarget {
254
254
  if (!navStarts || navStartIndex === undefined || navStartIndex === -1) {
255
255
  throw new Lantern.Core.LanternError('Could not find navigation start');
256
256
  }
257
+ const processedNavigation = LanternComputationData.createProcessedNavigation(data, frameId, navigation);
257
258
  const startTime = navStarts[navStartIndex].ts;
258
259
  const endTime = navStartIndex + 1 < navStarts.length ? navStarts[navStartIndex + 1].ts : Number.POSITIVE_INFINITY;
259
260
  const boundedTraceEvents = traceEvents.filter(e => e.ts >= startTime && e.ts < endTime);
@@ -264,7 +265,6 @@ export class TraceProcessor extends EventTarget {
264
265
  };
265
266
  const requests = LanternComputationData.createNetworkRequests(trace, data, startTime, endTime);
266
267
  const graph = LanternComputationData.createGraph(requests, trace, data);
267
- const processedNavigation = LanternComputationData.createProcessedNavigation(data, frameId, navigation);
268
268
  const networkAnalysis = Lantern.Core.NetworkAnalyzer.analyze(requests);
269
269
  if (!networkAnalysis) {
270
270
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"Processor.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/Processor.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;;AAE7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAEtE,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,IAAW,MAKV;AALD,WAAW,MAAM;IACf,uBAAa,CAAA;IACb,6BAAmB,CAAA;IACnB,+CAAqC,CAAA;IACrC,yDAA+C,CAAA;AACjD,CAAC,EALU,MAAM,KAAN,MAAM,QAKhB;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAGrC,IAAI;IAFf,MAAM,CAAU,SAAS,GAAG,oBAAoB,CAAC;IACjD,YACW,IAAuC,EAC9C,IAAI,GAA2C,EAAC,OAAO,EAAE,IAAI,EAAC;QAEhE,KAAK,CAAC,uBAAuB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;oBA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AAW,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACrD,YAAY,CAAC,WAAyC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,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 Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Lantern from './lantern/lantern.js';\nimport * as LanternComputationData from './LanternComputationData.js';\nimport type * as Model from './ModelImpl.js';\nimport * as Types from './types/types.js';\n\nconst enum Status {\n IDLE = 'IDLE',\n PARSING = 'PARSING',\n FINISHED_PARSING = 'FINISHED_PARSING',\n ERRORED_WHILE_PARSING = 'ERRORED_WHILE_PARSING',\n}\n\nexport class TraceParseProgressEvent extends Event {\n static readonly eventName = 'traceparseprogress';\n constructor(\n public data: Model.TraceParseEventProgressData,\n init: ConstructorParameters<typeof Event>[1] = {bubbles: true},\n ) {\n super(TraceParseProgressEvent.eventName, init);\n }\n}\n\n/**\n * Parsing a trace can take time. On large traces we see a breakdown of time like so:\n * - handleEvent() loop: ~25%\n * - finalize() loop: ~75%\n * The numbers below are set so we can report a progress percentage of [0...1]\n */\nconst enum ProgressPhase {\n HANDLE_EVENT = 0.25,\n FINALIZE = 1.0,\n}\nfunction calculateProgress(value: number, phase: ProgressPhase): number {\n // Finalize values should be [0.25...1].\n if (phase === ProgressPhase.FINALIZE) {\n return (value * (ProgressPhase.FINALIZE - ProgressPhase.HANDLE_EVENT)) + ProgressPhase.HANDLE_EVENT;\n }\n return value * phase;\n}\n\nexport class TraceProcessor extends EventTarget {\n // We force the Meta handler to be enabled, so the TraceHandlers type here is\n // the model handlers the user passes in and the Meta handler.\n readonly #traceHandlers: Partial<Handlers.Types.Handlers>;\n #status = Status.IDLE;\n #modelConfiguration = Types.Configuration.defaults();\n #data: Handlers.Types.HandlerData|null = null;\n #insights: Insights.Types.TraceInsightSets|null = null;\n\n static createWithAllHandlers(): TraceProcessor {\n return new TraceProcessor(Handlers.ModelHandlers, Types.Configuration.defaults());\n }\n\n /**\n * This function is kept for testing with `stub`.\n */\n static getInsightRunners(): Insights.Types.InsightModelsType {\n return {...Insights.Models};\n }\n\n constructor(traceHandlers: Partial<Handlers.Types.Handlers>, modelConfiguration?: Types.Configuration.Configuration) {\n super();\n\n this.#verifyHandlers(traceHandlers);\n this.#traceHandlers = {\n Meta: Handlers.ModelHandlers.Meta,\n ...traceHandlers,\n };\n if (modelConfiguration) {\n this.#modelConfiguration = modelConfiguration;\n }\n this.#passConfigToHandlers();\n }\n\n #passConfigToHandlers(): void {\n for (const handler of Object.values(this.#traceHandlers)) {\n // Bit of an odd double check, but without this TypeScript refuses to let\n // you call the function as it thinks it might be undefined.\n if ('handleUserConfig' in handler && handler.handleUserConfig) {\n handler.handleUserConfig(this.#modelConfiguration);\n }\n }\n }\n\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#modelConfiguration = config;\n this.#passConfigToHandlers();\n }\n\n /**\n * When the user passes in a set of handlers, we want to ensure that we have all\n * the required handlers. Handlers can depend on other handlers, so if the user\n * passes in FooHandler which depends on BarHandler, they must also pass in\n * BarHandler too. This method verifies that all dependencies are met, and\n * throws if not.\n **/\n #verifyHandlers(providedHandlers: Partial<Handlers.Types.Handlers>): void {\n // Tiny optimisation: if the amount of provided handlers matches the amount\n // of handlers in the Handlers.ModelHandlers object, that means that the\n // user has passed in every handler we have. So therefore they cannot have\n // missed any, and there is no need to iterate through the handlers and\n // check the dependencies.\n if (Object.keys(providedHandlers).length === Object.keys(Handlers.ModelHandlers).length) {\n return;\n }\n const requiredHandlerKeys = new Set<Handlers.Types.HandlerName>();\n for (const [handlerName, handler] of Object.entries(providedHandlers)) {\n requiredHandlerKeys.add(handlerName as Handlers.Types.HandlerName);\n const deps = 'deps' in handler ? handler.deps() : [];\n for (const depName of deps) {\n requiredHandlerKeys.add(depName);\n }\n }\n\n const providedHandlerKeys = new Set(Object.keys(providedHandlers));\n // We always force the Meta handler to be enabled when creating the\n // Processor, so if it is missing from the set the user gave us that is OK,\n // as we will have enabled it anyway.\n requiredHandlerKeys.delete('Meta');\n\n for (const requiredKey of requiredHandlerKeys) {\n if (!providedHandlerKeys.has(requiredKey)) {\n throw new Error(`Required handler ${requiredKey} not provided.`);\n }\n }\n }\n\n reset(): void {\n if (this.#status === Status.PARSING) {\n throw new Error('Trace processor can\\'t reset while parsing.');\n }\n\n const handlers = Object.values(this.#traceHandlers);\n for (const handler of handlers) {\n handler.reset();\n }\n\n this.#data = null;\n this.#insights = null;\n this.#status = Status.IDLE;\n }\n\n async parse(traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions): Promise<void> {\n if (this.#status !== Status.IDLE) {\n throw new Error(`Trace processor can't start parsing when not idle. Current state: ${this.#status}`);\n }\n\n if (typeof options.isCPUProfile === 'undefined' && options.metadata) {\n options.isCPUProfile = options.metadata.dataOrigin === Types.File.DataOrigin.CPU_PROFILE;\n }\n\n options.logger?.start('total');\n try {\n this.#status = Status.PARSING;\n options.logger?.start('parse');\n await this.#computeParsedTrace(traceEvents, options);\n options.logger?.end('parse');\n if (this.#data && !options.isCPUProfile) { // We do not calculate insights for CPU Profiles.\n options.logger?.start('insights');\n this.#computeInsights(this.#data, traceEvents, options);\n options.logger?.end('insights');\n }\n this.#status = Status.FINISHED_PARSING;\n } catch (e) {\n this.#status = Status.ERRORED_WHILE_PARSING;\n throw e;\n } finally {\n options.logger?.end('total');\n }\n }\n\n /**\n * Run all the handlers and set the result to `#data`.\n */\n async #computeParsedTrace(traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions):\n Promise<void> {\n /**\n * We want to yield regularly to maintain responsiveness. If we yield too often, we're wasting idle time.\n * We could do this by checking `performance.now()` regularly, but it's an expensive call in such a hot loop.\n * `eventsPerChunk` is an approximated proxy metric.\n * But how big a chunk? We're aiming for long tasks that are no smaller than 100ms and not bigger than 200ms.\n * It's CPU dependent, so it should be calibrated on oldish hardware.\n * Illustration of a previous change to `eventsPerChunk`: https://imgur.com/wzp8BnR\n */\n const eventsPerChunk = 50_000;\n // Convert to array so that we are able to iterate all handlers multiple times.\n const sortedHandlers = [...sortHandlers(this.#traceHandlers).entries()];\n\n // Reset.\n for (const [, handler] of sortedHandlers) {\n handler.reset();\n }\n\n options.logger?.start('parse:handleEvent');\n\n // In bundled builds each handler is a module namespace object whose exports are getters, and every handler has a\n // different shape. V8 can't optimise a `handler.handleEvent` read that sees all these shapes, so reading it inside the\n // loop costs a slow getter call for every event and handler.\n // On a 1M-event trace that is about 30M getter calls per parse. Reading each `handleEvent` once here cut the\n // handleEvent loop from ~2.9s to ~2.1s (-25%) and total parse time by ~10%, so keep this read outside the loop.\n const handleEventFns = sortedHandlers.map(([, handler]) => handler.handleEvent);\n\n // Handle each event.\n for (let i = 0; i < traceEvents.length; ++i) {\n // Every so often we take a break just to render.\n if (options.yieldToMain !== false && i % eventsPerChunk === 0 && i) {\n // Take the opportunity to provide status update events.\n const percent = calculateProgress(i / traceEvents.length, ProgressPhase.HANDLE_EVENT);\n this.dispatchEvent(new TraceParseProgressEvent({percent}));\n // TODO(paulirish): consider using `scheduler.yield()` or `scheduler.postTask(() => {}, {priority: 'user-blocking'})`\n await new Promise(resolve => setTimeout(resolve, 0));\n }\n const event = traceEvents[i];\n for (let j = 0; j < handleEventFns.length; ++j) {\n handleEventFns[j](event);\n }\n }\n\n options.logger?.end('parse:handleEvent');\n\n // Finalize.\n const finalizeOptions: Handlers.Types.FinalizeOptions = {\n ...options,\n allTraceEvents: traceEvents,\n };\n for (let i = 0; i < sortedHandlers.length; i++) {\n const [name, handler] = sortedHandlers[i];\n if (handler.finalize) {\n options.logger?.start(`parse:${name}:finalize`);\n if (options.yieldToMain !== false) {\n // Yield to the UI because finalize() calls can be expensive\n // TODO(jacktfranklin): consider using `scheduler.yield()` or `scheduler.postTask(() => {}, {priority: 'user-blocking'})`\n await new Promise(resolve => setTimeout(resolve, 0));\n }\n await handler.finalize(finalizeOptions);\n options.logger?.end(`parse:${name}:finalize`);\n }\n const percent = calculateProgress(i / sortedHandlers.length, ProgressPhase.FINALIZE);\n this.dispatchEvent(new TraceParseProgressEvent({percent}));\n }\n\n options.logger?.start('parse:handler.data()');\n const parsedTrace = {};\n for (const [name, handler] of Object.entries(this.#traceHandlers)) {\n Object.assign(parsedTrace, {[name]: handler.data()});\n }\n options.logger?.end('parse:handler.data()');\n\n this.dispatchEvent(new TraceParseProgressEvent({percent: ProgressPhase.FINALIZE}));\n\n this.#data = parsedTrace as Handlers.Types.HandlerData;\n }\n\n get data(): Handlers.Types.HandlerData|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n return this.#data;\n }\n\n get insights(): Insights.Types.TraceInsightSets|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n return this.#insights;\n }\n\n #createLanternContext(\n data: Handlers.Types.HandlerData, traceEvents: readonly Types.Events.Event[], frameId: string,\n navigation: Types.Events.NavigationStart,\n options: Types.Configuration.ParseOptions): Insights.Types.LanternContext|undefined {\n // Check for required handlers.\n if (!data.NetworkRequests || !data.Workers || !data.PageLoadMetrics) {\n return;\n }\n if (!data.NetworkRequests.byTime.length) {\n throw new Lantern.Core.LanternError('No network requests found in trace');\n }\n\n const navStarts = data.Meta.navigationsByFrameId.get(frameId);\n const navStartIndex = navStarts?.findIndex(n => n === navigation);\n if (!navStarts || navStartIndex === undefined || navStartIndex === -1) {\n throw new Lantern.Core.LanternError('Could not find navigation start');\n }\n\n const startTime = navStarts[navStartIndex].ts;\n const endTime = navStartIndex + 1 < navStarts.length ? navStarts[navStartIndex + 1].ts : Number.POSITIVE_INFINITY;\n const boundedTraceEvents = traceEvents.filter(e => e.ts >= startTime && e.ts < endTime);\n\n // Lantern.Types.TraceEvent and Types.Events.Event represent the same\n // object - a trace event - but one is more flexible than the other. It should be safe to cast between them.\n const trace: Lantern.Types.Trace = {\n traceEvents: boundedTraceEvents as unknown as Lantern.Types.TraceEvent[],\n };\n\n const requests = LanternComputationData.createNetworkRequests(trace, data, startTime, endTime);\n const graph = LanternComputationData.createGraph(requests, trace, data);\n const processedNavigation = LanternComputationData.createProcessedNavigation(data, frameId, navigation);\n\n const networkAnalysis = Lantern.Core.NetworkAnalyzer.analyze(requests);\n if (!networkAnalysis) {\n return;\n }\n\n const lanternSettings: Lantern.Types.Simulation.Settings = {\n // TODO(crbug.com/372674229): if devtools throttling was on, does this network analysis capture\n // that? Do we need to set 'devtools' throttlingMethod?\n networkAnalysis,\n throttlingMethod: 'provided',\n ...options.lanternSettings,\n };\n const simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest> =\n Lantern.Simulation.Simulator.createSimulator(lanternSettings);\n\n const computeData = {graph, simulator, processedNavigation};\n const fcpResult = Lantern.Metrics.FirstContentfulPaint.compute(computeData);\n const lcpResult = Lantern.Metrics.LargestContentfulPaint.compute(computeData, {fcpResult});\n const interactiveResult = Lantern.Metrics.Interactive.compute(computeData, {lcpResult});\n const tbtResult = Lantern.Metrics.TotalBlockingTime.compute(computeData, {fcpResult, interactiveResult});\n const metrics = {\n firstContentfulPaint: fcpResult,\n interactive: interactiveResult,\n largestContentfulPaint: lcpResult,\n totalBlockingTime: tbtResult,\n };\n\n return {requests, graph, simulator, metrics};\n }\n\n /**\n * Sort the insight models based on the impact of each insight's estimated savings, additionally weighted by the\n * worst metrics according to field data (if present).\n */\n sortInsightSet(insightSet: Insights.Types.InsightSet, metadata: Types.File.MetaData|null): void {\n // The initial order of the insights is alphabetical, based on `front_end/models/trace/insights/Models.ts`.\n // The order here provides a baseline that groups insights in a more logical way.\n const baselineOrder: Record<keyof Insights.Types.InsightModels, null> = {\n INPBreakdown: null,\n LCPBreakdown: null,\n LCPDiscovery: null,\n CLSCulprits: null,\n RenderBlocking: null,\n NetworkDependencyTree: null,\n ImageDelivery: null,\n DocumentLatency: null,\n FontDisplay: null,\n Viewport: null,\n DOMSize: null,\n ThirdParties: null,\n DuplicatedJavaScript: null,\n SlowCSSSelector: null,\n ForcedReflow: null,\n Cache: null,\n CharacterSet: null,\n ModernHTTP: null,\n LegacyJavaScript: null,\n };\n\n // Determine the weights for each metric based on field data, utilizing the same scoring curve that Lighthouse uses.\n const weights = Insights.Common.calculateMetricWeightsForSorting(insightSet, metadata);\n\n // Normalize the estimated savings to a single number, weighted by its relative impact\n // to the page experience based on the same scoring curve that Lighthouse uses.\n const observedLcpMicro = Insights.Common.getLCP(insightSet)?.value;\n const observedLcp = observedLcpMicro ? Helpers.Timing.microToMilli(observedLcpMicro) : Types.Timing.Milli(0);\n const observedCls = Insights.Common.getCLS(insightSet).value;\n\n // INP is special - if users did not interact with the page, we'll have no INP, but we should still\n // be able to prioritize insights based on this metric. When we observe no interaction, instead use\n // a default value for the baseline INP.\n const observedInpMicro = Insights.Common.getINP(insightSet)?.value;\n const observedInp = observedInpMicro ? Helpers.Timing.microToMilli(observedInpMicro) : Types.Timing.Milli(200);\n\n const observedLcpScore =\n observedLcp !== undefined ? Insights.Common.evaluateLCPMetricScore(observedLcp) : undefined;\n const observedInpScore = Insights.Common.evaluateINPMetricScore(observedInp);\n const observedClsScore = Insights.Common.evaluateCLSMetricScore(observedCls);\n\n const insightToSortingRank = new Map<string, number>();\n for (const [name, insight] of Object.entries(insightSet.model)) {\n const lcp = insight.metricSavings?.LCP ?? 0;\n const inp = insight.metricSavings?.INP ?? 0;\n const cls = insight.metricSavings?.CLS ?? 0;\n\n const lcpPostSavings =\n observedLcp !== undefined ? Math.max(0, observedLcp - lcp) as Types.Timing.Milli : undefined;\n const inpPostSavings = Math.max(0, observedInp - inp) as Types.Timing.Milli;\n const clsPostSavings = Math.max(0, observedCls - cls);\n\n let score = 0;\n if (weights.lcp && lcp && observedLcpScore !== undefined && lcpPostSavings !== undefined) {\n score += weights.lcp * (Insights.Common.evaluateLCPMetricScore(lcpPostSavings) - observedLcpScore);\n }\n if (weights.inp && inp && observedInpScore !== undefined) {\n score += weights.inp * (Insights.Common.evaluateINPMetricScore(inpPostSavings) - observedInpScore);\n }\n if (weights.cls && cls && observedClsScore !== undefined) {\n score += weights.cls * (Insights.Common.evaluateCLSMetricScore(clsPostSavings) - observedClsScore);\n }\n\n insightToSortingRank.set(name, score);\n }\n\n // Now perform the actual sorting.\n const baselineOrderKeys = Object.keys(baselineOrder);\n const orderedKeys = Object.keys(insightSet.model);\n orderedKeys.sort((a, b) => {\n const a1 = baselineOrderKeys.indexOf(a);\n const b1 = baselineOrderKeys.indexOf(b);\n if (a1 >= 0 && b1 >= 0) {\n return a1 - b1;\n }\n if (a1 >= 0) {\n return -1;\n }\n if (b1 >= 0) {\n return 1;\n }\n return 0;\n });\n orderedKeys.sort((a, b) => (insightToSortingRank.get(b) ?? 0) - (insightToSortingRank.get(a) ?? 0));\n\n const newModel = {} as Insights.Types.InsightModels;\n for (const key of orderedKeys as Array<keyof Insights.Types.InsightModels>) {\n const model = insightSet.model[key];\n // @ts-expect-error Maybe someday typescript will be powerful enough to handle this.\n newModel[key] = model;\n }\n insightSet.model = newModel;\n }\n\n #computeInsightSet(data: Handlers.Types.HandlerData, context: Insights.Types.InsightSetContext): void {\n const logger = context.options.logger;\n\n if (!this.#insights) {\n this.#insights = new Map();\n }\n\n let id, urlString, navigation;\n if (context.navigation) {\n id = `NAVIGATION_${this.#insights.size}`;\n if (Types.Events.isSoftNavigationStart(context.navigation)) {\n urlString = context.navigation.args.context.URL;\n } else {\n urlString = data.Meta.finalDisplayUrlByNavigationId.get(context.navigation.args.data?.navigationId ?? '') ??\n data.Meta.mainFrameURL;\n }\n navigation = context.navigation;\n } else {\n id = Types.Events.NO_NAVIGATION;\n urlString = data.Meta.finalDisplayUrlByNavigationId.get('') ?? data.Meta.mainFrameURL;\n }\n\n const insightSetModel = {} as Insights.Types.InsightModels;\n const insightSetModelErrors: Insights.Types.InsightModelErrors = {};\n\n for (const [name, insight] of Object.entries(TraceProcessor.getInsightRunners())) {\n try {\n logger?.start(`insights:${name}`);\n const model = insight.generateInsight(data, context);\n model.frameId = context.frameId;\n const navId = Helpers.Trace.navigationIDForEvent(context.navigation);\n if (navId) {\n model.navigation = context.navigation;\n }\n model.createOverlays = () => {\n // @ts-expect-error: model is a union of all possible insight model types.\n return insight.createOverlays(model);\n };\n Object.assign(insightSetModel, {[name]: model});\n } catch (err) {\n Object.assign(insightSetModelErrors, {[name]: err});\n } finally {\n logger?.end(`insights:${name}`);\n }\n }\n\n // We may choose to exclude the insightSet if it's trivial. Trivial means:\n // 1. There's no navigation (it's an initial trace period)\n // 2. The duration is short.\n // 3. All the insights are passing (aka no insights to show the user)\n // 4. It has no metrics to report (apart from a CLS of 0, which is default)\n // Generally, these cases are the short time ranges before a page reload starts.\n const isNavigation = id === Types.Events.NO_NAVIGATION;\n const trivialThreshold = Helpers.Timing.milliToMicro(Types.Timing.Milli(5000));\n const everyInsightPasses = Object.values(insightSetModel).every(model => model && model.state === 'pass');\n\n const noLcp = !insightSetModel.LCPBreakdown?.lcpEvent;\n const noInp = !insightSetModel.INPBreakdown?.longestInteractionEvent;\n const noLayoutShifts = insightSetModel.CLSCulprits?.shifts?.size === 0;\n const shouldExclude = isNavigation && context.bounds.range < trivialThreshold && everyInsightPasses && noLcp &&\n noInp && noLayoutShifts;\n if (shouldExclude) {\n return;\n }\n\n let url;\n try {\n url = new URL(urlString);\n } catch {\n // We're pretty sure this only happens for our test fixture: missing-url.json.gz. Shouldn't\n // happen for real traces.\n return;\n }\n\n const insightSet: Insights.Types.InsightSet = {\n id,\n url,\n navigation,\n frameId: context.frameId,\n bounds: context.bounds,\n model: insightSetModel,\n modelErrors: insightSetModelErrors,\n };\n this.#insights.set(insightSet.id, insightSet);\n this.sortInsightSet(insightSet, context.options.metadata ?? null);\n }\n\n /**\n * Run all the insights and set the result to `#insights`.\n */\n #computeInsights(\n data: Handlers.Types.HandlerData, traceEvents: readonly Types.Events.Event[],\n options: Types.Configuration.ParseOptions): void {\n // This insights map will be populated by the helper methods.\n this.#insights = new Map();\n\n // Filter main frame navigations to those that have the necessary data (frameId and navigationId).\n // TODO(cjamcl): Does this filtering makes the \"use the next nav as the end time\" logic potentially broken? Are navs without nav id or frame even real?\n const hardNavigations = data.Meta.mainFrameNavigations.filter(navigation => navigation.args.frame &&\n navigation.args.data?.navigationId);\n\n const softNavigations =\n this.#modelConfiguration.enableSoftNavigation ? Array.from(data.Meta.softNavigationsById.values()) : [];\n const navigations = [...hardNavigations, ...softNavigations].sort((a, b) => a.ts - b.ts);\n\n this.#computeInsightsForInitialTracePeriod(data, navigations, options);\n\n for (const [index, navigation] of navigations.entries()) {\n const min = navigation.ts;\n // Use trace end for the last navigation, otherwise use the start of the next navigation (minus 1 to avoid overlap).\n let max = index + 1 < navigations.length ? navigations[index + 1].ts : data.Meta.traceBounds.max;\n if (index + 1 < navigations.length) {\n max = Types.Timing.Micro(max - 1);\n }\n const bounds = Helpers.Timing.traceWindowFromMicroSeconds(min, max);\n if (Types.Events.isSoftNavigationStart(navigation)) {\n this.#computeInsightsForSoftNavigation(navigation, bounds, data, options);\n } else {\n this.#computeInsightsForNavigation(navigation, bounds, data, traceEvents, options);\n }\n }\n }\n\n /**\n * Computes insights for the period before the first navigation, or for the entire trace if no navigations exist.\n */\n #computeInsightsForInitialTracePeriod(\n data: Handlers.Types.HandlerData,\n navigations: ReadonlyArray<Types.Events.NavigationStart|Types.Events.SoftNavigationStart>,\n options: Types.Configuration.ParseOptions): void {\n // Determine bounds: Use the period before the first navigation if navigations exist, otherwise use the entire trace bounds.\n const bounds = navigations.length > 0 ? Helpers.Timing.traceWindowFromMicroSeconds(\n data.Meta.traceBounds.min, Types.Timing.Micro(navigations[0].ts - 1)) :\n data.Meta.traceBounds;\n\n const context: Insights.Types.InsightSetContext = {\n options,\n bounds,\n frameId: data.Meta.mainFrameId,\n // No navigation or lantern context applies to this initial/no-navigation period.\n };\n this.#computeInsightSet(data, context);\n }\n\n /**\n * Computes insights for a specific navigation event.\n */\n #computeInsightsForNavigation(\n navigation: Types.Events.NavigationStart, bounds: Types.Timing.TraceWindowMicro, data: Handlers.Types.HandlerData,\n traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions): void {\n const frameId = navigation.args.frame;\n // Guaranteed by the filter in #computeInsights\n const navigationId = navigation.args.data?.navigationId as string;\n\n // The lantern sub-context is optional on InsightSetContext, so not setting it is OK.\n // This is also a hedge against an error inside Lantern resulting in breaking the entire performance panel.\n // Additionally, many trace fixtures are too old to be processed by Lantern.\n let lantern: Insights.Types.LanternContext|undefined;\n try {\n options.logger?.start('insights:createLanternContext');\n lantern = this.#createLanternContext(data, traceEvents, frameId, navigation, options);\n } catch (e) {\n // Handle Lantern errors gracefully\n // Don't allow an error in constructing the Lantern graphs to break the rest of the trace processor.\n // Log unexpected errors, but suppress anything that occurs from a trace being too old.\n // Otherwise tests using old fixtures become way too noisy.\n const expectedErrors = [\n 'mainDocumentRequest not found',\n 'missing metric scores for frame',\n 'missing metric scores for specified navigation',\n 'missing metric: FCP',\n 'missing metric: LCP',\n 'NO_LCP',\n 'No network requests found in trace',\n 'Trace is too old',\n ];\n if (!(e instanceof Lantern.Core.LanternError)) {\n // If this wasn't a managed LanternError, the stack trace is likely needed for debugging.\n console.error(e);\n } else if (!expectedErrors.some(err => e.message === err)) {\n // To reduce noise from tests, only print errors that are not expected to occur because a trace is\n // too old (for which there is no single check).\n console.error(e);\n }\n } finally {\n options.logger?.end('insights:createLanternContext');\n }\n\n const context: Insights.Types.InsightSetContext = {\n options,\n bounds,\n frameId,\n navigation,\n navigationId,\n lantern,\n };\n this.#computeInsightSet(data, context);\n }\n\n /**\n * Computes insights for a specific soft navigation event.\n */\n #computeInsightsForSoftNavigation(navigation: Types.Events.SoftNavigationStart, bounds: Types.Timing.TraceWindowMicro,\n data: Handlers.Types.HandlerData, options: Types.Configuration.ParseOptions): void {\n const frameId = navigation.args.frame;\n const context: Insights.Types.InsightSetContextWithSoftNavigation = {\n options,\n bounds,\n frameId,\n navigation,\n };\n this.#computeInsightSet(data, context);\n }\n}\n\n/**\n * Some Handlers need data provided by others. Dependencies of a handler handler are\n * declared in the `deps` field.\n * @returns A map from trace event handler name to trace event handler whose entries\n * iterate in such a way that each handler is visited after its dependencies.\n */\nexport function sortHandlers(traceHandlers: Partial<Record<Handlers.Types.HandlerName, Handlers.Types.Handler>>):\n Map<Handlers.Types.HandlerName, Handlers.Types.Handler> {\n const sortedMap = new Map<Handlers.Types.HandlerName, Handlers.Types.Handler>();\n const visited = new Set<Handlers.Types.HandlerName>();\n const visitHandler = (handlerName: Handlers.Types.HandlerName): void => {\n if (sortedMap.has(handlerName)) {\n return;\n }\n if (visited.has(handlerName)) {\n let stackPath = '';\n for (const handler of visited) {\n if (stackPath || handler === handlerName) {\n stackPath += `${handler}->`;\n }\n }\n stackPath += handlerName;\n throw new Error(`Found dependency cycle in trace event handlers: ${stackPath}`);\n }\n visited.add(handlerName);\n const handler = traceHandlers[handlerName];\n if (!handler) {\n return;\n }\n const deps = handler.deps?.();\n if (deps) {\n deps.forEach(visitHandler);\n }\n sortedMap.set(handlerName, handler);\n };\n\n for (const handlerName of Object.keys(traceHandlers)) {\n visitHandler(handlerName as Handlers.Types.HandlerName);\n }\n return sortedMap;\n}\n"]}
1
+ {"version":3,"file":"Processor.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/Processor.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;;AAE7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAEtE,OAAO,KAAK,KAAK,MAAM,kBAAkB,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AK,CAAC,mDAAmD,SAAS,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9B,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACrD,YAAY,CAAC,WAAyC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,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 Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Lantern from './lantern/lantern.js';\nimport * as LanternComputationData from './LanternComputationData.js';\nimport type * as Model from './ModelImpl.js';\nimport * as Types from './types/types.js';\n\nconst enum Status {\n IDLE = 'IDLE',\n PARSING = 'PARSING',\n FINISHED_PARSING = 'FINISHED_PARSING',\n ERRORED_WHILE_PARSING = 'ERRORED_WHILE_PARSING',\n}\n\nexport class TraceParseProgressEvent extends Event {\n static readonly eventName = 'traceparseprogress';\n constructor(\n public data: Model.TraceParseEventProgressData,\n init: ConstructorParameters<typeof Event>[1] = {bubbles: true},\n ) {\n super(TraceParseProgressEvent.eventName, init);\n }\n}\n\n/**\n * Parsing a trace can take time. On large traces we see a breakdown of time like so:\n * - handleEvent() loop: ~25%\n * - finalize() loop: ~75%\n * The numbers below are set so we can report a progress percentage of [0...1]\n */\nconst enum ProgressPhase {\n HANDLE_EVENT = 0.25,\n FINALIZE = 1.0,\n}\nfunction calculateProgress(value: number, phase: ProgressPhase): number {\n // Finalize values should be [0.25...1].\n if (phase === ProgressPhase.FINALIZE) {\n return (value * (ProgressPhase.FINALIZE - ProgressPhase.HANDLE_EVENT)) + ProgressPhase.HANDLE_EVENT;\n }\n return value * phase;\n}\n\nexport class TraceProcessor extends EventTarget {\n // We force the Meta handler to be enabled, so the TraceHandlers type here is\n // the model handlers the user passes in and the Meta handler.\n readonly #traceHandlers: Partial<Handlers.Types.Handlers>;\n #status = Status.IDLE;\n #modelConfiguration = Types.Configuration.defaults();\n #data: Handlers.Types.HandlerData|null = null;\n #insights: Insights.Types.TraceInsightSets|null = null;\n\n static createWithAllHandlers(): TraceProcessor {\n return new TraceProcessor(Handlers.ModelHandlers, Types.Configuration.defaults());\n }\n\n /**\n * This function is kept for testing with `stub`.\n */\n static getInsightRunners(): Insights.Types.InsightModelsType {\n return {...Insights.Models};\n }\n\n constructor(traceHandlers: Partial<Handlers.Types.Handlers>, modelConfiguration?: Types.Configuration.Configuration) {\n super();\n\n this.#verifyHandlers(traceHandlers);\n this.#traceHandlers = {\n Meta: Handlers.ModelHandlers.Meta,\n ...traceHandlers,\n };\n if (modelConfiguration) {\n this.#modelConfiguration = modelConfiguration;\n }\n this.#passConfigToHandlers();\n }\n\n #passConfigToHandlers(): void {\n for (const handler of Object.values(this.#traceHandlers)) {\n // Bit of an odd double check, but without this TypeScript refuses to let\n // you call the function as it thinks it might be undefined.\n if ('handleUserConfig' in handler && handler.handleUserConfig) {\n handler.handleUserConfig(this.#modelConfiguration);\n }\n }\n }\n\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#modelConfiguration = config;\n this.#passConfigToHandlers();\n }\n\n /**\n * When the user passes in a set of handlers, we want to ensure that we have all\n * the required handlers. Handlers can depend on other handlers, so if the user\n * passes in FooHandler which depends on BarHandler, they must also pass in\n * BarHandler too. This method verifies that all dependencies are met, and\n * throws if not.\n **/\n #verifyHandlers(providedHandlers: Partial<Handlers.Types.Handlers>): void {\n // Tiny optimisation: if the amount of provided handlers matches the amount\n // of handlers in the Handlers.ModelHandlers object, that means that the\n // user has passed in every handler we have. So therefore they cannot have\n // missed any, and there is no need to iterate through the handlers and\n // check the dependencies.\n if (Object.keys(providedHandlers).length === Object.keys(Handlers.ModelHandlers).length) {\n return;\n }\n const requiredHandlerKeys = new Set<Handlers.Types.HandlerName>();\n for (const [handlerName, handler] of Object.entries(providedHandlers)) {\n requiredHandlerKeys.add(handlerName as Handlers.Types.HandlerName);\n const deps = 'deps' in handler ? handler.deps() : [];\n for (const depName of deps) {\n requiredHandlerKeys.add(depName);\n }\n }\n\n const providedHandlerKeys = new Set(Object.keys(providedHandlers));\n // We always force the Meta handler to be enabled when creating the\n // Processor, so if it is missing from the set the user gave us that is OK,\n // as we will have enabled it anyway.\n requiredHandlerKeys.delete('Meta');\n\n for (const requiredKey of requiredHandlerKeys) {\n if (!providedHandlerKeys.has(requiredKey)) {\n throw new Error(`Required handler ${requiredKey} not provided.`);\n }\n }\n }\n\n reset(): void {\n if (this.#status === Status.PARSING) {\n throw new Error('Trace processor can\\'t reset while parsing.');\n }\n\n const handlers = Object.values(this.#traceHandlers);\n for (const handler of handlers) {\n handler.reset();\n }\n\n this.#data = null;\n this.#insights = null;\n this.#status = Status.IDLE;\n }\n\n async parse(traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions): Promise<void> {\n if (this.#status !== Status.IDLE) {\n throw new Error(`Trace processor can't start parsing when not idle. Current state: ${this.#status}`);\n }\n\n if (typeof options.isCPUProfile === 'undefined' && options.metadata) {\n options.isCPUProfile = options.metadata.dataOrigin === Types.File.DataOrigin.CPU_PROFILE;\n }\n\n options.logger?.start('total');\n try {\n this.#status = Status.PARSING;\n options.logger?.start('parse');\n await this.#computeParsedTrace(traceEvents, options);\n options.logger?.end('parse');\n if (this.#data && !options.isCPUProfile) { // We do not calculate insights for CPU Profiles.\n options.logger?.start('insights');\n this.#computeInsights(this.#data, traceEvents, options);\n options.logger?.end('insights');\n }\n this.#status = Status.FINISHED_PARSING;\n } catch (e) {\n this.#status = Status.ERRORED_WHILE_PARSING;\n throw e;\n } finally {\n options.logger?.end('total');\n }\n }\n\n /**\n * Run all the handlers and set the result to `#data`.\n */\n async #computeParsedTrace(traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions):\n Promise<void> {\n /**\n * We want to yield regularly to maintain responsiveness. If we yield too often, we're wasting idle time.\n * We could do this by checking `performance.now()` regularly, but it's an expensive call in such a hot loop.\n * `eventsPerChunk` is an approximated proxy metric.\n * But how big a chunk? We're aiming for long tasks that are no smaller than 100ms and not bigger than 200ms.\n * It's CPU dependent, so it should be calibrated on oldish hardware.\n * Illustration of a previous change to `eventsPerChunk`: https://imgur.com/wzp8BnR\n */\n const eventsPerChunk = 50_000;\n // Convert to array so that we are able to iterate all handlers multiple times.\n const sortedHandlers = [...sortHandlers(this.#traceHandlers).entries()];\n\n // Reset.\n for (const [, handler] of sortedHandlers) {\n handler.reset();\n }\n\n options.logger?.start('parse:handleEvent');\n\n // In bundled builds each handler is a module namespace object whose exports are getters, and every handler has a\n // different shape. V8 can't optimise a `handler.handleEvent` read that sees all these shapes, so reading it inside the\n // loop costs a slow getter call for every event and handler.\n // On a 1M-event trace that is about 30M getter calls per parse. Reading each `handleEvent` once here cut the\n // handleEvent loop from ~2.9s to ~2.1s (-25%) and total parse time by ~10%, so keep this read outside the loop.\n const handleEventFns = sortedHandlers.map(([, handler]) => handler.handleEvent);\n\n // Handle each event.\n for (let i = 0; i < traceEvents.length; ++i) {\n // Every so often we take a break just to render.\n if (options.yieldToMain !== false && i % eventsPerChunk === 0 && i) {\n // Take the opportunity to provide status update events.\n const percent = calculateProgress(i / traceEvents.length, ProgressPhase.HANDLE_EVENT);\n this.dispatchEvent(new TraceParseProgressEvent({percent}));\n // TODO(paulirish): consider using `scheduler.yield()` or `scheduler.postTask(() => {}, {priority: 'user-blocking'})`\n await new Promise(resolve => setTimeout(resolve, 0));\n }\n const event = traceEvents[i];\n for (let j = 0; j < handleEventFns.length; ++j) {\n handleEventFns[j](event);\n }\n }\n\n options.logger?.end('parse:handleEvent');\n\n // Finalize.\n const finalizeOptions: Handlers.Types.FinalizeOptions = {\n ...options,\n allTraceEvents: traceEvents,\n };\n for (let i = 0; i < sortedHandlers.length; i++) {\n const [name, handler] = sortedHandlers[i];\n if (handler.finalize) {\n options.logger?.start(`parse:${name}:finalize`);\n if (options.yieldToMain !== false) {\n // Yield to the UI because finalize() calls can be expensive\n // TODO(jacktfranklin): consider using `scheduler.yield()` or `scheduler.postTask(() => {}, {priority: 'user-blocking'})`\n await new Promise(resolve => setTimeout(resolve, 0));\n }\n await handler.finalize(finalizeOptions);\n options.logger?.end(`parse:${name}:finalize`);\n }\n const percent = calculateProgress(i / sortedHandlers.length, ProgressPhase.FINALIZE);\n this.dispatchEvent(new TraceParseProgressEvent({percent}));\n }\n\n options.logger?.start('parse:handler.data()');\n const parsedTrace = {};\n for (const [name, handler] of Object.entries(this.#traceHandlers)) {\n Object.assign(parsedTrace, {[name]: handler.data()});\n }\n options.logger?.end('parse:handler.data()');\n\n this.dispatchEvent(new TraceParseProgressEvent({percent: ProgressPhase.FINALIZE}));\n\n this.#data = parsedTrace as Handlers.Types.HandlerData;\n }\n\n get data(): Handlers.Types.HandlerData|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n return this.#data;\n }\n\n get insights(): Insights.Types.TraceInsightSets|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n return this.#insights;\n }\n\n #createLanternContext(\n data: Handlers.Types.HandlerData, traceEvents: readonly Types.Events.Event[], frameId: string,\n navigation: Types.Events.NavigationStart,\n options: Types.Configuration.ParseOptions): Insights.Types.LanternContext|undefined {\n // Check for required handlers.\n if (!data.NetworkRequests || !data.Workers || !data.PageLoadMetrics) {\n return;\n }\n if (!data.NetworkRequests.byTime.length) {\n throw new Lantern.Core.LanternError('No network requests found in trace');\n }\n\n const navStarts = data.Meta.navigationsByFrameId.get(frameId);\n const navStartIndex = navStarts?.findIndex(n => n === navigation);\n if (!navStarts || navStartIndex === undefined || navStartIndex === -1) {\n throw new Lantern.Core.LanternError('Could not find navigation start');\n }\n\n const processedNavigation = LanternComputationData.createProcessedNavigation(data, frameId, navigation);\n\n const startTime = navStarts[navStartIndex].ts;\n const endTime = navStartIndex + 1 < navStarts.length ? navStarts[navStartIndex + 1].ts : Number.POSITIVE_INFINITY;\n const boundedTraceEvents = traceEvents.filter(e => e.ts >= startTime && e.ts < endTime);\n\n // Lantern.Types.TraceEvent and Types.Events.Event represent the same\n // object - a trace event - but one is more flexible than the other. It should be safe to cast between them.\n const trace: Lantern.Types.Trace = {\n traceEvents: boundedTraceEvents as unknown as Lantern.Types.TraceEvent[],\n };\n\n const requests = LanternComputationData.createNetworkRequests(trace, data, startTime, endTime);\n const graph = LanternComputationData.createGraph(requests, trace, data);\n\n const networkAnalysis = Lantern.Core.NetworkAnalyzer.analyze(requests);\n if (!networkAnalysis) {\n return;\n }\n\n const lanternSettings: Lantern.Types.Simulation.Settings = {\n // TODO(crbug.com/372674229): if devtools throttling was on, does this network analysis capture\n // that? Do we need to set 'devtools' throttlingMethod?\n networkAnalysis,\n throttlingMethod: 'provided',\n ...options.lanternSettings,\n };\n const simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest> =\n Lantern.Simulation.Simulator.createSimulator(lanternSettings);\n\n const computeData = {graph, simulator, processedNavigation};\n const fcpResult = Lantern.Metrics.FirstContentfulPaint.compute(computeData);\n const lcpResult = Lantern.Metrics.LargestContentfulPaint.compute(computeData, {fcpResult});\n const interactiveResult = Lantern.Metrics.Interactive.compute(computeData, {lcpResult});\n const tbtResult = Lantern.Metrics.TotalBlockingTime.compute(computeData, {fcpResult, interactiveResult});\n const metrics = {\n firstContentfulPaint: fcpResult,\n interactive: interactiveResult,\n largestContentfulPaint: lcpResult,\n totalBlockingTime: tbtResult,\n };\n\n return {requests, graph, simulator, metrics};\n }\n\n /**\n * Sort the insight models based on the impact of each insight's estimated savings, additionally weighted by the\n * worst metrics according to field data (if present).\n */\n sortInsightSet(insightSet: Insights.Types.InsightSet, metadata: Types.File.MetaData|null): void {\n // The initial order of the insights is alphabetical, based on `front_end/models/trace/insights/Models.ts`.\n // The order here provides a baseline that groups insights in a more logical way.\n const baselineOrder: Record<keyof Insights.Types.InsightModels, null> = {\n INPBreakdown: null,\n LCPBreakdown: null,\n LCPDiscovery: null,\n CLSCulprits: null,\n RenderBlocking: null,\n NetworkDependencyTree: null,\n ImageDelivery: null,\n DocumentLatency: null,\n FontDisplay: null,\n Viewport: null,\n DOMSize: null,\n ThirdParties: null,\n DuplicatedJavaScript: null,\n SlowCSSSelector: null,\n ForcedReflow: null,\n Cache: null,\n CharacterSet: null,\n ModernHTTP: null,\n LegacyJavaScript: null,\n };\n\n // Determine the weights for each metric based on field data, utilizing the same scoring curve that Lighthouse uses.\n const weights = Insights.Common.calculateMetricWeightsForSorting(insightSet, metadata);\n\n // Normalize the estimated savings to a single number, weighted by its relative impact\n // to the page experience based on the same scoring curve that Lighthouse uses.\n const observedLcpMicro = Insights.Common.getLCP(insightSet)?.value;\n const observedLcp = observedLcpMicro ? Helpers.Timing.microToMilli(observedLcpMicro) : Types.Timing.Milli(0);\n const observedCls = Insights.Common.getCLS(insightSet).value;\n\n // INP is special - if users did not interact with the page, we'll have no INP, but we should still\n // be able to prioritize insights based on this metric. When we observe no interaction, instead use\n // a default value for the baseline INP.\n const observedInpMicro = Insights.Common.getINP(insightSet)?.value;\n const observedInp = observedInpMicro ? Helpers.Timing.microToMilli(observedInpMicro) : Types.Timing.Milli(200);\n\n const observedLcpScore =\n observedLcp !== undefined ? Insights.Common.evaluateLCPMetricScore(observedLcp) : undefined;\n const observedInpScore = Insights.Common.evaluateINPMetricScore(observedInp);\n const observedClsScore = Insights.Common.evaluateCLSMetricScore(observedCls);\n\n const insightToSortingRank = new Map<string, number>();\n for (const [name, insight] of Object.entries(insightSet.model)) {\n const lcp = insight.metricSavings?.LCP ?? 0;\n const inp = insight.metricSavings?.INP ?? 0;\n const cls = insight.metricSavings?.CLS ?? 0;\n\n const lcpPostSavings =\n observedLcp !== undefined ? Math.max(0, observedLcp - lcp) as Types.Timing.Milli : undefined;\n const inpPostSavings = Math.max(0, observedInp - inp) as Types.Timing.Milli;\n const clsPostSavings = Math.max(0, observedCls - cls);\n\n let score = 0;\n if (weights.lcp && lcp && observedLcpScore !== undefined && lcpPostSavings !== undefined) {\n score += weights.lcp * (Insights.Common.evaluateLCPMetricScore(lcpPostSavings) - observedLcpScore);\n }\n if (weights.inp && inp && observedInpScore !== undefined) {\n score += weights.inp * (Insights.Common.evaluateINPMetricScore(inpPostSavings) - observedInpScore);\n }\n if (weights.cls && cls && observedClsScore !== undefined) {\n score += weights.cls * (Insights.Common.evaluateCLSMetricScore(clsPostSavings) - observedClsScore);\n }\n\n insightToSortingRank.set(name, score);\n }\n\n // Now perform the actual sorting.\n const baselineOrderKeys = Object.keys(baselineOrder);\n const orderedKeys = Object.keys(insightSet.model);\n orderedKeys.sort((a, b) => {\n const a1 = baselineOrderKeys.indexOf(a);\n const b1 = baselineOrderKeys.indexOf(b);\n if (a1 >= 0 && b1 >= 0) {\n return a1 - b1;\n }\n if (a1 >= 0) {\n return -1;\n }\n if (b1 >= 0) {\n return 1;\n }\n return 0;\n });\n orderedKeys.sort((a, b) => (insightToSortingRank.get(b) ?? 0) - (insightToSortingRank.get(a) ?? 0));\n\n const newModel = {} as Insights.Types.InsightModels;\n for (const key of orderedKeys as Array<keyof Insights.Types.InsightModels>) {\n const model = insightSet.model[key];\n // @ts-expect-error Maybe someday typescript will be powerful enough to handle this.\n newModel[key] = model;\n }\n insightSet.model = newModel;\n }\n\n #computeInsightSet(data: Handlers.Types.HandlerData, context: Insights.Types.InsightSetContext): void {\n const logger = context.options.logger;\n\n if (!this.#insights) {\n this.#insights = new Map();\n }\n\n let id, urlString, navigation;\n if (context.navigation) {\n id = `NAVIGATION_${this.#insights.size}`;\n if (Types.Events.isSoftNavigationStart(context.navigation)) {\n urlString = context.navigation.args.context.URL;\n } else {\n urlString = data.Meta.finalDisplayUrlByNavigationId.get(context.navigation.args.data?.navigationId ?? '') ??\n data.Meta.mainFrameURL;\n }\n navigation = context.navigation;\n } else {\n id = Types.Events.NO_NAVIGATION;\n urlString = data.Meta.finalDisplayUrlByNavigationId.get('') ?? data.Meta.mainFrameURL;\n }\n\n const insightSetModel = {} as Insights.Types.InsightModels;\n const insightSetModelErrors: Insights.Types.InsightModelErrors = {};\n\n for (const [name, insight] of Object.entries(TraceProcessor.getInsightRunners())) {\n try {\n logger?.start(`insights:${name}`);\n const model = insight.generateInsight(data, context);\n model.frameId = context.frameId;\n const navId = Helpers.Trace.navigationIDForEvent(context.navigation);\n if (navId) {\n model.navigation = context.navigation;\n }\n model.createOverlays = () => {\n // @ts-expect-error: model is a union of all possible insight model types.\n return insight.createOverlays(model);\n };\n Object.assign(insightSetModel, {[name]: model});\n } catch (err) {\n Object.assign(insightSetModelErrors, {[name]: err});\n } finally {\n logger?.end(`insights:${name}`);\n }\n }\n\n // We may choose to exclude the insightSet if it's trivial. Trivial means:\n // 1. There's no navigation (it's an initial trace period)\n // 2. The duration is short.\n // 3. All the insights are passing (aka no insights to show the user)\n // 4. It has no metrics to report (apart from a CLS of 0, which is default)\n // Generally, these cases are the short time ranges before a page reload starts.\n const isNavigation = id === Types.Events.NO_NAVIGATION;\n const trivialThreshold = Helpers.Timing.milliToMicro(Types.Timing.Milli(5000));\n const everyInsightPasses = Object.values(insightSetModel).every(model => model && model.state === 'pass');\n\n const noLcp = !insightSetModel.LCPBreakdown?.lcpEvent;\n const noInp = !insightSetModel.INPBreakdown?.longestInteractionEvent;\n const noLayoutShifts = insightSetModel.CLSCulprits?.shifts?.size === 0;\n const shouldExclude = isNavigation && context.bounds.range < trivialThreshold && everyInsightPasses && noLcp &&\n noInp && noLayoutShifts;\n if (shouldExclude) {\n return;\n }\n\n let url;\n try {\n url = new URL(urlString);\n } catch {\n // We're pretty sure this only happens for our test fixture: missing-url.json.gz. Shouldn't\n // happen for real traces.\n return;\n }\n\n const insightSet: Insights.Types.InsightSet = {\n id,\n url,\n navigation,\n frameId: context.frameId,\n bounds: context.bounds,\n model: insightSetModel,\n modelErrors: insightSetModelErrors,\n };\n this.#insights.set(insightSet.id, insightSet);\n this.sortInsightSet(insightSet, context.options.metadata ?? null);\n }\n\n /**\n * Run all the insights and set the result to `#insights`.\n */\n #computeInsights(\n data: Handlers.Types.HandlerData, traceEvents: readonly Types.Events.Event[],\n options: Types.Configuration.ParseOptions): void {\n // This insights map will be populated by the helper methods.\n this.#insights = new Map();\n\n // Filter main frame navigations to those that have the necessary data (frameId and navigationId).\n // TODO(cjamcl): Does this filtering makes the \"use the next nav as the end time\" logic potentially broken? Are navs without nav id or frame even real?\n const hardNavigations = data.Meta.mainFrameNavigations.filter(navigation => navigation.args.frame &&\n navigation.args.data?.navigationId);\n\n const softNavigations =\n this.#modelConfiguration.enableSoftNavigation ? Array.from(data.Meta.softNavigationsById.values()) : [];\n const navigations = [...hardNavigations, ...softNavigations].sort((a, b) => a.ts - b.ts);\n\n this.#computeInsightsForInitialTracePeriod(data, navigations, options);\n\n for (const [index, navigation] of navigations.entries()) {\n const min = navigation.ts;\n // Use trace end for the last navigation, otherwise use the start of the next navigation (minus 1 to avoid overlap).\n let max = index + 1 < navigations.length ? navigations[index + 1].ts : data.Meta.traceBounds.max;\n if (index + 1 < navigations.length) {\n max = Types.Timing.Micro(max - 1);\n }\n const bounds = Helpers.Timing.traceWindowFromMicroSeconds(min, max);\n if (Types.Events.isSoftNavigationStart(navigation)) {\n this.#computeInsightsForSoftNavigation(navigation, bounds, data, options);\n } else {\n this.#computeInsightsForNavigation(navigation, bounds, data, traceEvents, options);\n }\n }\n }\n\n /**\n * Computes insights for the period before the first navigation, or for the entire trace if no navigations exist.\n */\n #computeInsightsForInitialTracePeriod(\n data: Handlers.Types.HandlerData,\n navigations: ReadonlyArray<Types.Events.NavigationStart|Types.Events.SoftNavigationStart>,\n options: Types.Configuration.ParseOptions): void {\n // Determine bounds: Use the period before the first navigation if navigations exist, otherwise use the entire trace bounds.\n const bounds = navigations.length > 0 ? Helpers.Timing.traceWindowFromMicroSeconds(\n data.Meta.traceBounds.min, Types.Timing.Micro(navigations[0].ts - 1)) :\n data.Meta.traceBounds;\n\n const context: Insights.Types.InsightSetContext = {\n options,\n bounds,\n frameId: data.Meta.mainFrameId,\n // No navigation or lantern context applies to this initial/no-navigation period.\n };\n this.#computeInsightSet(data, context);\n }\n\n /**\n * Computes insights for a specific navigation event.\n */\n #computeInsightsForNavigation(\n navigation: Types.Events.NavigationStart, bounds: Types.Timing.TraceWindowMicro, data: Handlers.Types.HandlerData,\n traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions): void {\n const frameId = navigation.args.frame;\n // Guaranteed by the filter in #computeInsights\n const navigationId = navigation.args.data?.navigationId as string;\n\n // The lantern sub-context is optional on InsightSetContext, so not setting it is OK.\n // This is also a hedge against an error inside Lantern resulting in breaking the entire performance panel.\n // Additionally, many trace fixtures are too old to be processed by Lantern.\n let lantern: Insights.Types.LanternContext|undefined;\n try {\n options.logger?.start('insights:createLanternContext');\n lantern = this.#createLanternContext(data, traceEvents, frameId, navigation, options);\n } catch (e) {\n // Handle Lantern errors gracefully\n // Don't allow an error in constructing the Lantern graphs to break the rest of the trace processor.\n // Log unexpected errors, but suppress anything that occurs from a trace being too old.\n // Otherwise tests using old fixtures become way too noisy.\n const expectedErrors = [\n 'mainDocumentRequest not found',\n 'missing metric scores for frame',\n 'missing metric scores for specified navigation',\n 'missing metric: FCP',\n 'missing metric: LCP',\n 'NO_LCP',\n 'No network requests found in trace',\n 'Trace is too old',\n ];\n if (!(e instanceof Lantern.Core.LanternError)) {\n // If this wasn't a managed LanternError, the stack trace is likely needed for debugging.\n console.error(e);\n } else if (!expectedErrors.some(err => e.message === err)) {\n // To reduce noise from tests, only print errors that are not expected to occur because a trace is\n // too old (for which there is no single check).\n console.error(e);\n }\n } finally {\n options.logger?.end('insights:createLanternContext');\n }\n\n const context: Insights.Types.InsightSetContext = {\n options,\n bounds,\n frameId,\n navigation,\n navigationId,\n lantern,\n };\n this.#computeInsightSet(data, context);\n }\n\n /**\n * Computes insights for a specific soft navigation event.\n */\n #computeInsightsForSoftNavigation(navigation: Types.Events.SoftNavigationStart, bounds: Types.Timing.TraceWindowMicro,\n data: Handlers.Types.HandlerData, options: Types.Configuration.ParseOptions): void {\n const frameId = navigation.args.frame;\n const context: Insights.Types.InsightSetContextWithSoftNavigation = {\n options,\n bounds,\n frameId,\n navigation,\n };\n this.#computeInsightSet(data, context);\n }\n}\n\n/**\n * Some Handlers need data provided by others. Dependencies of a handler handler are\n * declared in the `deps` field.\n * @returns A map from trace event handler name to trace event handler whose entries\n * iterate in such a way that each handler is visited after its dependencies.\n */\nexport function sortHandlers(traceHandlers: Partial<Record<Handlers.Types.HandlerName, Handlers.Types.Handler>>):\n Map<Handlers.Types.HandlerName, Handlers.Types.Handler> {\n const sortedMap = new Map<Handlers.Types.HandlerName, Handlers.Types.Handler>();\n const visited = new Set<Handlers.Types.HandlerName>();\n const visitHandler = (handlerName: Handlers.Types.HandlerName): void => {\n if (sortedMap.has(handlerName)) {\n return;\n }\n if (visited.has(handlerName)) {\n let stackPath = '';\n for (const handler of visited) {\n if (stackPath || handler === handlerName) {\n stackPath += `${handler}->`;\n }\n }\n stackPath += handlerName;\n throw new Error(`Found dependency cycle in trace event handlers: ${stackPath}`);\n }\n visited.add(handlerName);\n const handler = traceHandlers[handlerName];\n if (!handler) {\n return;\n }\n const deps = handler.deps?.();\n if (deps) {\n deps.forEach(visitHandler);\n }\n sortedMap.set(handlerName, handler);\n };\n\n for (const handlerName of Object.keys(traceHandlers)) {\n visitHandler(handlerName as Handlers.Types.HandlerName);\n }\n return sortedMap;\n}\n"]}
@@ -277,6 +277,31 @@ export class TopDownRootNode extends TopDownNode {
277
277
  return this.eventGroupIdCallback;
278
278
  }
279
279
  }
280
+ /**
281
+ * Maps a trace events array to the set of network request IDs served from cache.
282
+ * Timeline pans and zooms rebuild the tree with new time bounds over the same
283
+ * events array; memoizing this lookup avoids an O(N) full-trace scan per rebuild.
284
+ */
285
+ const cacheHitRequestIdsByEvents = new WeakMap();
286
+ function getCacheHitRequestIds(events) {
287
+ let cacheHitRequestIds = cacheHitRequestIdsByEvents.get(events);
288
+ if (!cacheHitRequestIds) {
289
+ const requestIds = new Set();
290
+ for (const e of events) {
291
+ if (Types.Events.isResourceReceiveResponse(e)) {
292
+ if (e.args.data.fromCache) {
293
+ requestIds.add(e.args.data.requestId);
294
+ }
295
+ else {
296
+ requestIds.delete(e.args.data.requestId);
297
+ }
298
+ }
299
+ }
300
+ cacheHitRequestIds = requestIds;
301
+ cacheHitRequestIdsByEvents.set(events, cacheHitRequestIds);
302
+ }
303
+ return cacheHitRequestIds;
304
+ }
280
305
  export class BottomUpRootNode extends Node {
281
306
  childrenInternal;
282
307
  textFilter;
@@ -334,7 +359,6 @@ export class BottomUpRootNode extends Node {
334
359
  // TODO(paulirish): rename to getGroupNodeId
335
360
  const eventGroupIdCallback = this.eventGroupIdCallback;
336
361
  const forceGroupIdCallback = this.forceGroupIdCallback;
337
- const idToIsCacheHit = new Map();
338
362
  // Node IDs are cached so that every event with the same ID reuses one
339
363
  // string. Building a new ID string per event, and hashing it again on
340
364
  // each Map lookup, is a large part of the cost of this loop on big
@@ -376,11 +400,9 @@ export class BottomUpRootNode extends Node {
376
400
  }
377
401
  return groupedId;
378
402
  };
379
- for (const e of this.events) {
380
- if (Types.Events.isReceivedDataEvent(e) && e.name === 'ResourceReceiveResponse') {
381
- idToIsCacheHit.set(nodeIdForEvent(e), e.args.data.fromCache || false);
382
- }
383
- }
403
+ // Evaluated lazily on the first relevant event to avoid a WeakMap lookup or
404
+ // full-trace scan when the time window contains no network data events.
405
+ let cacheHitRequestIds = null;
384
406
  // encodedDataLength is provided solely on instant events.
385
407
  const sumTransferSizeOfInstantEvent = (e) => {
386
408
  if (Types.Events.isReceivedDataEvent(e)) {
@@ -396,7 +418,8 @@ export class BottomUpRootNode extends Node {
396
418
  // ResourceReceivedData events tally up the transfer size over time, but the
397
419
  // ResourceReceiveResponse / ResourceFinish events hold the final result.
398
420
  if (e.name === 'ResourceReceivedData') {
399
- if (idToIsCacheHit.get(id)) {
421
+ cacheHitRequestIds ??= getCacheHitRequestIds(this.events);
422
+ if (cacheHitRequestIds.has(e.args.data.requestId)) {
400
423
  // It's a cache hit, so the actual network transfer size is 0.
401
424
  // We overwrite the tallied sum (which is uncompressed body size) with 0.
402
425
  node.transferSize = 0;
@@ -405,8 +428,11 @@ export class BottomUpRootNode extends Node {
405
428
  node.transferSize += e.args.data.encodedDataLength;
406
429
  }
407
430
  }
408
- else if (e.name === 'ResourceFinish' && e.args.data.encodedDataLength === 0 && idToIsCacheHit.get(id)) {
409
- node.transferSize = 0;
431
+ else if (e.name === 'ResourceFinish' && e.args.data.encodedDataLength === 0) {
432
+ cacheHitRequestIds ??= getCacheHitRequestIds(this.events);
433
+ if (cacheHitRequestIds.has(e.args.data.requestId)) {
434
+ node.transferSize = 0;
435
+ }
410
436
  }
411
437
  else if (e.args.data.encodedDataLength > 0) {
412
438
  // For some reason, ResourceFinish can be zero even if data was sent.