@paulirish/trace_engine 0.0.28 → 0.0.29
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.
- package/core/platform/SetUtilities.d.ts +0 -1
- package/core/platform/SetUtilities.js +0 -14
- package/core/platform/SetUtilities.js.map +1 -1
- package/generated/protocol.d.ts +61 -6
- package/models/trace/LanternComputationData.js +4 -4
- package/models/trace/LanternComputationData.js.map +1 -1
- package/models/trace/ModelImpl.d.ts +23 -23
- package/models/trace/ModelImpl.js +20 -12
- package/models/trace/ModelImpl.js.map +1 -1
- package/models/trace/Processor.d.ts +6 -7
- package/models/trace/Processor.js +102 -29
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/extras/URLForEntry.js +1 -1
- package/models/trace/extras/URLForEntry.js.map +1 -1
- package/models/trace/handlers/ExtensionTraceDataHandler.js +2 -6
- package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
- package/models/trace/handlers/InvalidationsHandler.d.ts +1 -1
- package/models/trace/handlers/InvalidationsHandler.js +2 -21
- package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.d.ts +1 -0
- package/models/trace/handlers/LayoutShiftsHandler.js +5 -0
- package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.d.ts +15 -0
- package/models/trace/handlers/NetworkRequestsHandler.js +98 -2
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/types.d.ts +1 -8
- package/models/trace/handlers/types.js +1 -17
- package/models/trace/handlers/types.js.map +1 -1
- package/models/trace/helpers/Extensions.d.ts +1 -1
- package/models/trace/helpers/Extensions.js +22 -8
- package/models/trace/helpers/Extensions.js.map +1 -1
- package/models/trace/helpers/Network.d.ts +2 -0
- package/models/trace/helpers/Network.js +7 -0
- package/models/trace/helpers/Network.js.map +1 -0
- package/models/trace/helpers/SyntheticEvents.d.ts +3 -8
- package/models/trace/helpers/SyntheticEvents.js +16 -25
- package/models/trace/helpers/SyntheticEvents.js.map +1 -1
- package/models/trace/helpers/Timing.d.ts +1 -0
- package/models/trace/helpers/Timing.js +3 -0
- package/models/trace/helpers/Timing.js.map +1 -1
- package/models/trace/helpers/Trace.d.ts +2 -0
- package/models/trace/helpers/Trace.js +3 -3
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/helpers/helpers-tsconfig.json +1 -0
- package/models/trace/helpers/helpers.d.ts +1 -0
- package/models/trace/helpers/helpers.js +1 -0
- package/models/trace/helpers/helpers.js.map +1 -1
- package/models/trace/insights/LargestContentfulPaint.d.ts +2 -8
- package/models/trace/insights/LargestContentfulPaint.js +9 -5
- package/models/trace/insights/LargestContentfulPaint.js.map +1 -1
- package/models/trace/insights/RenderBlocking.d.ts +4 -2
- package/models/trace/insights/RenderBlocking.js +76 -1
- package/models/trace/insights/RenderBlocking.js.map +1 -1
- package/models/trace/insights/insights-tsconfig.json +3 -0
- package/models/trace/insights/types.d.ts +27 -19
- package/models/trace/insights/types.js.map +1 -1
- package/models/trace/lantern/core/NetworkAnalyzer.js +2 -1
- package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -1
- package/models/trace/lantern/graph/BaseNode.d.ts +5 -1
- package/models/trace/lantern/graph/BaseNode.js +11 -6
- package/models/trace/lantern/graph/BaseNode.js.map +1 -1
- package/models/trace/lantern/graph/PageDependencyGraph.js +8 -8
- package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
- package/models/trace/lantern/metrics/Interactive.d.ts +1 -1
- package/models/trace/lantern/metrics/Interactive.js +5 -4
- package/models/trace/lantern/metrics/Interactive.js.map +1 -1
- package/models/trace/lantern/metrics/LargestContentfulPaint.d.ts +1 -1
- package/models/trace/lantern/metrics/LargestContentfulPaint.js +3 -3
- package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -1
- package/models/trace/lantern/metrics/MaxPotentialFID.d.ts +1 -1
- package/models/trace/lantern/metrics/MaxPotentialFID.js +3 -2
- package/models/trace/lantern/metrics/MaxPotentialFID.js.map +1 -1
- package/models/trace/lantern/metrics/Metric.d.ts +1 -1
- package/models/trace/lantern/metrics/Metric.js +5 -4
- package/models/trace/lantern/metrics/Metric.js.map +1 -1
- package/models/trace/lantern/metrics/SpeedIndex.d.ts +1 -1
- package/models/trace/lantern/metrics/SpeedIndex.js +6 -5
- package/models/trace/lantern/metrics/SpeedIndex.js.map +1 -1
- package/models/trace/lantern/metrics/TotalBlockingTime.d.ts +1 -1
- package/models/trace/lantern/metrics/TotalBlockingTime.js +6 -5
- package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -1
- package/models/trace/lantern/simulation/ConnectionPool.js +3 -3
- package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -1
- package/models/trace/lantern/simulation/SimulationTimingMap.d.ts +0 -7
- package/models/trace/lantern/simulation/SimulationTimingMap.js +15 -14
- package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -1
- package/models/trace/lantern/simulation/Simulator.js +10 -9
- package/models/trace/lantern/simulation/Simulator.js.map +1 -1
- package/models/trace/lantern/simulation/simulation-tsconfig.json +3 -0
- package/models/trace/lantern/types/Lantern.d.ts +1 -1
- package/models/trace/lantern/types/Lantern.js.map +1 -1
- package/models/trace/types/Extensions.d.ts +29 -34
- package/models/trace/types/Extensions.js +7 -3
- package/models/trace/types/Extensions.js.map +1 -1
- package/models/trace/types/File.d.ts +16 -0
- package/models/trace/types/File.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +31 -13
- package/models/trace/types/TraceEvents.js +14 -3
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/package.json +1 -1
- package/models/trace/lantern/BaseNode.d.ts +0 -91
- package/models/trace/lantern/BaseNode.js +0 -268
- package/models/trace/lantern/BaseNode.js.map +0 -1
- package/models/trace/lantern/CPUNode.d.ts +0 -24
- package/models/trace/lantern/CPUNode.js +0 -64
- package/models/trace/lantern/CPUNode.js.map +0 -1
- package/models/trace/lantern/LanternError.d.ts +0 -3
- package/models/trace/lantern/LanternError.js +0 -7
- package/models/trace/lantern/LanternError.js.map +0 -1
- package/models/trace/lantern/MetricsModule.d.ts +0 -11
- package/models/trace/lantern/MetricsModule.js +0 -14
- package/models/trace/lantern/MetricsModule.js.map +0 -1
- package/models/trace/lantern/NetworkNode.d.ts +0 -22
- package/models/trace/lantern/NetworkNode.js +0 -83
- package/models/trace/lantern/NetworkNode.js.map +0 -1
- package/models/trace/lantern/PageDependencyGraph.d.ts +0 -43
- package/models/trace/lantern/PageDependencyGraph.js +0 -509
- package/models/trace/lantern/PageDependencyGraph.js.map +0 -1
- package/models/trace/lantern/SimulationModule.d.ts +0 -17
- package/models/trace/lantern/SimulationModule.js +0 -13
- package/models/trace/lantern/SimulationModule.js.map +0 -1
- package/models/trace/lantern/simulation/NetworkAnalyzer.d.ts +0 -112
- package/models/trace/lantern/simulation/NetworkAnalyzer.js +0 -486
- package/models/trace/lantern/simulation/NetworkAnalyzer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
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,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AA8CzD,4EAA4E;AAC5E,YAAY;AACZ,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AAE/G,8EAA8E;AAC9E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,oBAAo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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: readonly 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 // TODO(crbug/41484172): should be readonly\n prePaintEvents: Types.TraceEvents.TraceEventPrePaint[];\n layoutInvalidationEvents: readonly Types.TraceEvents.TraceEventLayoutInvalidationTracking[];\n scheduleStyleInvalidationEvents: readonly Types.TraceEvents.TraceEventScheduleStyleInvalidationTracking[];\n styleRecalcInvalidationEvents: readonly Types.TraceEvents.TraceEventStyleRecalcInvalidationTracking[];\n renderFrameImplCreateChildFrameEvents: readonly Types.TraceEvents.TraceEventRenderFrameImplCreateChildFrame[];\n scoreRecords: readonly ScoreRecord[];\n // TODO(crbug/41484172): should be readonly\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[] = [];\nconst renderFrameImplCreateChildFrameEvents: Types.TraceEvents.TraceEventRenderFrameImplCreateChildFrame[] = [];\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 renderFrameImplCreateChildFrameEvents.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 if (Types.TraceEvents.isTraceEventRenderFrameImplCreateChildFrame(event)) {\n renderFrameImplCreateChildFrameEvents.push(event);\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 renderFrameImplCreateChildFrameEvents.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 = Helpers.SyntheticEvents.SyntheticEventsManager\n .registerSyntheticBasedEvent<Types.TraceEvents.SyntheticLayoutShift>({\n rawSourceEvent: event,\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,\n sessionMaxScore: sessionMaxScore,\n clsWindowID,\n prePaintEvents,\n layoutInvalidationEvents,\n scheduleStyleInvalidationEvents,\n styleRecalcInvalidationEvents: [],\n renderFrameImplCreateChildFrameEvents,\n scoreRecords,\n // TODO(crbug/41484172): change the type so no need to clone\n backendNodeIds: [...backendNodeIds],\n };\n}\n\nexport function deps(): TraceEventHandlerName[] {\n return ['Screenshots', 'Meta'];\n}\n\nexport function scoreClassificationForLayoutShift(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"]}
|
|
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,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AA8CzD,4EAA4E;AAC5E,YAAY;AACZ,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AAE/G,8EAA8E;AAC9E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAA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C;IAED,IAAI,KAAK,wCAA6B,EAAE,CAAC;QACvC,KAAK,sCAA0B,CAAC;IAClC,CAAC;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: readonly 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 // TODO(crbug/41484172): should be readonly\n prePaintEvents: Types.TraceEvents.TraceEventPrePaint[];\n layoutInvalidationEvents: readonly Types.TraceEvents.TraceEventLayoutInvalidationTracking[];\n scheduleStyleInvalidationEvents: readonly Types.TraceEvents.TraceEventScheduleStyleInvalidationTracking[];\n styleRecalcInvalidationEvents: readonly Types.TraceEvents.TraceEventStyleRecalcInvalidationTracking[];\n renderFrameImplCreateChildFrameEvents: readonly Types.TraceEvents.TraceEventRenderFrameImplCreateChildFrame[];\n scoreRecords: readonly ScoreRecord[];\n // TODO(crbug/41484172): should be readonly\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[] = [];\nconst renderFrameImplCreateChildFrameEvents: Types.TraceEvents.TraceEventRenderFrameImplCreateChildFrame[] = [];\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 renderFrameImplCreateChildFrameEvents.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 if (Types.TraceEvents.isTraceEventRenderFrameImplCreateChildFrame(event)) {\n renderFrameImplCreateChildFrameEvents.push(event);\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 renderFrameImplCreateChildFrameEvents.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 // If this cluster happened after a navigation, set the navigationId to\n // the current navigation. This lets us easily group clusters by\n // navigation.\n const navigationId =\n currentShiftNavigation === null ? undefined : navigations[currentShiftNavigation].args.data?.navigationId;\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 navigationId,\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 = Helpers.SyntheticEvents.SyntheticEventsManager\n .registerSyntheticBasedEvent<Types.TraceEvents.SyntheticLayoutShift>({\n rawSourceEvent: event,\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,\n sessionMaxScore: sessionMaxScore,\n clsWindowID,\n prePaintEvents,\n layoutInvalidationEvents,\n scheduleStyleInvalidationEvents,\n styleRecalcInvalidationEvents: [],\n renderFrameImplCreateChildFrameEvents,\n scoreRecords,\n // TODO(crbug/41484172): change the type so no need to clone\n backendNodeIds: [...backendNodeIds],\n };\n}\n\nexport function deps(): TraceEventHandlerName[] {\n return ['Screenshots', 'Meta'];\n}\n\nexport function scoreClassificationForLayoutShift(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 // The last navigation that happened before this cluster.\n navigationId?: string;\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"]}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import * as Types from '../types/types.js';
|
|
2
2
|
import { type TraceEventHandlerName } from './types.js';
|
|
3
|
+
export interface WebSocketTraceDataForFrame {
|
|
4
|
+
frame: string;
|
|
5
|
+
webSocketIdentifier: number;
|
|
6
|
+
events: Types.TraceEvents.WebSocketEvent[];
|
|
7
|
+
syntheticConnectionEvent: Types.TraceEvents.SyntheticWebSocketConnectionEvent | null;
|
|
8
|
+
}
|
|
9
|
+
export interface WebSocketTraceDataForWorker {
|
|
10
|
+
workerId: string;
|
|
11
|
+
webSocketIdentifier: number;
|
|
12
|
+
events: Types.TraceEvents.WebSocketEvent[];
|
|
13
|
+
syntheticConnectionEvent: Types.TraceEvents.SyntheticWebSocketConnectionEvent | null;
|
|
14
|
+
}
|
|
15
|
+
export type WebSocketTraceData = WebSocketTraceDataForFrame | WebSocketTraceDataForWorker;
|
|
3
16
|
interface NetworkRequestData {
|
|
4
17
|
byOrigin: Map<string, {
|
|
5
18
|
renderBlocking: Types.TraceEvents.SyntheticNetworkRequest[];
|
|
@@ -7,6 +20,8 @@ interface NetworkRequestData {
|
|
|
7
20
|
all: Types.TraceEvents.SyntheticNetworkRequest[];
|
|
8
21
|
}>;
|
|
9
22
|
byTime: Types.TraceEvents.SyntheticNetworkRequest[];
|
|
23
|
+
eventToInitiator: Map<Types.TraceEvents.SyntheticNetworkRequest, Types.TraceEvents.SyntheticNetworkRequest>;
|
|
24
|
+
webSocket: WebSocketTraceData[];
|
|
10
25
|
}
|
|
11
26
|
export declare function reset(): void;
|
|
12
27
|
export declare function initialize(): void;
|
|
@@ -7,9 +7,12 @@ import * as Types from '../types/types.js';
|
|
|
7
7
|
import { data as metaHandlerData } from './MetaHandler.js';
|
|
8
8
|
const MILLISECONDS_TO_MICROSECONDS = 1000;
|
|
9
9
|
const SECONDS_TO_MICROSECONDS = 1000000;
|
|
10
|
+
const webSocketData = new Map();
|
|
10
11
|
const requestMap = new Map();
|
|
11
12
|
const requestsByOrigin = new Map();
|
|
12
13
|
const requestsByTime = [];
|
|
14
|
+
const networkRequestEventByInitiatorUrl = new Map();
|
|
15
|
+
const eventToInitiatorMap = new Map();
|
|
13
16
|
function storeTraceEventWithRequestId(requestId, key, value) {
|
|
14
17
|
if (!requestMap.has(requestId)) {
|
|
15
18
|
requestMap.set(requestId, {});
|
|
@@ -43,6 +46,9 @@ export function reset() {
|
|
|
43
46
|
requestsByOrigin.clear();
|
|
44
47
|
requestMap.clear();
|
|
45
48
|
requestsByTime.length = 0;
|
|
49
|
+
networkRequestEventByInitiatorUrl.clear();
|
|
50
|
+
eventToInitiatorMap.clear();
|
|
51
|
+
webSocketData.clear();
|
|
46
52
|
handlerState = 1 /* HandlerState.UNINITIALIZED */;
|
|
47
53
|
}
|
|
48
54
|
export function initialize() {
|
|
@@ -80,6 +86,29 @@ export function handleEvent(event) {
|
|
|
80
86
|
storeTraceEventWithRequestId(event.args.data.requestId, 'resourceMarkAsCached', event);
|
|
81
87
|
return;
|
|
82
88
|
}
|
|
89
|
+
if (Types.TraceEvents.isTraceEventWebSocketCreate(event) || Types.TraceEvents.isTraceEventWebSocketInfo(event) ||
|
|
90
|
+
Types.TraceEvents.isTraceEventWebSocketTransfer(event)) {
|
|
91
|
+
const identifier = event.args.data.identifier;
|
|
92
|
+
if (!webSocketData.has(identifier)) {
|
|
93
|
+
if (event.args.data.frame) {
|
|
94
|
+
webSocketData.set(identifier, {
|
|
95
|
+
frame: event.args.data.frame,
|
|
96
|
+
webSocketIdentifier: identifier,
|
|
97
|
+
events: [],
|
|
98
|
+
syntheticConnectionEvent: null,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else if (event.args.data.workerId) {
|
|
102
|
+
webSocketData.set(identifier, {
|
|
103
|
+
workerId: event.args.data.workerId,
|
|
104
|
+
webSocketIdentifier: identifier,
|
|
105
|
+
events: [],
|
|
106
|
+
syntheticConnectionEvent: null,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
webSocketData.get(identifier)?.events.push(event);
|
|
111
|
+
}
|
|
83
112
|
}
|
|
84
113
|
export async function finalize() {
|
|
85
114
|
if (handlerState !== 2 /* HandlerState.INITIALIZED */) {
|
|
@@ -304,7 +333,7 @@ export async function finalize() {
|
|
|
304
333
|
protocol: request.receiveResponse.args.data.protocol ?? 'unknown',
|
|
305
334
|
redirects,
|
|
306
335
|
// In the event the property isn't set, assume non-blocking.
|
|
307
|
-
renderBlocking: renderBlocking
|
|
336
|
+
renderBlocking: renderBlocking ?? 'non_blocking',
|
|
308
337
|
requestId,
|
|
309
338
|
requestingFrameUrl,
|
|
310
339
|
requestMethod: finalSendRequest.args.data.requestMethod,
|
|
@@ -341,7 +370,7 @@ export async function finalize() {
|
|
|
341
370
|
});
|
|
342
371
|
// For ease of rendering we sometimes want to differentiate between
|
|
343
372
|
// render-blocking and non-render-blocking, so we divide the data here.
|
|
344
|
-
if (
|
|
373
|
+
if (!Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(networkEvent)) {
|
|
345
374
|
requests.nonRenderBlocking.push(networkEvent);
|
|
346
375
|
}
|
|
347
376
|
else {
|
|
@@ -351,7 +380,23 @@ export async function finalize() {
|
|
|
351
380
|
// the captured requests, so here we store all of them together.
|
|
352
381
|
requests.all.push(networkEvent);
|
|
353
382
|
requestsByTime.push(networkEvent);
|
|
383
|
+
const initiatorUrl = networkEvent.args.data.initiator?.url ||
|
|
384
|
+
Helpers.Trace.getZeroIndexedStackTraceForEvent(networkEvent)?.at(0)?.url;
|
|
385
|
+
if (initiatorUrl) {
|
|
386
|
+
const events = networkRequestEventByInitiatorUrl.get(initiatorUrl) ?? [];
|
|
387
|
+
events.push(networkEvent);
|
|
388
|
+
networkRequestEventByInitiatorUrl.set(initiatorUrl, events);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
for (const request of requestsByTime) {
|
|
392
|
+
const initiatedEvents = networkRequestEventByInitiatorUrl.get(request.args.data.url);
|
|
393
|
+
if (initiatedEvents) {
|
|
394
|
+
for (const initiatedEvent of initiatedEvents) {
|
|
395
|
+
eventToInitiatorMap.set(initiatedEvent, request);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
354
398
|
}
|
|
399
|
+
finalizeWebSocketData();
|
|
355
400
|
handlerState = 3 /* HandlerState.FINALIZED */;
|
|
356
401
|
}
|
|
357
402
|
export function data() {
|
|
@@ -361,9 +406,60 @@ export function data() {
|
|
|
361
406
|
return {
|
|
362
407
|
byOrigin: requestsByOrigin,
|
|
363
408
|
byTime: requestsByTime,
|
|
409
|
+
eventToInitiator: eventToInitiatorMap,
|
|
410
|
+
webSocket: [...webSocketData.values()],
|
|
364
411
|
};
|
|
365
412
|
}
|
|
366
413
|
export function deps() {
|
|
367
414
|
return ['Meta'];
|
|
368
415
|
}
|
|
416
|
+
function finalizeWebSocketData() {
|
|
417
|
+
// for each WebSocketTraceData in webSocketData map, we create a synthetic event
|
|
418
|
+
// to represent the entire WebSocket connection. This is done by finding the start and end event
|
|
419
|
+
// if they exist, and if they don't, we use the first event in the list for start, and the traceBounds.max
|
|
420
|
+
// for the end. So each WebSocketTraceData will have
|
|
421
|
+
// {
|
|
422
|
+
// events: the list of WebSocket events
|
|
423
|
+
// syntheticConnectionEvent: the synthetic event representing the entire WebSocket connection
|
|
424
|
+
// }
|
|
425
|
+
webSocketData.forEach(data => {
|
|
426
|
+
let startEvent = null;
|
|
427
|
+
let endEvent = null;
|
|
428
|
+
for (const event of data.events) {
|
|
429
|
+
if (Types.TraceEvents.isTraceEventWebSocketCreate(event)) {
|
|
430
|
+
startEvent = event;
|
|
431
|
+
}
|
|
432
|
+
if (Types.TraceEvents.isTraceEventWebSocketDestroy(event)) {
|
|
433
|
+
endEvent = event;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
data.syntheticConnectionEvent = createSyntheticWebSocketConnectionEvent(startEvent, endEvent, data.events[0]);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
function createSyntheticWebSocketConnectionEvent(startEvent, endEvent, firstRecordedEvent) {
|
|
440
|
+
const { traceBounds } = metaHandlerData();
|
|
441
|
+
const startTs = startEvent ? startEvent.ts : traceBounds.min;
|
|
442
|
+
const endTs = endEvent ? endEvent.ts : traceBounds.max;
|
|
443
|
+
const duration = endTs - startTs;
|
|
444
|
+
const mainEvent = startEvent || endEvent || firstRecordedEvent;
|
|
445
|
+
return {
|
|
446
|
+
name: 'SyntheticWebSocketConnectionEvent',
|
|
447
|
+
cat: mainEvent.cat,
|
|
448
|
+
ph: "X" /* Types.TraceEvents.Phase.COMPLETE */,
|
|
449
|
+
ts: startTs,
|
|
450
|
+
dur: duration,
|
|
451
|
+
pid: mainEvent.pid,
|
|
452
|
+
tid: mainEvent.tid,
|
|
453
|
+
s: mainEvent.s,
|
|
454
|
+
rawSourceEvent: mainEvent,
|
|
455
|
+
_tag: 'SyntheticEntryTag',
|
|
456
|
+
args: {
|
|
457
|
+
data: {
|
|
458
|
+
identifier: mainEvent.args.data.identifier,
|
|
459
|
+
priority: "Low" /* Protocol.Network.ResourcePriority.Low */,
|
|
460
|
+
url: mainEvent.args.data.url || '',
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
}
|
|
369
465
|
//# sourceMappingURL=NetworkRequestsHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkRequestsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/NetworkRequestsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAGzD,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAC1C,MAAM,uBAAuB,GAAG,OAAO,CAAC;AA6BxC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAwC,CAAC;AACnE,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAI5B,CAAC;AACL,MAAM,cAAc,GAAgD,EAAE,CAAC;AAEvE,SAAS,4BAA4B,CACjC,SAAiB,EAAE,GAAM,EAAE,KAAsC;IACnE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE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AE5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,gBAAgB,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE;YAC3F,OAAO;gBACL,cAAc,EAAE,EAAE;gBAClB,iBAAiB,EAAE,EAAE;gBACrB,GAAG,EAAE,EAAE;aACR,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,mEAAmE;QACnE,uEAAuE;QACvE,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,KAAK,cAAc,EAAE,CAAC;YAC7D,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAChD,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7C,CAAC;QAED,uEAAuE;QACvE,gEAAgE;QAChE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAChC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAED,YAAY,iCAAyB,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,IAAI,YAAY,mCAA2B,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,gBAAgB;QAC1B,MAAM,EAAE,cAAc;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {data as metaHandlerData} from './MetaHandler.js';\nimport {HandlerState, type TraceEventHandlerName} from './types.js';\n\nconst MILLISECONDS_TO_MICROSECONDS = 1000;\nconst SECONDS_TO_MICROSECONDS = 1000000;\n\n// Network requests from traces are actually formed of 5 trace records.\n// This handler tracks all trace records based on the request ID, and\n// then creates a new synthetic trace event for those network requests.\n//\n// This interface, then, defines the shape of the object we intend to\n// keep for each request in the trace. In the finalize we will convert\n// these 5 types of trace records to a synthetic complete event that\n// represents a composite of these trace records.\ninterface TraceEventsForNetworkRequest {\n changePriority?: Types.TraceEvents.TraceEventResourceChangePriority;\n willSendRequests?: Types.TraceEvents.TraceEventResourceWillSendRequest[];\n sendRequests?: Types.TraceEvents.TraceEventResourceSendRequest[];\n receiveResponse?: Types.TraceEvents.TraceEventResourceReceiveResponse;\n resourceFinish?: Types.TraceEvents.TraceEventResourceFinish;\n receivedData?: Types.TraceEvents.TraceEventResourceReceivedData[];\n resourceMarkAsCached?: Types.TraceEvents.TraceEventResourceMarkAsCached;\n}\n\ninterface NetworkRequestData {\n byOrigin: Map<string, {\n renderBlocking: Types.TraceEvents.SyntheticNetworkRequest[],\n nonRenderBlocking: Types.TraceEvents.SyntheticNetworkRequest[],\n all: Types.TraceEvents.SyntheticNetworkRequest[],\n }>;\n byTime: Types.TraceEvents.SyntheticNetworkRequest[];\n}\n\nconst requestMap = new Map<string, TraceEventsForNetworkRequest>();\nconst requestsByOrigin = new Map<string, {\n renderBlocking: Types.TraceEvents.SyntheticNetworkRequest[],\n nonRenderBlocking: Types.TraceEvents.SyntheticNetworkRequest[],\n all: Types.TraceEvents.SyntheticNetworkRequest[],\n}>();\nconst requestsByTime: Types.TraceEvents.SyntheticNetworkRequest[] = [];\n\nfunction storeTraceEventWithRequestId<K extends keyof TraceEventsForNetworkRequest>(\n requestId: string, key: K, value: TraceEventsForNetworkRequest[K]): void {\n if (!requestMap.has(requestId)) {\n requestMap.set(requestId, {});\n }\n\n const traceEvents = requestMap.get(requestId);\n if (!traceEvents) {\n throw new Error(`Unable to locate trace events for request ID ${requestId}`);\n }\n\n if (Array.isArray(traceEvents[key])) {\n const target = traceEvents[key] as Types.TraceEvents.TraceEventData[];\n const values = value as Types.TraceEvents.TraceEventData[];\n target.push(...values);\n } else {\n traceEvents[key] = value;\n }\n}\n\nfunction firstPositiveValueInList(entries: number[]): number {\n for (const entry of entries) {\n if (entry > 0) {\n return entry;\n }\n }\n\n // In the event we don't find a positive value, we return 0 so as to\n // be a mathematical noop. It's typically not correct to return – say –\n // a -1 here because it would affect the calculation of stats below.\n return 0;\n}\n\nlet handlerState = HandlerState.UNINITIALIZED;\n\nexport function reset(): void {\n requestsByOrigin.clear();\n requestMap.clear();\n requestsByTime.length = 0;\n\n handlerState = HandlerState.UNINITIALIZED;\n}\n\nexport function initialize(): void {\n handlerState = HandlerState.INITIALIZED;\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Network Request handler is not initialized');\n }\n\n if (Types.TraceEvents.isTraceEventResourceChangePriority(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'changePriority', event);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceWillSendRequest(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'willSendRequests', [event]);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceSendRequest(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'sendRequests', [event]);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceReceiveResponse(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'receiveResponse', event);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceReceivedData(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'receivedData', [event]);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceFinish(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'resourceFinish', event);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceMarkAsCached(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'resourceMarkAsCached', event);\n return;\n }\n}\n\nexport async function finalize(): Promise<void> {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Network Request handler is not initialized');\n }\n\n const {rendererProcessesByFrame} = metaHandlerData();\n for (const [requestId, request] of requestMap.entries()) {\n // If we have an incomplete set of events here, we choose to drop the network\n // request rather than attempt to synthesize the missing data.\n if (!request.sendRequests || !request.receiveResponse) {\n continue;\n }\n\n // In the data we may get multiple willSendRequests and sendRequests, which\n // will indicate that there are redirects for a given (sub)resource. In the\n // case of a navigation, e.g., example.com/ we will get willSendRequests,\n // and we should use these to calculate time spent in redirects.\n // In the case of sub-resources, however, e.g., example.com/foo.js we will\n // *only* get sendRequests, and we use these instead of willSendRequests\n // to detect the time in redirects. We always use the sendRequest for the\n // url, priority etc since it contains those values, but we use the\n // willSendRequest (if it exists) to calculate the timestamp and durations\n // of redirects.\n const redirects: Types.TraceEvents.SyntheticNetworkRedirect[] = [];\n for (let i = 0; i < request.sendRequests.length - 1; i++) {\n const sendRequest = request.sendRequests[i];\n const nextSendRequest = request.sendRequests[i + 1];\n\n // Use the willSendRequests as the source for redirects if possible.\n // We default to those of the sendRequests, however, since willSendRequest\n // is not guaranteed to be present in the data for every request.\n let ts = sendRequest.ts;\n let dur = Types.Timing.MicroSeconds(nextSendRequest.ts - sendRequest.ts);\n if (request.willSendRequests && request.willSendRequests[i] && request.willSendRequests[i + 1]) {\n const willSendRequest = request.willSendRequests[i];\n const nextWillSendRequest = request.willSendRequests[i + 1];\n ts = willSendRequest.ts;\n dur = Types.Timing.MicroSeconds(nextWillSendRequest.ts - willSendRequest.ts);\n }\n\n redirects.push({\n url: sendRequest.args.data.url,\n priority: sendRequest.args.data.priority,\n requestMethod: sendRequest.args.data.requestMethod,\n ts,\n dur,\n });\n }\n\n // If a ResourceFinish event with an encoded data length is received,\n // then the resource was not cached; it was fetched before it was\n // requested, e.g. because it was pushed in this navigation.\n const isPushedResource = request.resourceFinish?.args.data.encodedDataLength !== 0;\n // This works around crbug.com/998397, which reports pushed resources, and resources served by a service worker as disk cached.\n const isDiskCached = request.receiveResponse.args.data.fromCache &&\n !request.receiveResponse.args.data.fromServiceWorker && !isPushedResource;\n // If the request contains a resourceMarkAsCached event, it was served from memory cache.\n const isMemoryCached = request.resourceMarkAsCached !== undefined;\n\n // The timing data returned is from the original (uncached) request, which\n // means that if we leave the above network record data as-is when the\n // request came from either the disk cache or memory cache, our calculations\n // will be incorrect.\n //\n // Here we add a flag so when we calculate the timestamps of the various\n // events, we can overwrite them.\n // These timestamps may not be perfect (indeed they don't always match\n // the Network CDP domain exactly, which is likely an artifact of the way\n // the data is routed on the backend), but they're the closest we have.\n const isCached = isMemoryCached || isDiskCached;\n\n const timing = request.receiveResponse.args.data.timing;\n // If a non-cached request has no |timing| indicates data URLs, we ignore it.\n if (!timing && !isCached) {\n continue;\n }\n\n const firstSendRequest = request.sendRequests[0];\n const finalSendRequest = request.sendRequests[request.sendRequests.length - 1];\n\n const initialPriority = finalSendRequest.args.data.priority;\n let finalPriority = initialPriority;\n if (request.changePriority) {\n finalPriority = request.changePriority.args.data.priority;\n }\n\n // Start time\n // =======================\n // The time where the request started, which is either the first willSendRequest\n // event if there is one, or, if there is not, the sendRequest.\n const startTime = (request.willSendRequests && request.willSendRequests.length) ?\n Types.Timing.MicroSeconds(request.willSendRequests[0].ts) :\n Types.Timing.MicroSeconds(firstSendRequest.ts);\n\n // End redirect time\n // =======================\n // It's possible that when we start requesting data we will receive redirections.\n // Here we note the time of the *last* willSendRequest / sendRequest event,\n // which is used later on in the calculations for time queueing etc.\n const endRedirectTime = (request.willSendRequests && request.willSendRequests.length) ?\n Types.Timing.MicroSeconds(request.willSendRequests[request.willSendRequests.length - 1].ts) :\n Types.Timing.MicroSeconds(finalSendRequest.ts);\n\n // Finish time and end time\n // =======================\n // The finish time and the end time are subtly different.\n // - Finish time: records the point at which the network stack stopped receiving the data\n // - End time: the timestamp of the finish event itself (if one exists)\n //\n // The end time, then, will be slightly after the finish time.\n const endTime = request.resourceFinish ? request.resourceFinish.ts : endRedirectTime;\n const finishTime = request.resourceFinish?.args.data.finishTime ?\n Types.Timing.MicroSeconds(request.resourceFinish.args.data.finishTime * SECONDS_TO_MICROSECONDS) :\n Types.Timing.MicroSeconds(endTime);\n\n // Network duration\n // =======================\n // Time spent on the network.\n const networkDuration = isCached ? Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((finishTime || endRedirectTime) - endRedirectTime);\n\n // Processing duration\n // =======================\n // Time spent from start to end.\n const processingDuration = Types.Timing.MicroSeconds(endTime - (finishTime || endTime));\n\n // Redirection duration\n // =======================\n // Time between the first willSendRequest / sendRequest and last. This we place in *front* of the\n // queueing, since the queueing time that we know about from the trace data is only the last request,\n // i.e., the one that occurs after all the redirects.\n const redirectionDuration = Types.Timing.MicroSeconds(endRedirectTime - startTime);\n\n // Queueing\n // =======================\n // The amount of time queueing is the time between the request's start time to the requestTime\n // arg recorded in the receiveResponse event. In the cases where the recorded start time is larger\n // that the requestTime we set queueing time to zero.\n const queueing = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds(Platform.NumberUtilities.clamp(\n (timing.requestTime * SECONDS_TO_MICROSECONDS - endRedirectTime), 0, Number.MAX_VALUE));\n\n // Stalled\n // =======================\n // If the request is cached, the amount of time stalled is the time between the start time and\n // receiving a response.\n // Otherwise it is whichever positive number comes first from the following timing info:\n // DNS start, Connection start, Send Start, or the time duration between our start time and\n // receiving a response.\n const stalled = isCached ? Types.Timing.MicroSeconds(request.receiveResponse.ts - startTime) :\n Types.Timing.MicroSeconds(firstPositiveValueInList([\n timing.dnsStart * MILLISECONDS_TO_MICROSECONDS,\n timing.connectStart * MILLISECONDS_TO_MICROSECONDS,\n timing.sendStart * MILLISECONDS_TO_MICROSECONDS,\n (request.receiveResponse.ts - endRedirectTime),\n ]));\n\n // Sending HTTP request\n // =======================\n // Time when the HTTP request is sent.\n const sendStartTime = isCached ?\n startTime :\n Types.Timing.MicroSeconds(\n timing.requestTime * SECONDS_TO_MICROSECONDS + timing.sendStart * MILLISECONDS_TO_MICROSECONDS);\n\n // Waiting\n // =======================\n // Time from when the send finished going to when the headers were received.\n const waiting = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.receiveHeadersEnd - timing.sendEnd) * MILLISECONDS_TO_MICROSECONDS);\n\n // Download\n // =======================\n // Time from receipt of headers to the finish time.\n const downloadStart = isCached ?\n startTime :\n Types.Timing.MicroSeconds(\n timing.requestTime * SECONDS_TO_MICROSECONDS + timing.receiveHeadersEnd * MILLISECONDS_TO_MICROSECONDS);\n const download = isCached ? Types.Timing.MicroSeconds(endTime - request.receiveResponse.ts) :\n Types.Timing.MicroSeconds(((finishTime || downloadStart) - downloadStart));\n\n const totalTime = Types.Timing.MicroSeconds(networkDuration + processingDuration);\n\n // Collect a few values from the timing info.\n // If the Network request is cached, we zero out them.\n const dnsLookup = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.dnsEnd - timing.dnsStart) * MILLISECONDS_TO_MICROSECONDS);\n const ssl = isCached ? Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.sslEnd - timing.sslStart) * MILLISECONDS_TO_MICROSECONDS);\n const proxyNegotiation = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.proxyEnd - timing.proxyStart) * MILLISECONDS_TO_MICROSECONDS);\n const requestSent = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.sendEnd - timing.sendStart) * MILLISECONDS_TO_MICROSECONDS);\n const initialConnection = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.connectEnd - timing.connectStart) * MILLISECONDS_TO_MICROSECONDS);\n\n // Finally get some of the general data from the trace events.\n const {frame, url, renderBlocking} = finalSendRequest.args.data;\n const {encodedDataLength, decodedBodyLength} =\n request.resourceFinish ? request.resourceFinish.args.data : {encodedDataLength: 0, decodedBodyLength: 0};\n const parsedUrl = new URL(url);\n const isHttps = parsedUrl.protocol === 'https:';\n const requestingFrameUrl =\n Helpers.Trace.activeURLForFrameAtTime(frame, finalSendRequest.ts, rendererProcessesByFrame) || '';\n // Construct a synthetic trace event for this network request.\n const networkEvent = Helpers.SyntheticEvents.SyntheticEventsManager\n .registerSyntheticBasedEvent<Types.TraceEvents.SyntheticNetworkRequest>({\n rawSourceEvent: finalSendRequest,\n args: {\n data: {\n // All data we create from trace events should be added to |syntheticData|.\n syntheticData: {\n dnsLookup,\n download,\n downloadStart,\n finishTime,\n initialConnection,\n isDiskCached,\n isHttps,\n isMemoryCached,\n isPushedResource,\n networkDuration,\n processingDuration,\n proxyNegotiation,\n queueing,\n redirectionDuration,\n requestSent,\n sendStartTime,\n ssl,\n stalled,\n totalTime,\n waiting,\n },\n // All fields below are from TraceEventsForNetworkRequest.\n decodedBodyLength,\n encodedDataLength,\n frame,\n fromServiceWorker: request.receiveResponse.args.data.fromServiceWorker,\n isLinkPreload: finalSendRequest.args.data.isLinkPreload || false,\n mimeType: request.receiveResponse.args.data.mimeType,\n priority: finalPriority,\n initialPriority,\n protocol: request.receiveResponse.args.data.protocol ?? 'unknown',\n redirects,\n // In the event the property isn't set, assume non-blocking.\n renderBlocking: renderBlocking ? renderBlocking : 'non_blocking',\n requestId,\n requestingFrameUrl,\n requestMethod: finalSendRequest.args.data.requestMethod,\n resourceType: finalSendRequest.args.data.resourceType,\n statusCode: request.receiveResponse.args.data.statusCode,\n responseHeaders: request.receiveResponse.args.data.headers || [],\n fetchPriorityHint: finalSendRequest.args.data.fetchPriorityHint,\n initiator: finalSendRequest.args.data.initiator,\n stackTrace: finalSendRequest.args.data.stackTrace,\n timing,\n url,\n failed: request.resourceFinish?.args.data.didFail ?? false,\n finished: Boolean(request.resourceFinish),\n connectionId: request.receiveResponse.args.data.connectionId,\n connectionReused: request.receiveResponse.args.data.connectionReused,\n },\n },\n cat: 'loading',\n name: 'SyntheticNetworkRequest',\n ph: Types.TraceEvents.Phase.COMPLETE,\n dur: Types.Timing.MicroSeconds(endTime - startTime),\n tdur: Types.Timing.MicroSeconds(endTime - startTime),\n ts: Types.Timing.MicroSeconds(startTime),\n tts: Types.Timing.MicroSeconds(startTime),\n pid: finalSendRequest.pid,\n tid: finalSendRequest.tid,\n });\n\n const requests = Platform.MapUtilities.getWithDefault(requestsByOrigin, parsedUrl.host, () => {\n return {\n renderBlocking: [],\n nonRenderBlocking: [],\n all: [],\n };\n });\n\n // For ease of rendering we sometimes want to differentiate between\n // render-blocking and non-render-blocking, so we divide the data here.\n if (networkEvent.args.data.renderBlocking === 'non_blocking') {\n requests.nonRenderBlocking.push(networkEvent);\n } else {\n requests.renderBlocking.push(networkEvent);\n }\n\n // However, there are also times where we just want to loop through all\n // the captured requests, so here we store all of them together.\n requests.all.push(networkEvent);\n requestsByTime.push(networkEvent);\n }\n\n handlerState = HandlerState.FINALIZED;\n}\n\nexport function data(): NetworkRequestData {\n if (handlerState !== HandlerState.FINALIZED) {\n throw new Error('Network Request handler is not finalized');\n }\n\n return {\n byOrigin: requestsByOrigin,\n byTime: requestsByTime,\n };\n}\n\nexport function deps(): TraceEventHandlerName[] {\n return ['Meta'];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NetworkRequestsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/NetworkRequestsHandler.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAGzD,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAC1C,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAkCxC,MAAM,aAAa,GAAoC,IAAI,GAAG,EAAE,CAAC;AAYjE,MAA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AQ,mDAAuC;gBAC/C,GAAG,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE;aACnC;SACF;KACF,CAAC;AACJ,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 * 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 {HandlerState, type TraceEventHandlerName} from './types.js';\n\nconst MILLISECONDS_TO_MICROSECONDS = 1000;\nconst SECONDS_TO_MICROSECONDS = 1000000;\n\n// Network requests from traces are actually formed of 5 trace records.\n// This handler tracks all trace records based on the request ID, and\n// then creates a new synthetic trace event for those network requests.\n//\n// This interface, then, defines the shape of the object we intend to\n// keep for each request in the trace. In the finalize we will convert\n// these 5 types of trace records to a synthetic complete event that\n// represents a composite of these trace records.\ninterface TraceEventsForNetworkRequest {\n changePriority?: Types.TraceEvents.TraceEventResourceChangePriority;\n willSendRequests?: Types.TraceEvents.TraceEventResourceWillSendRequest[];\n sendRequests?: Types.TraceEvents.TraceEventResourceSendRequest[];\n receiveResponse?: Types.TraceEvents.TraceEventResourceReceiveResponse;\n resourceFinish?: Types.TraceEvents.TraceEventResourceFinish;\n receivedData?: Types.TraceEvents.TraceEventResourceReceivedData[];\n resourceMarkAsCached?: Types.TraceEvents.TraceEventResourceMarkAsCached;\n}\n\nexport interface WebSocketTraceDataForFrame {\n frame: string;\n webSocketIdentifier: number;\n events: Types.TraceEvents.WebSocketEvent[];\n syntheticConnectionEvent: Types.TraceEvents.SyntheticWebSocketConnectionEvent|null;\n}\nexport interface WebSocketTraceDataForWorker {\n workerId: string;\n webSocketIdentifier: number;\n events: Types.TraceEvents.WebSocketEvent[];\n syntheticConnectionEvent: Types.TraceEvents.SyntheticWebSocketConnectionEvent|null;\n}\nexport type WebSocketTraceData = WebSocketTraceDataForFrame|WebSocketTraceDataForWorker;\n\nconst webSocketData: Map<number, WebSocketTraceData> = new Map();\ninterface NetworkRequestData {\n byOrigin: Map<string, {\n renderBlocking: Types.TraceEvents.SyntheticNetworkRequest[],\n nonRenderBlocking: Types.TraceEvents.SyntheticNetworkRequest[],\n all: Types.TraceEvents.SyntheticNetworkRequest[],\n }>;\n byTime: Types.TraceEvents.SyntheticNetworkRequest[];\n eventToInitiator: Map<Types.TraceEvents.SyntheticNetworkRequest, Types.TraceEvents.SyntheticNetworkRequest>;\n webSocket: WebSocketTraceData[];\n}\n\nconst requestMap = new Map<string, TraceEventsForNetworkRequest>();\nconst requestsByOrigin = new Map<string, {\n renderBlocking: Types.TraceEvents.SyntheticNetworkRequest[],\n nonRenderBlocking: Types.TraceEvents.SyntheticNetworkRequest[],\n all: Types.TraceEvents.SyntheticNetworkRequest[],\n}>();\nconst requestsByTime: Types.TraceEvents.SyntheticNetworkRequest[] = [];\n\nconst networkRequestEventByInitiatorUrl = new Map<string, Types.TraceEvents.SyntheticNetworkRequest[]>();\nconst eventToInitiatorMap =\n new Map<Types.TraceEvents.SyntheticNetworkRequest, Types.TraceEvents.SyntheticNetworkRequest>();\n\nfunction storeTraceEventWithRequestId<K extends keyof TraceEventsForNetworkRequest>(\n requestId: string, key: K, value: TraceEventsForNetworkRequest[K]): void {\n if (!requestMap.has(requestId)) {\n requestMap.set(requestId, {});\n }\n\n const traceEvents = requestMap.get(requestId);\n if (!traceEvents) {\n throw new Error(`Unable to locate trace events for request ID ${requestId}`);\n }\n\n if (Array.isArray(traceEvents[key])) {\n const target = traceEvents[key] as Types.TraceEvents.TraceEventData[];\n const values = value as Types.TraceEvents.TraceEventData[];\n target.push(...values);\n } else {\n traceEvents[key] = value;\n }\n}\n\nfunction firstPositiveValueInList(entries: number[]): number {\n for (const entry of entries) {\n if (entry > 0) {\n return entry;\n }\n }\n\n // In the event we don't find a positive value, we return 0 so as to\n // be a mathematical noop. It's typically not correct to return – say –\n // a -1 here because it would affect the calculation of stats below.\n return 0;\n}\n\nlet handlerState = HandlerState.UNINITIALIZED;\n\nexport function reset(): void {\n requestsByOrigin.clear();\n requestMap.clear();\n requestsByTime.length = 0;\n networkRequestEventByInitiatorUrl.clear();\n eventToInitiatorMap.clear();\n webSocketData.clear();\n\n handlerState = HandlerState.UNINITIALIZED;\n}\n\nexport function initialize(): void {\n handlerState = HandlerState.INITIALIZED;\n}\n\nexport function handleEvent(event: Types.TraceEvents.TraceEventData): void {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Network Request handler is not initialized');\n }\n\n if (Types.TraceEvents.isTraceEventResourceChangePriority(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'changePriority', event);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceWillSendRequest(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'willSendRequests', [event]);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceSendRequest(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'sendRequests', [event]);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceReceiveResponse(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'receiveResponse', event);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceReceivedData(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'receivedData', [event]);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceFinish(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'resourceFinish', event);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventResourceMarkAsCached(event)) {\n storeTraceEventWithRequestId(event.args.data.requestId, 'resourceMarkAsCached', event);\n return;\n }\n\n if (Types.TraceEvents.isTraceEventWebSocketCreate(event) || Types.TraceEvents.isTraceEventWebSocketInfo(event) ||\n Types.TraceEvents.isTraceEventWebSocketTransfer(event)) {\n const identifier = event.args.data.identifier;\n if (!webSocketData.has(identifier)) {\n if (event.args.data.frame) {\n webSocketData.set(identifier, {\n frame: event.args.data.frame,\n webSocketIdentifier: identifier,\n events: [],\n syntheticConnectionEvent: null,\n });\n } else if (event.args.data.workerId) {\n webSocketData.set(identifier, {\n workerId: event.args.data.workerId,\n webSocketIdentifier: identifier,\n events: [],\n syntheticConnectionEvent: null,\n });\n }\n }\n\n webSocketData.get(identifier)?.events.push(event);\n }\n}\n\nexport async function finalize(): Promise<void> {\n if (handlerState !== HandlerState.INITIALIZED) {\n throw new Error('Network Request handler is not initialized');\n }\n\n const {rendererProcessesByFrame} = metaHandlerData();\n for (const [requestId, request] of requestMap.entries()) {\n // If we have an incomplete set of events here, we choose to drop the network\n // request rather than attempt to synthesize the missing data.\n if (!request.sendRequests || !request.receiveResponse) {\n continue;\n }\n\n // In the data we may get multiple willSendRequests and sendRequests, which\n // will indicate that there are redirects for a given (sub)resource. In the\n // case of a navigation, e.g., example.com/ we will get willSendRequests,\n // and we should use these to calculate time spent in redirects.\n // In the case of sub-resources, however, e.g., example.com/foo.js we will\n // *only* get sendRequests, and we use these instead of willSendRequests\n // to detect the time in redirects. We always use the sendRequest for the\n // url, priority etc since it contains those values, but we use the\n // willSendRequest (if it exists) to calculate the timestamp and durations\n // of redirects.\n const redirects: Types.TraceEvents.SyntheticNetworkRedirect[] = [];\n for (let i = 0; i < request.sendRequests.length - 1; i++) {\n const sendRequest = request.sendRequests[i];\n const nextSendRequest = request.sendRequests[i + 1];\n\n // Use the willSendRequests as the source for redirects if possible.\n // We default to those of the sendRequests, however, since willSendRequest\n // is not guaranteed to be present in the data for every request.\n let ts = sendRequest.ts;\n let dur = Types.Timing.MicroSeconds(nextSendRequest.ts - sendRequest.ts);\n if (request.willSendRequests && request.willSendRequests[i] && request.willSendRequests[i + 1]) {\n const willSendRequest = request.willSendRequests[i];\n const nextWillSendRequest = request.willSendRequests[i + 1];\n ts = willSendRequest.ts;\n dur = Types.Timing.MicroSeconds(nextWillSendRequest.ts - willSendRequest.ts);\n }\n\n redirects.push({\n url: sendRequest.args.data.url,\n priority: sendRequest.args.data.priority,\n requestMethod: sendRequest.args.data.requestMethod,\n ts,\n dur,\n });\n }\n\n // If a ResourceFinish event with an encoded data length is received,\n // then the resource was not cached; it was fetched before it was\n // requested, e.g. because it was pushed in this navigation.\n const isPushedResource = request.resourceFinish?.args.data.encodedDataLength !== 0;\n // This works around crbug.com/998397, which reports pushed resources, and resources served by a service worker as disk cached.\n const isDiskCached = request.receiveResponse.args.data.fromCache &&\n !request.receiveResponse.args.data.fromServiceWorker && !isPushedResource;\n // If the request contains a resourceMarkAsCached event, it was served from memory cache.\n const isMemoryCached = request.resourceMarkAsCached !== undefined;\n\n // The timing data returned is from the original (uncached) request, which\n // means that if we leave the above network record data as-is when the\n // request came from either the disk cache or memory cache, our calculations\n // will be incorrect.\n //\n // Here we add a flag so when we calculate the timestamps of the various\n // events, we can overwrite them.\n // These timestamps may not be perfect (indeed they don't always match\n // the Network CDP domain exactly, which is likely an artifact of the way\n // the data is routed on the backend), but they're the closest we have.\n const isCached = isMemoryCached || isDiskCached;\n\n const timing = request.receiveResponse.args.data.timing;\n // If a non-cached request has no |timing| indicates data URLs, we ignore it.\n if (!timing && !isCached) {\n continue;\n }\n\n const firstSendRequest = request.sendRequests[0];\n const finalSendRequest = request.sendRequests[request.sendRequests.length - 1];\n\n const initialPriority = finalSendRequest.args.data.priority;\n let finalPriority = initialPriority;\n if (request.changePriority) {\n finalPriority = request.changePriority.args.data.priority;\n }\n\n // Start time\n // =======================\n // The time where the request started, which is either the first willSendRequest\n // event if there is one, or, if there is not, the sendRequest.\n const startTime = (request.willSendRequests && request.willSendRequests.length) ?\n Types.Timing.MicroSeconds(request.willSendRequests[0].ts) :\n Types.Timing.MicroSeconds(firstSendRequest.ts);\n\n // End redirect time\n // =======================\n // It's possible that when we start requesting data we will receive redirections.\n // Here we note the time of the *last* willSendRequest / sendRequest event,\n // which is used later on in the calculations for time queueing etc.\n const endRedirectTime = (request.willSendRequests && request.willSendRequests.length) ?\n Types.Timing.MicroSeconds(request.willSendRequests[request.willSendRequests.length - 1].ts) :\n Types.Timing.MicroSeconds(finalSendRequest.ts);\n\n // Finish time and end time\n // =======================\n // The finish time and the end time are subtly different.\n // - Finish time: records the point at which the network stack stopped receiving the data\n // - End time: the timestamp of the finish event itself (if one exists)\n //\n // The end time, then, will be slightly after the finish time.\n const endTime = request.resourceFinish ? request.resourceFinish.ts : endRedirectTime;\n const finishTime = request.resourceFinish?.args.data.finishTime ?\n Types.Timing.MicroSeconds(request.resourceFinish.args.data.finishTime * SECONDS_TO_MICROSECONDS) :\n Types.Timing.MicroSeconds(endTime);\n\n // Network duration\n // =======================\n // Time spent on the network.\n const networkDuration = isCached ? Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((finishTime || endRedirectTime) - endRedirectTime);\n\n // Processing duration\n // =======================\n // Time spent from start to end.\n const processingDuration = Types.Timing.MicroSeconds(endTime - (finishTime || endTime));\n\n // Redirection duration\n // =======================\n // Time between the first willSendRequest / sendRequest and last. This we place in *front* of the\n // queueing, since the queueing time that we know about from the trace data is only the last request,\n // i.e., the one that occurs after all the redirects.\n const redirectionDuration = Types.Timing.MicroSeconds(endRedirectTime - startTime);\n\n // Queueing\n // =======================\n // The amount of time queueing is the time between the request's start time to the requestTime\n // arg recorded in the receiveResponse event. In the cases where the recorded start time is larger\n // that the requestTime we set queueing time to zero.\n const queueing = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds(Platform.NumberUtilities.clamp(\n (timing.requestTime * SECONDS_TO_MICROSECONDS - endRedirectTime), 0, Number.MAX_VALUE));\n\n // Stalled\n // =======================\n // If the request is cached, the amount of time stalled is the time between the start time and\n // receiving a response.\n // Otherwise it is whichever positive number comes first from the following timing info:\n // DNS start, Connection start, Send Start, or the time duration between our start time and\n // receiving a response.\n const stalled = isCached ? Types.Timing.MicroSeconds(request.receiveResponse.ts - startTime) :\n Types.Timing.MicroSeconds(firstPositiveValueInList([\n timing.dnsStart * MILLISECONDS_TO_MICROSECONDS,\n timing.connectStart * MILLISECONDS_TO_MICROSECONDS,\n timing.sendStart * MILLISECONDS_TO_MICROSECONDS,\n (request.receiveResponse.ts - endRedirectTime),\n ]));\n\n // Sending HTTP request\n // =======================\n // Time when the HTTP request is sent.\n const sendStartTime = isCached ?\n startTime :\n Types.Timing.MicroSeconds(\n timing.requestTime * SECONDS_TO_MICROSECONDS + timing.sendStart * MILLISECONDS_TO_MICROSECONDS);\n\n // Waiting\n // =======================\n // Time from when the send finished going to when the headers were received.\n const waiting = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.receiveHeadersEnd - timing.sendEnd) * MILLISECONDS_TO_MICROSECONDS);\n\n // Download\n // =======================\n // Time from receipt of headers to the finish time.\n const downloadStart = isCached ?\n startTime :\n Types.Timing.MicroSeconds(\n timing.requestTime * SECONDS_TO_MICROSECONDS + timing.receiveHeadersEnd * MILLISECONDS_TO_MICROSECONDS);\n const download = isCached ? Types.Timing.MicroSeconds(endTime - request.receiveResponse.ts) :\n Types.Timing.MicroSeconds(((finishTime || downloadStart) - downloadStart));\n\n const totalTime = Types.Timing.MicroSeconds(networkDuration + processingDuration);\n\n // Collect a few values from the timing info.\n // If the Network request is cached, we zero out them.\n const dnsLookup = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.dnsEnd - timing.dnsStart) * MILLISECONDS_TO_MICROSECONDS);\n const ssl = isCached ? Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.sslEnd - timing.sslStart) * MILLISECONDS_TO_MICROSECONDS);\n const proxyNegotiation = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.proxyEnd - timing.proxyStart) * MILLISECONDS_TO_MICROSECONDS);\n const requestSent = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.sendEnd - timing.sendStart) * MILLISECONDS_TO_MICROSECONDS);\n const initialConnection = isCached ?\n Types.Timing.MicroSeconds(0) :\n Types.Timing.MicroSeconds((timing.connectEnd - timing.connectStart) * MILLISECONDS_TO_MICROSECONDS);\n\n // Finally get some of the general data from the trace events.\n const {frame, url, renderBlocking} = finalSendRequest.args.data;\n const {encodedDataLength, decodedBodyLength} =\n request.resourceFinish ? request.resourceFinish.args.data : {encodedDataLength: 0, decodedBodyLength: 0};\n const parsedUrl = new URL(url);\n const isHttps = parsedUrl.protocol === 'https:';\n const requestingFrameUrl =\n Helpers.Trace.activeURLForFrameAtTime(frame, finalSendRequest.ts, rendererProcessesByFrame) || '';\n // Construct a synthetic trace event for this network request.\n const networkEvent = Helpers.SyntheticEvents.SyntheticEventsManager\n .registerSyntheticBasedEvent<Types.TraceEvents.SyntheticNetworkRequest>({\n rawSourceEvent: finalSendRequest,\n args: {\n data: {\n // All data we create from trace events should be added to |syntheticData|.\n syntheticData: {\n dnsLookup,\n download,\n downloadStart,\n finishTime,\n initialConnection,\n isDiskCached,\n isHttps,\n isMemoryCached,\n isPushedResource,\n networkDuration,\n processingDuration,\n proxyNegotiation,\n queueing,\n redirectionDuration,\n requestSent,\n sendStartTime,\n ssl,\n stalled,\n totalTime,\n waiting,\n },\n // All fields below are from TraceEventsForNetworkRequest.\n decodedBodyLength,\n encodedDataLength,\n frame,\n fromServiceWorker: request.receiveResponse.args.data.fromServiceWorker,\n isLinkPreload: finalSendRequest.args.data.isLinkPreload || false,\n mimeType: request.receiveResponse.args.data.mimeType,\n priority: finalPriority,\n initialPriority,\n protocol: request.receiveResponse.args.data.protocol ?? 'unknown',\n redirects,\n // In the event the property isn't set, assume non-blocking.\n renderBlocking: renderBlocking ?? 'non_blocking',\n requestId,\n requestingFrameUrl,\n requestMethod: finalSendRequest.args.data.requestMethod,\n resourceType: finalSendRequest.args.data.resourceType,\n statusCode: request.receiveResponse.args.data.statusCode,\n responseHeaders: request.receiveResponse.args.data.headers || [],\n fetchPriorityHint: finalSendRequest.args.data.fetchPriorityHint,\n initiator: finalSendRequest.args.data.initiator,\n stackTrace: finalSendRequest.args.data.stackTrace,\n timing,\n url,\n failed: request.resourceFinish?.args.data.didFail ?? false,\n finished: Boolean(request.resourceFinish),\n connectionId: request.receiveResponse.args.data.connectionId,\n connectionReused: request.receiveResponse.args.data.connectionReused,\n },\n },\n cat: 'loading',\n name: 'SyntheticNetworkRequest',\n ph: Types.TraceEvents.Phase.COMPLETE,\n dur: Types.Timing.MicroSeconds(endTime - startTime),\n tdur: Types.Timing.MicroSeconds(endTime - startTime),\n ts: Types.Timing.MicroSeconds(startTime),\n tts: Types.Timing.MicroSeconds(startTime),\n pid: finalSendRequest.pid,\n tid: finalSendRequest.tid,\n });\n\n const requests = Platform.MapUtilities.getWithDefault(requestsByOrigin, parsedUrl.host, () => {\n return {\n renderBlocking: [],\n nonRenderBlocking: [],\n all: [],\n };\n });\n\n // For ease of rendering we sometimes want to differentiate between\n // render-blocking and non-render-blocking, so we divide the data here.\n if (!Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(networkEvent)) {\n requests.nonRenderBlocking.push(networkEvent);\n } else {\n requests.renderBlocking.push(networkEvent);\n }\n\n // However, there are also times where we just want to loop through all\n // the captured requests, so here we store all of them together.\n requests.all.push(networkEvent);\n requestsByTime.push(networkEvent);\n\n const initiatorUrl = networkEvent.args.data.initiator?.url ||\n Helpers.Trace.getZeroIndexedStackTraceForEvent(networkEvent)?.at(0)?.url;\n if (initiatorUrl) {\n const events = networkRequestEventByInitiatorUrl.get(initiatorUrl) ?? [];\n events.push(networkEvent);\n networkRequestEventByInitiatorUrl.set(initiatorUrl, events);\n }\n }\n\n for (const request of requestsByTime) {\n const initiatedEvents = networkRequestEventByInitiatorUrl.get(request.args.data.url);\n\n if (initiatedEvents) {\n for (const initiatedEvent of initiatedEvents) {\n eventToInitiatorMap.set(initiatedEvent, request);\n }\n }\n }\n finalizeWebSocketData();\n\n handlerState = HandlerState.FINALIZED;\n}\n\nexport function data(): NetworkRequestData {\n if (handlerState !== HandlerState.FINALIZED) {\n throw new Error('Network Request handler is not finalized');\n }\n\n return {\n byOrigin: requestsByOrigin,\n byTime: requestsByTime,\n eventToInitiator: eventToInitiatorMap,\n webSocket: [...webSocketData.values()],\n };\n}\n\nexport function deps(): TraceEventHandlerName[] {\n return ['Meta'];\n}\n\nfunction finalizeWebSocketData(): void {\n // for each WebSocketTraceData in webSocketData map, we create a synthetic event\n // to represent the entire WebSocket connection. This is done by finding the start and end event\n // if they exist, and if they don't, we use the first event in the list for start, and the traceBounds.max\n // for the end. So each WebSocketTraceData will have\n // {\n // events: the list of WebSocket events\n // syntheticConnectionEvent: the synthetic event representing the entire WebSocket connection\n // }\n webSocketData.forEach(data => {\n let startEvent: Types.TraceEvents.WebSocketEvent|null = null;\n let endEvent: Types.TraceEvents.TraceEventWebSocketDestroy|null = null;\n for (const event of data.events) {\n if (Types.TraceEvents.isTraceEventWebSocketCreate(event)) {\n startEvent = event;\n }\n if (Types.TraceEvents.isTraceEventWebSocketDestroy(event)) {\n endEvent = event;\n }\n }\n data.syntheticConnectionEvent = createSyntheticWebSocketConnectionEvent(startEvent, endEvent, data.events[0]);\n });\n}\n\nfunction createSyntheticWebSocketConnectionEvent(\n startEvent: Types.TraceEvents.TraceEventWebSocketCreate|null,\n endEvent: Types.TraceEvents.TraceEventWebSocketDestroy|null,\n firstRecordedEvent: Types.TraceEvents.WebSocketEvent): Types.TraceEvents.SyntheticWebSocketConnectionEvent {\n const {traceBounds} = metaHandlerData();\n const startTs = startEvent ? startEvent.ts : traceBounds.min;\n const endTs = endEvent ? endEvent.ts : traceBounds.max;\n const duration = endTs - startTs;\n const mainEvent = startEvent || endEvent || firstRecordedEvent;\n return {\n name: 'SyntheticWebSocketConnectionEvent',\n cat: mainEvent.cat,\n ph: Types.TraceEvents.Phase.COMPLETE,\n ts: startTs,\n dur: duration as Types.Timing.MicroSeconds,\n pid: mainEvent.pid,\n tid: mainEvent.tid,\n s: mainEvent.s,\n rawSourceEvent: mainEvent,\n _tag: 'SyntheticEntryTag',\n args: {\n data: {\n identifier: mainEvent.args.data.identifier,\n priority: Protocol.Network.ResourcePriority.Low,\n url: mainEvent.args.data.url || '',\n },\n },\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as Types from './../types/types.js';
|
|
2
|
-
import * as ModelHandlers from './ModelHandlers.js';
|
|
2
|
+
import type * as ModelHandlers from './ModelHandlers.js';
|
|
3
3
|
export interface TraceEventHandler {
|
|
4
4
|
reset(): void;
|
|
5
5
|
initialize?(freshRecording?: boolean): void;
|
|
@@ -25,13 +25,6 @@ export type HandlersWithMeta<T extends {
|
|
|
25
25
|
[K in keyof T]: T[K];
|
|
26
26
|
};
|
|
27
27
|
export type TraceParseData = Readonly<EnabledHandlerDataWithMeta<typeof ModelHandlers>>;
|
|
28
|
-
/**
|
|
29
|
-
* Because you can run the trace engine with a subset of handlers enabled,
|
|
30
|
-
* there can be times when you need to confirm if the trace contains all
|
|
31
|
-
* handlers or not, because some parts of the engine expect to be given all
|
|
32
|
-
* the handlers.
|
|
33
|
-
*/
|
|
34
|
-
export declare function handlerDataHasAllHandlers(data: Readonly<EnabledHandlerDataWithMeta<{}>>): data is TraceParseData;
|
|
35
28
|
type DeepWriteable<T> = {
|
|
36
29
|
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
37
30
|
};
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Because you can run the trace engine with a subset of handlers enabled,
|
|
4
|
-
* there can be times when you need to confirm if the trace contains all
|
|
5
|
-
* handlers or not, because some parts of the engine expect to be given all
|
|
6
|
-
* the handlers.
|
|
7
|
-
*/
|
|
8
|
-
export function handlerDataHasAllHandlers(data) {
|
|
9
|
-
let isMissingHandler = false;
|
|
10
|
-
for (const handlerName of Object.keys(ModelHandlers)) {
|
|
11
|
-
if (handlerName in data === false) {
|
|
12
|
-
isMissingHandler = true;
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return !isMissingHandler;
|
|
17
|
-
}
|
|
1
|
+
export {};
|
|
18
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/types.ts"],"names":[],"mappings":"","sourcesContent":["\n// 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.\nimport type * as Types from './../types/types.js';\nimport type * as ModelHandlers from './ModelHandlers.js';\n\nexport interface TraceEventHandler {\n reset(): void;\n initialize?(freshRecording?: boolean): void;\n handleEvent(data: {}): void;\n finalize?(): Promise<void>;\n data(): unknown;\n deps?(): TraceEventHandlerName[];\n handleUserConfig?(config: Types.Configuration.Configuration): void;\n}\nexport type TraceEventHandlerName = keyof typeof ModelHandlers;\n\n// This type maps TraceEventHandler names to the return type of their data\n// function. So, for example, if we are given an object with a key of 'foo'\n// and a value which is a TraceHandler containing a data() function that\n// returns a string, this type will be { foo: string }.\n//\n// This allows us to model the behavior of the TraceProcessor in the model,\n// which takes an object with TraceEventHandlers as part of its config, and\n// which ultimately returns an object keyed off the names of the\n// TraceEventHandlers, and with values that are derived from each\n// TraceEventHandler's data function.\n//\n// So, concretely, we provide a TraceEventHandler for calculating the #time\n// bounds of a trace called TraceBounds, whose data() function returns a\n// TraceWindow. The HandlerData, therefore, would determine that the\n// TraceProcessor would contain a key called 'TraceBounds' whose value is\n// a TraceWindow.\nexport type EnabledHandlerDataWithMeta<T extends {[key: string]: TraceEventHandler}> = {\n // We allow the user to configure which handlers are created by passing them\n // in when constructing a model instance. However, we then ensure that the\n // Meta handler is added to that, as the Model relies on some of the data\n // from the Meta handler when creating the file. Therefore, this type\n // explicitly defines that the Meta data is present, before then extending it\n // with the index type to represent all the other handlers.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Meta: Readonly<ReturnType<typeof ModelHandlers['Meta']['data']>>,\n}&{\n // For every key in the object, look up the TraceEventHandler's data function\n // and use its return type as the value for the object.\n [K in keyof T]: Readonly<ReturnType<T[K]['data']>>;\n};\n\nexport type HandlersWithMeta<T extends {[key: string]: TraceEventHandler}> = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Meta: typeof ModelHandlers.Meta,\n}&{\n [K in keyof T]: T[K];\n};\n\n// Represents the final parsed data from all of the handlers. If you instantiate a\n// TraceProcessor with a subset of handlers, you should instead use\n// `EnabledHandlerDataWithMeta<>`.\nexport type TraceParseData = Readonly<EnabledHandlerDataWithMeta<typeof ModelHandlers>>;\n\ntype DeepWriteable<T> = {\n -readonly[P in keyof T]: DeepWriteable<T[P]>\n};\nexport type TraceParseDataMutable = DeepWriteable<TraceParseData>;\n\nexport type Handlers = typeof ModelHandlers;\n\nexport const enum HandlerState {\n UNINITIALIZED = 1,\n INITIALIZED = 2,\n FINALIZED = 3,\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type * as Types from '../types/types.js';
|
|
2
|
-
export declare function buildTrackDataFromExtensionEntries(extensionEntries: Types.Extensions.
|
|
2
|
+
export declare function buildTrackDataFromExtensionEntries(extensionEntries: Types.Extensions.SyntheticExtensionTrackChartEntry[], extensionTrackData: Types.Extensions.ExtensionTrackData[]): Types.Extensions.ExtensionTrackData[];
|