@paulirish/trace_engine 0.0.67 → 0.0.69
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/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
- package/README.md +17 -1
- package/core/common/ParsedURL.d.ts +0 -2
- package/core/common/ParsedURL.js +3 -3
- package/core/common/ParsedURL.js.map +1 -1
- package/core/platform/StringUtilities.d.ts +15 -4
- package/core/platform/StringUtilities.js +48 -12
- package/core/platform/StringUtilities.js.map +1 -1
- package/generated/protocol.d.ts +89 -19
- package/generated/protocol.js +9 -4
- package/locales/af.json +12 -12
- package/locales/am.json +19 -19
- package/locales/ar.json +56 -56
- package/locales/as.json +69 -69
- package/locales/az.json +22 -22
- package/locales/be.json +46 -46
- package/locales/bg.json +17 -17
- package/locales/bn.json +76 -76
- package/locales/bs.json +23 -23
- package/locales/ca.json +14 -14
- package/locales/cs.json +13 -13
- package/locales/cy.json +21 -21
- package/locales/da.json +12 -12
- package/locales/de.json +10 -10
- package/locales/el.json +14 -14
- package/locales/en-GB.json +73 -73
- package/locales/en-US.json +3 -6
- package/locales/en-XL.json +3 -6
- package/locales/es-419.json +64 -64
- package/locales/es.json +44 -44
- package/locales/et.json +48 -48
- package/locales/eu.json +18 -18
- package/locales/fa.json +39 -39
- package/locales/fi.json +11 -11
- package/locales/fil.json +34 -34
- package/locales/fr-CA.json +49 -49
- package/locales/fr.json +18 -18
- package/locales/gl.json +33 -33
- package/locales/gu.json +39 -39
- package/locales/he.json +72 -72
- package/locales/hi.json +40 -40
- package/locales/hr.json +26 -26
- package/locales/hu.json +56 -56
- package/locales/hy.json +19 -19
- package/locales/id.json +68 -68
- package/locales/is.json +11 -11
- package/locales/it.json +44 -44
- package/locales/ja.json +15 -15
- package/locales/ka.json +68 -68
- package/locales/kk.json +44 -44
- package/locales/km.json +18 -18
- package/locales/kn.json +28 -28
- package/locales/ko.json +11 -11
- package/locales/ky.json +22 -22
- package/locales/lo.json +33 -33
- package/locales/lt.json +9 -9
- package/locales/lv.json +35 -35
- package/locales/mk.json +18 -18
- package/locales/ml.json +19 -19
- package/locales/mn.json +40 -40
- package/locales/mr.json +12 -12
- package/locales/ms.json +15 -15
- package/locales/my.json +62 -62
- package/locales/ne.json +42 -42
- package/locales/nl.json +33 -33
- package/locales/no.json +17 -17
- package/locales/or.json +54 -54
- package/locales/pa.json +24 -24
- package/locales/pl.json +32 -32
- package/locales/pt-PT.json +12 -12
- package/locales/pt.json +41 -41
- package/locales/ro.json +11 -11
- package/locales/ru.json +40 -40
- package/locales/si.json +36 -36
- package/locales/sk.json +65 -65
- package/locales/sl.json +13 -13
- package/locales/sq.json +21 -21
- package/locales/sr-Latn.json +17 -17
- package/locales/sr.json +17 -17
- package/locales/sv.json +13 -13
- package/locales/sw.json +69 -69
- package/locales/ta.json +39 -39
- package/locales/te.json +38 -38
- package/locales/th.json +38 -38
- package/locales/tr.json +17 -17
- package/locales/uk.json +23 -23
- package/locales/ur.json +13 -13
- package/locales/uz.json +15 -15
- package/locales/vi.json +43 -43
- package/locales/zh-HK.json +38 -38
- package/locales/zh-TW.json +35 -35
- package/locales/zh.json +73 -73
- package/locales/zu.json +53 -53
- package/models/cpu_profile/CPUProfileDataModel.d.ts +0 -33
- package/models/cpu_profile/CPUProfileDataModel.js +14 -14
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
- package/models/cpu_profile/ProfileTreeModel.d.ts +1 -2
- package/models/cpu_profile/ProfileTreeModel.js +4 -4
- package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
- package/models/trace/EventsSerializer.js +1 -13
- package/models/trace/EventsSerializer.js.map +1 -1
- package/models/trace/LanternComputationData.js +36 -10
- package/models/trace/LanternComputationData.js.map +1 -1
- package/models/trace/ModelImpl.js +0 -2
- package/models/trace/ModelImpl.js.map +1 -1
- package/models/trace/Processor.js +16 -8
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/extras/ThirdParties.js +4 -6
- package/models/trace/extras/ThirdParties.js.map +1 -1
- package/models/trace/extras/TraceFilter.d.ts +1 -0
- package/models/trace/extras/TraceFilter.js +18 -8
- package/models/trace/extras/TraceFilter.js.map +1 -1
- package/models/trace/extras/TraceTree.d.ts +13 -16
- package/models/trace/extras/TraceTree.js +161 -110
- package/models/trace/extras/TraceTree.js.map +1 -1
- package/models/trace/handlers/ExtensionTraceDataHandler.d.ts +0 -5
- package/models/trace/handlers/ExtensionTraceDataHandler.js +0 -5
- package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
- package/models/trace/handlers/FlowsHandler.js +34 -19
- package/models/trace/handlers/FlowsHandler.js.map +1 -1
- package/models/trace/handlers/InitiatorsHandler.js +22 -34
- package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.js +2 -6
- package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
- package/models/trace/handlers/MetaHandler.js +3 -0
- package/models/trace/handlers/MetaHandler.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.js +12 -6
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/RendererHandler.js +7 -6
- package/models/trace/handlers/RendererHandler.js.map +1 -1
- package/models/trace/handlers/SamplesHandler.d.ts +0 -1
- package/models/trace/handlers/SamplesHandler.js +11 -6
- package/models/trace/handlers/SamplesHandler.js.map +1 -1
- package/models/trace/handlers/ScriptsHandler.js +24 -22
- package/models/trace/handlers/ScriptsHandler.js.map +1 -1
- package/models/trace/handlers/types.d.ts +15 -0
- package/models/trace/handlers/types.js.map +1 -1
- package/models/trace/helpers/Extensions.js +1 -3
- package/models/trace/helpers/Extensions.js.map +1 -1
- package/models/trace/helpers/SamplesIntegrator.d.ts +17 -14
- package/models/trace/helpers/SamplesIntegrator.js +147 -84
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
- package/models/trace/helpers/SyntheticEvents.d.ts +0 -8
- package/models/trace/helpers/SyntheticEvents.js +10 -33
- package/models/trace/helpers/SyntheticEvents.js.map +1 -1
- package/models/trace/helpers/Trace.js +19 -14
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/helpers/TreeHelpers.d.ts +13 -1
- package/models/trace/helpers/TreeHelpers.js +35 -8
- package/models/trace/helpers/TreeHelpers.js.map +1 -1
- package/models/trace/insights/DuplicatedJavaScript.js +1 -2
- package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
- package/models/trace/insights/RenderBlocking.js +3 -1
- package/models/trace/insights/RenderBlocking.js.map +1 -1
- package/models/trace/insights/SlowCSSSelector.js +2 -2
- package/models/trace/insights/SlowCSSSelector.js.map +1 -1
- package/models/trace/lantern/metrics/LargestContentfulPaint.d.ts +6 -1
- package/models/trace/lantern/metrics/LargestContentfulPaint.js +130 -5
- package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -1
- package/models/trace/lantern/simulation/Simulator.d.ts +4 -0
- package/models/trace/lantern/simulation/Simulator.js +8 -1
- package/models/trace/lantern/simulation/Simulator.js.map +1 -1
- package/models/trace/lantern/types/Lantern.d.ts +4 -0
- package/models/trace/lantern/types/Lantern.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +21 -19
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/package.json +1 -1
- package/test/test-trace-engine.mjs +20 -17
- package/third_party/legacy-javascript/lib/legacy-javascript.js +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DuplicatedJavaScript.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/DuplicatedJavaScript.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAE9C,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC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AAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE7G,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzD,KAAK,MAAM,EAAC,UAAU,EAAC,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;QAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBAC/B,SAAS;YACX,CAAC;YAED,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,CAAC;YAC/C,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YAChE,sBAAsB,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;QACrG,CAAC;IACH,CAAC;IAED,IAAI,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;IAC7C,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,KAAK,CAAC,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3D,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,eAAe
|
|
1
|
+
{"version":3,"file":"DuplicatedJavaScript.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/DuplicatedJavaScript.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA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,IAAI,CAAC,IAAI,EAAE,iBAAiB,IAAI,eAAe,CAAC;QACvF,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,WAAW;QACX,+BAA+B;QAC/B,sBAAsB,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAC5D,OAAO;QACP,eAAe;QACf,aAAa,EAAE,2BAA2B,CAAC,sBAAsB,EAAE,OAAO,CAAC;QAC3E,WAAW,EAAE,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC;KAChF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAuC;IACpE,OAAO,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QAC/F,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,OAAO;YACd,aAAa,EAAE,OAAO;SACvB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Extras from '../extras/extras.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {estimateCompressionRatioForScript, metricSavingsForWastedBytes} from './Common.js';\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that identifies multiple copies of the same JavaScript sources, and recommends removing the duplication.\n */\n title: 'Duplicated JavaScript',\n /**\n * @description Description of an insight that identifies multiple copies of the same JavaScript sources, and recommends removing the duplication.\n */\n description:\n 'Remove large, [duplicate JavaScript modules](https://developer.chrome.com/docs/performance/insights/duplicated-javascript) from bundles to reduce unnecessary bytes consumed by network activity',\n /**\n * @description Label for a column in a data table; entries will be the locations of JavaScript or CSS code, e.g. the name of a JavaScript package or module.\n */\n columnSource: 'Source',\n /**\n * @description Label for a column in a data table; entries will be the number of wasted bytes due to duplication of a web resource.\n */\n columnDuplicatedBytes: 'Duplicated bytes',\n /**\n * @description Message shown when no duplicated JavaScript is found.\n */\n noDuplicatedJavaScript: 'No duplicated JavaScript found',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/DuplicatedJavaScript.ts', UIStrings);\nexport const i18nString: i18n.LocalizeString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type DuplicatedJavaScriptInsightModel = InsightModel<typeof UIStrings, {\n duplication: Extras.ScriptDuplication.ScriptDuplication,\n duplicationGroupedByNodeModules: Extras.ScriptDuplication.ScriptDuplication,\n scriptsWithDuplication: Handlers.ModelHandlers.Scripts.Script[],\n scripts: Handlers.ModelHandlers.Scripts.Script[],\n mainDocumentUrl: string,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<DuplicatedJavaScriptInsightModel>):\n DuplicatedJavaScriptInsightModel {\n const requests = partialModel.scriptsWithDuplication.map(script => script.request).filter(e => !!e);\n\n return {\n insightKey: InsightKeys.DUPLICATE_JAVASCRIPT,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n docs: 'https://developer.chrome.com/docs/performance/insights/duplicated-javascript',\n category: InsightCategory.LCP,\n state: Boolean(partialModel.duplication.values().next().value) ? 'fail' : 'pass',\n relatedEvents: [...new Set(requests)],\n ...partialModel,\n };\n}\n\nexport function isDuplicatedJavaScriptInsight(model: InsightModel): model is DuplicatedJavaScriptInsightModel {\n return model.insightKey === InsightKeys.DUPLICATE_JAVASCRIPT;\n}\n\nexport function generateInsight(\n data: Handlers.Types.HandlerData, context: InsightSetContext): DuplicatedJavaScriptInsightModel {\n const scripts = data.Scripts.scripts.filter(script => {\n if (script.frame !== context.frameId) {\n return false;\n }\n\n if (script.url?.startsWith('chrome-extension://')) {\n return false;\n }\n\n return Helpers.Timing.timestampIsInBounds(context.bounds, script.ts);\n });\n\n const compressionRatios = new Map<string, number>();\n for (const script of scripts) {\n if (script.request) {\n compressionRatios.set(script.request.args.data.requestId, estimateCompressionRatioForScript(script));\n }\n }\n\n const {duplication, duplicationGroupedByNodeModules} =\n Extras.ScriptDuplication.computeScriptDuplication({scripts}, compressionRatios);\n const scriptsWithDuplication = [...duplication.values().flatMap(data => data.duplicates.map(d => d.script))];\n\n const wastedBytesByRequestId = new Map<string, number>();\n for (const {duplicates} of duplication.values()) {\n for (let i = 1; i < duplicates.length; i++) {\n const sourceData = duplicates[i];\n if (!sourceData.script.request) {\n continue;\n }\n\n const transferSize = sourceData.attributedSize;\n const requestId = sourceData.script.request.args.data.requestId;\n wastedBytesByRequestId.set(requestId, (wastedBytesByRequestId.get(requestId) || 0) + transferSize);\n }\n }\n\n let mainDocumentUrl = data.Meta.mainFrameURL;\n if (context.navigation) {\n if (Types.Events.isSoftNavigationStart(context.navigation)) {\n mainDocumentUrl = context.navigation.args.context.URL;\n } else {\n mainDocumentUrl = context.navigation.args.data?.documentLoaderURL ?? mainDocumentUrl;\n }\n }\n\n return finalize({\n duplication,\n duplicationGroupedByNodeModules,\n scriptsWithDuplication: [...new Set(scriptsWithDuplication)],\n scripts,\n mainDocumentUrl,\n metricSavings: metricSavingsForWastedBytes(wastedBytesByRequestId, context),\n wastedBytes: wastedBytesByRequestId.values().reduce((acc, cur) => acc + cur, 0),\n });\n}\n\nexport function createOverlays(model: DuplicatedJavaScriptInsightModel): Types.Overlays.Overlay[] {\n return model.scriptsWithDuplication.map(script => script.request).filter(e => !!e).map(request => {\n return {\n type: 'ENTRY_OUTLINE',\n entry: request,\n outlineReason: 'ERROR',\n };\n });\n}\n"]}
|
|
@@ -52,17 +52,19 @@ function getNodesAndTimingByRequestId(nodeTimings) {
|
|
|
52
52
|
}
|
|
53
53
|
let duration = nodeTiming.duration;
|
|
54
54
|
let startTime = nodeTiming.startTime;
|
|
55
|
+
let queuedTime = nodeTiming.queuedTime;
|
|
55
56
|
for (const redirect of node.request.redirects ?? []) {
|
|
56
57
|
const redirectTiming = timingByNodeId.get(redirect.requestId);
|
|
57
58
|
if (redirectTiming) {
|
|
58
59
|
duration += redirectTiming.duration;
|
|
59
60
|
startTime = Math.min(startTime, redirectTiming.startTime);
|
|
61
|
+
queuedTime = Math.min(queuedTime, redirectTiming.queuedTime);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
const backendRequestId = node.request.rawRequest?.args.data.requestId ?? node.request.requestId;
|
|
63
65
|
requestIdToNode.set(backendRequestId, {
|
|
64
66
|
node,
|
|
65
|
-
nodeTiming: { startTime, endTime: nodeTiming.endTime, duration },
|
|
67
|
+
nodeTiming: { startTime, endTime: nodeTiming.endTime, queuedTime, duration },
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
return requestIdToNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderBlocking.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/RenderBlocking.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EACL,eAAe,EACf,WAAW,EAIX,cAAc,GAGf,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,0BAA0B;IACjC;;OAEG;IACH,WAAW,EACP,iOAAiO;IACrO;;OAEG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ACzC,sBAAsB,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5D,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;QACd,aAAa,EAAE,sBAAsB;QACrC,sBAAsB;QACtB,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAA6C;IACnF,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,OAAO;QACd,aAAa,EAAE,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAiC;IAC9D,OAAO,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC;AACvF,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Protocol from '../../../generated/protocol.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type InsightSetContextWithNavigation,\n InsightWarning,\n type LanternContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that provides the user with the list of network requests that blocked and therefore slowed down the page rendering and becoming visible to the user.\n */\n title: 'Render-blocking requests',\n /**\n * @description Text to describe that there are requests blocking rendering, which may affect LCP.\n */\n description:\n `Requests are blocking the page’s initial render, which may delay LCP. [Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) can move these network requests out of the critical path.`,\n /**\n * @description Label to describe a network request (that happens to be render-blocking).\n */\n renderBlockingRequest: 'Request',\n /**\n * @description Label used for a time duration.\n */\n duration: 'Duration',\n /**\n * @description Text status indicating that no requests blocked the initial render of a navigation.\n */\n noRenderBlocking: 'No render-blocking requests for this navigation',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/RenderBlocking.ts', UIStrings);\nexport const i18nString: i18n.LocalizeString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function isRenderBlockingInsight(insight: InsightModel): insight is RenderBlockingInsightModel {\n return insight.insightKey === 'RenderBlocking';\n}\n\nexport type RenderBlockingInsightModel = InsightModel<typeof UIStrings, {\n renderBlockingRequests: Types.Events.SyntheticNetworkRequest[],\n requestIdToWastedMs?: Map<string, number>,\n}>;\n\n// Because of the way we detect blocking stylesheets, asynchronously loaded\n// CSS with link[rel=preload] and an onload handler (see https://github.com/filamentgroup/loadCSS)\n// can be falsely flagged as blocking. Therefore, ignore stylesheets that loaded fast enough\n// to possibly be non-blocking (and they have minimal impact anyway).\nconst MINIMUM_WASTED_MS = 50;\n\n/**\n * Given a simulation's nodeTimings, return an object with the nodes/timing keyed by network URL\n */\nfunction getNodesAndTimingByRequestId(nodeTimings: Lantern.Simulation.Result['nodeTimings']):\n Map<string, {node: Lantern.Graph.NetworkNode, nodeTiming: Lantern.Types.Simulation.NodeTiming}> {\n const timingByNodeId = new Map<string, Lantern.Types.Simulation.NodeTiming>();\n for (const [node, nodeTiming] of nodeTimings) {\n timingByNodeId.set(node.id, nodeTiming);\n }\n\n const requestIdToNode =\n new Map<string, {node: Lantern.Graph.NetworkNode, nodeTiming: Lantern.Types.Simulation.NodeTiming}>();\n\n for (const [node, nodeTiming] of nodeTimings) {\n if (node.type !== 'network' || node.request.redirectDestination) {\n continue;\n }\n\n let duration = nodeTiming.duration;\n let startTime = nodeTiming.startTime;\n for (const redirect of node.request.redirects ?? []) {\n const redirectTiming = timingByNodeId.get(redirect.requestId);\n if (redirectTiming) {\n duration += redirectTiming.duration;\n startTime = Math.min(startTime, redirectTiming.startTime);\n }\n }\n\n const backendRequestId = node.request.rawRequest?.args.data.requestId ?? node.request.requestId;\n requestIdToNode.set(backendRequestId, {\n node,\n nodeTiming: {startTime, endTime: nodeTiming.endTime, duration},\n });\n }\n\n return requestIdToNode;\n}\n\nfunction estimateSavingsWithGraphs(deferredIds: Set<string>, lanternContext: LanternContext): Types.Timing.Milli {\n const simulator = lanternContext.simulator;\n const fcpGraph = lanternContext.metrics.firstContentfulPaint.optimisticGraph;\n const {nodeTimings} = lanternContext.simulator.simulate(fcpGraph);\n const adjustedNodeTimings = new Map(nodeTimings);\n\n const totalChildNetworkBytes = 0;\n const minimalFCPGraph = fcpGraph.cloneWithRelationships(node => {\n // If a node can be deferred, exclude it from the new FCP graph\n const canDeferRequest = deferredIds.has(node.id);\n return !canDeferRequest;\n });\n\n if (minimalFCPGraph.type !== 'network') {\n throw new Error('minimalFCPGraph not a NetworkNode');\n }\n\n // Recalculate the \"before\" time based on our adjusted node timings.\n const estimateBeforeInline = Math.max(...Array.from(\n Array.from(adjustedNodeTimings).map(timing => timing[1].endTime),\n ));\n\n // Add the inlined bytes to the HTML response\n const originalTransferSize = minimalFCPGraph.request.transferSize;\n const safeTransferSize = originalTransferSize || 0;\n minimalFCPGraph.request.transferSize = safeTransferSize + totalChildNetworkBytes;\n const estimateAfterInline = simulator.simulate(minimalFCPGraph).timeInMs;\n minimalFCPGraph.request.transferSize = originalTransferSize;\n return Math.round(Math.max(estimateBeforeInline - estimateAfterInline, 0)) as Types.Timing.Milli;\n}\n\nfunction hasImageLCP(data: Handlers.Types.HandlerData, context: InsightSetContextWithNavigation): boolean {\n return data.LargestImagePaint.lcpRequestByNavigationId.has(context.navigationId);\n}\n\nfunction computeSavings(\n data: Handlers.Types.HandlerData, context: InsightSetContextWithNavigation,\n renderBlockingRequests: Types.Events.SyntheticNetworkRequest[]):\n Pick<RenderBlockingInsightModel, 'metricSavings'|'requestIdToWastedMs'>|undefined {\n if (!context.lantern) {\n return;\n }\n\n const nodesAndTimingsByRequestId =\n getNodesAndTimingByRequestId(context.lantern.metrics.firstContentfulPaint.optimisticEstimate.nodeTimings);\n\n const metricSavings = {FCP: 0 as Types.Timing.Milli, LCP: 0 as Types.Timing.Milli};\n const requestIdToWastedMs = new Map<string, number>();\n const deferredNodeIds = new Set<string>();\n for (const request of renderBlockingRequests) {\n const nodeAndTiming = nodesAndTimingsByRequestId.get(request.args.data.requestId);\n if (!nodeAndTiming) {\n continue;\n }\n\n const {node, nodeTiming} = nodeAndTiming;\n\n // Mark this node, any redirects leading to it, and all its dependents as deferrable\n for (const redirect of node.request.redirects ?? []) {\n deferredNodeIds.add(redirect.requestId);\n }\n node.traverse(node => deferredNodeIds.add(node.id));\n\n // \"wastedMs\" is the download time of the network request, responseReceived - requestSent\n const wastedMs = Math.round(nodeTiming.duration);\n if (wastedMs < MINIMUM_WASTED_MS) {\n continue;\n }\n\n requestIdToWastedMs.set(request.args.data.requestId, wastedMs);\n }\n\n if (requestIdToWastedMs.size) {\n metricSavings.FCP = estimateSavingsWithGraphs(deferredNodeIds, context.lantern);\n\n // In most cases, render-blocking resources only affect LCP if LCP isn't an image.\n if (!hasImageLCP(data, context)) {\n metricSavings.LCP = metricSavings.FCP;\n }\n }\n\n return {metricSavings, requestIdToWastedMs};\n}\n\nfunction finalize(partialModel: PartialInsightModel<RenderBlockingInsightModel>): RenderBlockingInsightModel {\n return {\n insightKey: InsightKeys.RENDER_BLOCKING,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n docs: 'https://developer.chrome.com/docs/performance/insights/render-blocking',\n category: InsightCategory.LCP,\n state: partialModel.renderBlockingRequests.length > 0 ? 'fail' : 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n data: Handlers.Types.HandlerData, context: InsightSetContext): RenderBlockingInsightModel {\n if (!context.navigation || !('navigationId' in context)) {\n return finalize({\n renderBlockingRequests: [],\n });\n }\n\n const firstPaintTs = data.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)\n ?.get(context.navigation)\n ?.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP)\n ?.event?.ts;\n if (!firstPaintTs) {\n return finalize({\n renderBlockingRequests: [],\n warnings: [InsightWarning.NO_FP],\n });\n }\n\n let renderBlockingRequests: Types.Events.SyntheticNetworkRequest[] = [];\n for (const req of data.NetworkRequests.byTime) {\n if (req.args.data.frame !== context.frameId) {\n continue;\n }\n\n if (!Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(req)) {\n continue;\n }\n\n if (req.args.data.syntheticData.finishTime > firstPaintTs) {\n continue;\n }\n\n // If a request is marked `in_body_parser_blocking` it should only be considered render-blocking if it is a\n // high enough priority. Some requests (e.g. scripts) are not marked as high priority if they are fetched\n // after a non-preloaded image. (See \"early\" definition in https://web.dev/articles/fetch-priority)\n //\n // There are edge cases and exceptions (e.g. priority hints) but this gives us the best approximation\n // of render-blocking resources in the document body.\n if (req.args.data.renderBlocking === 'in_body_parser_blocking') {\n const priority = req.args.data.priority;\n const isScript = req.args.data.resourceType === Protocol.Network.ResourceType.Script;\n const isBlockingScript = isScript && priority === Protocol.Network.ResourcePriority.High;\n if (priority !== Protocol.Network.ResourcePriority.VeryHigh && !isBlockingScript) {\n continue;\n }\n }\n\n const navigation = Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, data.Meta.navigationsByFrameId);\n if (navigation === context.navigation) {\n renderBlockingRequests.push(req);\n }\n }\n\n const savings = computeSavings(data, context, renderBlockingRequests);\n\n // Sort by request duration for insights.\n renderBlockingRequests = renderBlockingRequests.sort((a, b) => {\n return b.dur - a.dur;\n });\n\n return finalize({\n relatedEvents: renderBlockingRequests,\n renderBlockingRequests,\n ...savings,\n });\n}\n\nexport function createOverlayForRequest(request: Types.Events.SyntheticNetworkRequest): Types.Overlays.EntryOutline {\n return {\n type: 'ENTRY_OUTLINE',\n entry: request,\n outlineReason: 'ERROR',\n };\n}\n\nexport function createOverlays(model: RenderBlockingInsightModel): Types.Overlays.Overlay[] {\n return model.renderBlockingRequests.map(request => createOverlayForRequest(request));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RenderBlocking.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/RenderBlocking.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EACL,eAAe,EACf,WAAW,EAIX,cAAc,GAGf,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,0BAA0B;IACjC;;OAEG;IACH,WAAW,EACP,iOAAiO;IACrO;;OAEG;IACH,qBAAqB,EAAE,SAAS;IAChC;;OAEG;IACH,QAAQ,EAAE,UAAU;IACpB;;OAEG;IACH,gBAAgB,EAAE,iDAAiD;CAC3D,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,yCAAyC,EAAE,SAAS,CAAC,CAAC;AAC/F,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAElG,MAAM,UAAU,uBAAuB,CAAC,OAAqB;IAC3D,OAAO,OAAO,CAAC,UAAU,KAAK,gBAAgB,CAAC;AACjD,CAAC;AAOD,2EAA2E;AAC3E,kGAAkG;AAClG,4FAA4F;AAC5F,qEAAqE;AACrE,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;GAEG;AACH,SAAS,4BAA4B,CAAC,WAAqD;IAEzF,MAAM,cAAc,GAAG,IAAI,GAAG,EAA+C,CAAC;IAC9E,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,WAA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AAC,OAAO,CAAC,CAAC,CAAC;AACvF,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Protocol from '../../../generated/protocol.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type InsightSetContextWithNavigation,\n InsightWarning,\n type LanternContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that provides the user with the list of network requests that blocked and therefore slowed down the page rendering and becoming visible to the user.\n */\n title: 'Render-blocking requests',\n /**\n * @description Text to describe that there are requests blocking rendering, which may affect LCP.\n */\n description:\n `Requests are blocking the page’s initial render, which may delay LCP. [Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) can move these network requests out of the critical path.`,\n /**\n * @description Label to describe a network request (that happens to be render-blocking).\n */\n renderBlockingRequest: 'Request',\n /**\n * @description Label used for a time duration.\n */\n duration: 'Duration',\n /**\n * @description Text status indicating that no requests blocked the initial render of a navigation.\n */\n noRenderBlocking: 'No render-blocking requests for this navigation',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/RenderBlocking.ts', UIStrings);\nexport const i18nString: i18n.LocalizeString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function isRenderBlockingInsight(insight: InsightModel): insight is RenderBlockingInsightModel {\n return insight.insightKey === 'RenderBlocking';\n}\n\nexport type RenderBlockingInsightModel = InsightModel<typeof UIStrings, {\n renderBlockingRequests: Types.Events.SyntheticNetworkRequest[],\n requestIdToWastedMs?: Map<string, number>,\n}>;\n\n// Because of the way we detect blocking stylesheets, asynchronously loaded\n// CSS with link[rel=preload] and an onload handler (see https://github.com/filamentgroup/loadCSS)\n// can be falsely flagged as blocking. Therefore, ignore stylesheets that loaded fast enough\n// to possibly be non-blocking (and they have minimal impact anyway).\nconst MINIMUM_WASTED_MS = 50;\n\n/**\n * Given a simulation's nodeTimings, return an object with the nodes/timing keyed by network URL\n */\nfunction getNodesAndTimingByRequestId(nodeTimings: Lantern.Simulation.Result['nodeTimings']):\n Map<string, {node: Lantern.Graph.NetworkNode, nodeTiming: Lantern.Types.Simulation.NodeTiming}> {\n const timingByNodeId = new Map<string, Lantern.Types.Simulation.NodeTiming>();\n for (const [node, nodeTiming] of nodeTimings) {\n timingByNodeId.set(node.id, nodeTiming);\n }\n\n const requestIdToNode =\n new Map<string, {node: Lantern.Graph.NetworkNode, nodeTiming: Lantern.Types.Simulation.NodeTiming}>();\n\n for (const [node, nodeTiming] of nodeTimings) {\n if (node.type !== 'network' || node.request.redirectDestination) {\n continue;\n }\n\n let duration = nodeTiming.duration;\n let startTime = nodeTiming.startTime;\n let queuedTime = nodeTiming.queuedTime;\n for (const redirect of node.request.redirects ?? []) {\n const redirectTiming = timingByNodeId.get(redirect.requestId);\n if (redirectTiming) {\n duration += redirectTiming.duration;\n startTime = Math.min(startTime, redirectTiming.startTime);\n queuedTime = Math.min(queuedTime, redirectTiming.queuedTime);\n }\n }\n\n const backendRequestId = node.request.rawRequest?.args.data.requestId ?? node.request.requestId;\n requestIdToNode.set(backendRequestId, {\n node,\n nodeTiming: {startTime, endTime: nodeTiming.endTime, queuedTime, duration},\n });\n }\n\n return requestIdToNode;\n}\n\nfunction estimateSavingsWithGraphs(deferredIds: Set<string>, lanternContext: LanternContext): Types.Timing.Milli {\n const simulator = lanternContext.simulator;\n const fcpGraph = lanternContext.metrics.firstContentfulPaint.optimisticGraph;\n const {nodeTimings} = lanternContext.simulator.simulate(fcpGraph);\n const adjustedNodeTimings = new Map(nodeTimings);\n\n const totalChildNetworkBytes = 0;\n const minimalFCPGraph = fcpGraph.cloneWithRelationships(node => {\n // If a node can be deferred, exclude it from the new FCP graph\n const canDeferRequest = deferredIds.has(node.id);\n return !canDeferRequest;\n });\n\n if (minimalFCPGraph.type !== 'network') {\n throw new Error('minimalFCPGraph not a NetworkNode');\n }\n\n // Recalculate the \"before\" time based on our adjusted node timings.\n const estimateBeforeInline = Math.max(...Array.from(\n Array.from(adjustedNodeTimings).map(timing => timing[1].endTime),\n ));\n\n // Add the inlined bytes to the HTML response\n const originalTransferSize = minimalFCPGraph.request.transferSize;\n const safeTransferSize = originalTransferSize || 0;\n minimalFCPGraph.request.transferSize = safeTransferSize + totalChildNetworkBytes;\n const estimateAfterInline = simulator.simulate(minimalFCPGraph).timeInMs;\n minimalFCPGraph.request.transferSize = originalTransferSize;\n return Math.round(Math.max(estimateBeforeInline - estimateAfterInline, 0)) as Types.Timing.Milli;\n}\n\nfunction hasImageLCP(data: Handlers.Types.HandlerData, context: InsightSetContextWithNavigation): boolean {\n return data.LargestImagePaint.lcpRequestByNavigationId.has(context.navigationId);\n}\n\nfunction computeSavings(\n data: Handlers.Types.HandlerData, context: InsightSetContextWithNavigation,\n renderBlockingRequests: Types.Events.SyntheticNetworkRequest[]):\n Pick<RenderBlockingInsightModel, 'metricSavings'|'requestIdToWastedMs'>|undefined {\n if (!context.lantern) {\n return;\n }\n\n const nodesAndTimingsByRequestId =\n getNodesAndTimingByRequestId(context.lantern.metrics.firstContentfulPaint.optimisticEstimate.nodeTimings);\n\n const metricSavings = {FCP: 0 as Types.Timing.Milli, LCP: 0 as Types.Timing.Milli};\n const requestIdToWastedMs = new Map<string, number>();\n const deferredNodeIds = new Set<string>();\n for (const request of renderBlockingRequests) {\n const nodeAndTiming = nodesAndTimingsByRequestId.get(request.args.data.requestId);\n if (!nodeAndTiming) {\n continue;\n }\n\n const {node, nodeTiming} = nodeAndTiming;\n\n // Mark this node, any redirects leading to it, and all its dependents as deferrable\n for (const redirect of node.request.redirects ?? []) {\n deferredNodeIds.add(redirect.requestId);\n }\n node.traverse(node => deferredNodeIds.add(node.id));\n\n // \"wastedMs\" is the download time of the network request, responseReceived - requestSent\n const wastedMs = Math.round(nodeTiming.duration);\n if (wastedMs < MINIMUM_WASTED_MS) {\n continue;\n }\n\n requestIdToWastedMs.set(request.args.data.requestId, wastedMs);\n }\n\n if (requestIdToWastedMs.size) {\n metricSavings.FCP = estimateSavingsWithGraphs(deferredNodeIds, context.lantern);\n\n // In most cases, render-blocking resources only affect LCP if LCP isn't an image.\n if (!hasImageLCP(data, context)) {\n metricSavings.LCP = metricSavings.FCP;\n }\n }\n\n return {metricSavings, requestIdToWastedMs};\n}\n\nfunction finalize(partialModel: PartialInsightModel<RenderBlockingInsightModel>): RenderBlockingInsightModel {\n return {\n insightKey: InsightKeys.RENDER_BLOCKING,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n docs: 'https://developer.chrome.com/docs/performance/insights/render-blocking',\n category: InsightCategory.LCP,\n state: partialModel.renderBlockingRequests.length > 0 ? 'fail' : 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n data: Handlers.Types.HandlerData, context: InsightSetContext): RenderBlockingInsightModel {\n if (!context.navigation || !('navigationId' in context)) {\n return finalize({\n renderBlockingRequests: [],\n });\n }\n\n const firstPaintTs = data.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)\n ?.get(context.navigation)\n ?.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP)\n ?.event?.ts;\n if (!firstPaintTs) {\n return finalize({\n renderBlockingRequests: [],\n warnings: [InsightWarning.NO_FP],\n });\n }\n\n let renderBlockingRequests: Types.Events.SyntheticNetworkRequest[] = [];\n for (const req of data.NetworkRequests.byTime) {\n if (req.args.data.frame !== context.frameId) {\n continue;\n }\n\n if (!Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(req)) {\n continue;\n }\n\n if (req.args.data.syntheticData.finishTime > firstPaintTs) {\n continue;\n }\n\n // If a request is marked `in_body_parser_blocking` it should only be considered render-blocking if it is a\n // high enough priority. Some requests (e.g. scripts) are not marked as high priority if they are fetched\n // after a non-preloaded image. (See \"early\" definition in https://web.dev/articles/fetch-priority)\n //\n // There are edge cases and exceptions (e.g. priority hints) but this gives us the best approximation\n // of render-blocking resources in the document body.\n if (req.args.data.renderBlocking === 'in_body_parser_blocking') {\n const priority = req.args.data.priority;\n const isScript = req.args.data.resourceType === Protocol.Network.ResourceType.Script;\n const isBlockingScript = isScript && priority === Protocol.Network.ResourcePriority.High;\n if (priority !== Protocol.Network.ResourcePriority.VeryHigh && !isBlockingScript) {\n continue;\n }\n }\n\n const navigation = Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, data.Meta.navigationsByFrameId);\n if (navigation === context.navigation) {\n renderBlockingRequests.push(req);\n }\n }\n\n const savings = computeSavings(data, context, renderBlockingRequests);\n\n // Sort by request duration for insights.\n renderBlockingRequests = renderBlockingRequests.sort((a, b) => {\n return b.dur - a.dur;\n });\n\n return finalize({\n relatedEvents: renderBlockingRequests,\n renderBlockingRequests,\n ...savings,\n });\n}\n\nexport function createOverlayForRequest(request: Types.Events.SyntheticNetworkRequest): Types.Overlays.EntryOutline {\n return {\n type: 'ENTRY_OUTLINE',\n entry: request,\n outlineReason: 'ERROR',\n };\n}\n\nexport function createOverlays(model: RenderBlockingInsightModel): Types.Overlays.Overlay[] {\n return model.renderBlockingRequests.map(request => createOverlayForRequest(request));\n}\n"]}
|
|
@@ -101,11 +101,11 @@ export function generateInsight(data, context) {
|
|
|
101
101
|
let totalElapsedUs = 0;
|
|
102
102
|
let totalMatchAttempts = 0;
|
|
103
103
|
let totalMatchCount = 0;
|
|
104
|
-
|
|
104
|
+
for (const timing of selectorTimings) {
|
|
105
105
|
totalElapsedUs += timing[Types.Events.SelectorTimingsKey.Elapsed];
|
|
106
106
|
totalMatchAttempts += timing[Types.Events.SelectorTimingsKey.MatchAttempts];
|
|
107
107
|
totalMatchCount += timing[Types.Events.SelectorTimingsKey.MatchCount];
|
|
108
|
-
}
|
|
108
|
+
}
|
|
109
109
|
let topSelectorElapsedMs = null;
|
|
110
110
|
let topSelectorMatchAttempts = null;
|
|
111
111
|
if (selectorTimings.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlowCSSSelector.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/SlowCSSSelector.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,eAAe,EACf,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,oBAAoB;IAE3B;;OAEG;IACH,WAAW,EACP,4UAA4U;IAChV;;OAEG;IACH,aAAa,EAAE,gBAAgB;IAC/B;;OAEG;IACH,UAAU,EAAE,aAAa;IACzB;;OAEG;IACH,OAAO,EAAE,cAAc;IACvB;;OAEG;IACH,YAAY,EAAE,eAAe;IAC7B;;OAEG;IACH,KAAK,EAAE,OAAO;IACd;;OAEG;IACH,kBAAkB,EACd,0GAA0G;IAC9G;;OAEG;IACH,sBAAsB,EAAE,2BAA2B;IACnD;;OAEG;IACH,uBAAuB,EAAE,4BAA4B;CAC7C,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,0CAA0C,EAAE,SAAS,CAAC,CAAC;AAChG,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAClG,MAAM,wBAAwB,GAAG,GAAG,CAAC,CAAE,qCAAqC;AAU5E,SAAS,sBAAsB,CAAC,IAA4D,EAC5D,OAA0B;IACxD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuC,CAAC;IAEnE,KA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AO,QAAQ,CAAC;QACd,yEAAyE;QACzE,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC;QAC3D,kBAAkB;QAClB,eAAe;QACf,oBAAoB;QACpB,wBAAwB;KACzB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAA8B;IAC3D,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that provides details about slow CSS selectors.\n */\n title: 'CSS selector costs',\n\n /**\n * @description Text to describe how to improve the performance of CSS selectors.\n */\n description:\n 'If recalculate style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/performance/insights/slow-css-selector) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.',\n /**\n * @description Column name for count of elements that the engine attempted to match against a style rule.\n */\n matchAttempts: 'Match attempts',\n /**\n * @description Column name for count of elements that matched a style rule.\n */\n matchCount: 'Match count',\n /**\n * @description Column name for elapsed time spent computing a style rule.\n */\n elapsed: 'Elapsed time',\n /**\n * @description Column name for the selectors that took the longest amount of time/effort.\n */\n topSelectors: 'Top selectors',\n /**\n * @description Column name for a total sum.\n */\n total: 'Total',\n /**\n * @description Text status indicating that no CSS selector data was found.\n */\n enableSelectorData:\n 'No CSS selector data was found. CSS selector stats need to be enabled in the Performance panel settings.',\n /**\n * @description Top CSS selector when ranked by elapsed time in ms.\n */\n topSelectorElapsedTime: 'Top selector elapsed time',\n /**\n * @description Top CSS selector when ranked by match attempt.\n */\n topSelectorMatchAttempt: 'Top selector match attempt',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/SlowCSSSelector.ts', UIStrings);\nexport const i18nString: i18n.LocalizeString = i18n.i18n.getLocalizedString.bind(undefined, str_);\nconst slowCSSSelectorThreshold = 500; // 500us threshold for slow selectors\n\nexport type SlowCSSSelectorInsightModel = InsightModel<typeof UIStrings, {\n totalElapsedMs: Types.Timing.Milli,\n totalMatchAttempts: number,\n totalMatchCount: number,\n topSelectorElapsedMs: Types.Events.SelectorTiming | null,\n topSelectorMatchAttempts: Types.Events.SelectorTiming | null,\n}>;\n\nfunction aggregateSelectorStats(data: Handlers.ModelHandlers.SelectorStats.SelectorStatsData,\n context: InsightSetContext): Types.Events.SelectorTiming[] {\n const selectorMap = new Map<String, Types.Events.SelectorTiming>();\n\n for (const [event, value] of data.dataForRecalcStyleEvent) {\n if (event.args.beginData?.frame !== context.frameId) {\n continue;\n }\n if (!Helpers.Timing.eventIsInBounds(event, context.bounds)) {\n continue;\n }\n for (const timing of value.timings) {\n const key =\n timing[Types.Events.SelectorTimingsKey.Selector] + '_' + timing[Types.Events.SelectorTimingsKey.StyleSheetId];\n const findTiming = selectorMap.get(key);\n if (findTiming !== undefined) {\n findTiming[Types.Events.SelectorTimingsKey.Elapsed] += timing[Types.Events.SelectorTimingsKey.Elapsed];\n findTiming[Types.Events.SelectorTimingsKey.FastRejectCount] +=\n timing[Types.Events.SelectorTimingsKey.FastRejectCount];\n findTiming[Types.Events.SelectorTimingsKey.MatchAttempts] +=\n timing[Types.Events.SelectorTimingsKey.MatchAttempts];\n findTiming[Types.Events.SelectorTimingsKey.MatchCount] += timing[Types.Events.SelectorTimingsKey.MatchCount];\n } else {\n selectorMap.set(key, {...timing});\n }\n }\n }\n\n return [...selectorMap.values()];\n}\n\nfunction finalize(partialModel: PartialInsightModel<SlowCSSSelectorInsightModel>): SlowCSSSelectorInsightModel {\n return {\n insightKey: InsightKeys.SLOW_CSS_SELECTOR,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n docs: 'https://developer.chrome.com/docs/performance/insights/slow-css-selector',\n category: InsightCategory.ALL,\n state: partialModel.topSelectorElapsedMs && partialModel.topSelectorMatchAttempts ? 'informative' : 'pass',\n ...partialModel,\n };\n}\n\nexport function isSlowCSSSelectorInsight(model: InsightModel): model is SlowCSSSelectorInsightModel {\n return model.insightKey === InsightKeys.SLOW_CSS_SELECTOR;\n}\n\nexport function generateInsight(\n data: Handlers.Types.HandlerData, context: InsightSetContext): SlowCSSSelectorInsightModel {\n const selectorStatsData = data.SelectorStats;\n\n if (!selectorStatsData) {\n throw new Error('no selector stats data');\n }\n\n const selectorTimings = aggregateSelectorStats(selectorStatsData, context);\n\n let totalElapsedUs = 0;\n let totalMatchAttempts = 0;\n let totalMatchCount = 0;\n\n selectorTimings.map(timing => {\n totalElapsedUs += timing[Types.Events.SelectorTimingsKey.Elapsed];\n totalMatchAttempts += timing[Types.Events.SelectorTimingsKey.MatchAttempts];\n totalMatchCount += timing[Types.Events.SelectorTimingsKey.MatchCount];\n });\n\n let topSelectorElapsedMs: Types.Events.SelectorTiming|null = null;\n let topSelectorMatchAttempts: Types.Events.SelectorTiming|null = null;\n\n if (selectorTimings.length > 0) {\n // find the selector with most elapsed time\n topSelectorElapsedMs = selectorTimings.reduce((a, b) => {\n return a[Types.Events.SelectorTimingsKey.Elapsed] > b[Types.Events.SelectorTimingsKey.Elapsed] ? a : b;\n });\n\n // check if the slowest selector is slow enough to trigger insights info\n if (topSelectorElapsedMs &&\n topSelectorElapsedMs[Types.Events.SelectorTimingsKey.Elapsed] < slowCSSSelectorThreshold) {\n topSelectorElapsedMs = null;\n }\n\n // find the selector with most match attempts\n topSelectorMatchAttempts = selectorTimings.reduce((a, b) => {\n return a[Types.Events.SelectorTimingsKey.MatchAttempts] > b[Types.Events.SelectorTimingsKey.MatchAttempts] ? a :\n b;\n });\n }\n\n return finalize({\n // TODO: should we identify RecalcStyle events as linked to this insight?\n relatedEvents: [],\n totalElapsedMs: Types.Timing.Milli(totalElapsedUs / 1000.0),\n totalMatchAttempts,\n totalMatchCount,\n topSelectorElapsedMs,\n topSelectorMatchAttempts,\n });\n}\n\nexport function createOverlays(_: SlowCSSSelectorInsightModel): Types.Overlays.Overlay[] {\n return [];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SlowCSSSelector.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/SlowCSSSelector.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,eAAe,EACf,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,oBAAoB;IAE3B;;OAEG;IACH,WAAW,EACP,4UAA4U;IAChV;;OAEG;IACH,aAAa,EAAE,gBAAgB;IAC/B;;OAEG;IACH,UAAU,EAAE,aAAa;IACzB;;OAEG;IACH,OAAO,EAAE,cAAc;IACvB;;OAEG;IACH,YAAY,EAAE,eAAe;IAC7B;;OAEG;IACH,KAAK,EAAE,OAAO;IACd;;OAEG;IACH,kBAAkB,EACd,0GAA0G;IAC9G;;OAEG;IACH,sBAAsB,EAAE,2BAA2B;IACnD;;OAEG;IACH,uBAAuB,EAAE,4BAA4B;CAC7C,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,0CAA0C,EAAE,SAAS,CAAC,CAAC;AAChG,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAA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C,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC;QACjH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,yEAAyE;QACzE,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC;QAC3D,kBAAkB;QAClB,eAAe;QACf,oBAAoB;QACpB,wBAAwB;KACzB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAA8B;IAC3D,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that provides details about slow CSS selectors.\n */\n title: 'CSS selector costs',\n\n /**\n * @description Text to describe how to improve the performance of CSS selectors.\n */\n description:\n 'If recalculate style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/performance/insights/slow-css-selector) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.',\n /**\n * @description Column name for count of elements that the engine attempted to match against a style rule.\n */\n matchAttempts: 'Match attempts',\n /**\n * @description Column name for count of elements that matched a style rule.\n */\n matchCount: 'Match count',\n /**\n * @description Column name for elapsed time spent computing a style rule.\n */\n elapsed: 'Elapsed time',\n /**\n * @description Column name for the selectors that took the longest amount of time/effort.\n */\n topSelectors: 'Top selectors',\n /**\n * @description Column name for a total sum.\n */\n total: 'Total',\n /**\n * @description Text status indicating that no CSS selector data was found.\n */\n enableSelectorData:\n 'No CSS selector data was found. CSS selector stats need to be enabled in the Performance panel settings.',\n /**\n * @description Top CSS selector when ranked by elapsed time in ms.\n */\n topSelectorElapsedTime: 'Top selector elapsed time',\n /**\n * @description Top CSS selector when ranked by match attempt.\n */\n topSelectorMatchAttempt: 'Top selector match attempt',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/SlowCSSSelector.ts', UIStrings);\nexport const i18nString: i18n.LocalizeString = i18n.i18n.getLocalizedString.bind(undefined, str_);\nconst slowCSSSelectorThreshold = 500; // 500us threshold for slow selectors\n\nexport type SlowCSSSelectorInsightModel = InsightModel<typeof UIStrings, {\n totalElapsedMs: Types.Timing.Milli,\n totalMatchAttempts: number,\n totalMatchCount: number,\n topSelectorElapsedMs: Types.Events.SelectorTiming | null,\n topSelectorMatchAttempts: Types.Events.SelectorTiming | null,\n}>;\n\nfunction aggregateSelectorStats(data: Handlers.ModelHandlers.SelectorStats.SelectorStatsData,\n context: InsightSetContext): Types.Events.SelectorTiming[] {\n const selectorMap = new Map<string, Types.Events.SelectorTiming>();\n\n for (const [event, value] of data.dataForRecalcStyleEvent) {\n if (event.args.beginData?.frame !== context.frameId) {\n continue;\n }\n if (!Helpers.Timing.eventIsInBounds(event, context.bounds)) {\n continue;\n }\n for (const timing of value.timings) {\n const key =\n timing[Types.Events.SelectorTimingsKey.Selector] + '_' + timing[Types.Events.SelectorTimingsKey.StyleSheetId];\n const findTiming = selectorMap.get(key);\n if (findTiming !== undefined) {\n findTiming[Types.Events.SelectorTimingsKey.Elapsed] += timing[Types.Events.SelectorTimingsKey.Elapsed];\n findTiming[Types.Events.SelectorTimingsKey.FastRejectCount] +=\n timing[Types.Events.SelectorTimingsKey.FastRejectCount];\n findTiming[Types.Events.SelectorTimingsKey.MatchAttempts] +=\n timing[Types.Events.SelectorTimingsKey.MatchAttempts];\n findTiming[Types.Events.SelectorTimingsKey.MatchCount] += timing[Types.Events.SelectorTimingsKey.MatchCount];\n } else {\n selectorMap.set(key, {...timing});\n }\n }\n }\n\n return [...selectorMap.values()];\n}\n\nfunction finalize(partialModel: PartialInsightModel<SlowCSSSelectorInsightModel>): SlowCSSSelectorInsightModel {\n return {\n insightKey: InsightKeys.SLOW_CSS_SELECTOR,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n docs: 'https://developer.chrome.com/docs/performance/insights/slow-css-selector',\n category: InsightCategory.ALL,\n state: partialModel.topSelectorElapsedMs && partialModel.topSelectorMatchAttempts ? 'informative' : 'pass',\n ...partialModel,\n };\n}\n\nexport function isSlowCSSSelectorInsight(model: InsightModel): model is SlowCSSSelectorInsightModel {\n return model.insightKey === InsightKeys.SLOW_CSS_SELECTOR;\n}\n\nexport function generateInsight(\n data: Handlers.Types.HandlerData, context: InsightSetContext): SlowCSSSelectorInsightModel {\n const selectorStatsData = data.SelectorStats;\n\n if (!selectorStatsData) {\n throw new Error('no selector stats data');\n }\n\n const selectorTimings = aggregateSelectorStats(selectorStatsData, context);\n\n let totalElapsedUs = 0;\n let totalMatchAttempts = 0;\n let totalMatchCount = 0;\n\n for (const timing of selectorTimings) {\n totalElapsedUs += timing[Types.Events.SelectorTimingsKey.Elapsed];\n totalMatchAttempts += timing[Types.Events.SelectorTimingsKey.MatchAttempts];\n totalMatchCount += timing[Types.Events.SelectorTimingsKey.MatchCount];\n }\n\n let topSelectorElapsedMs: Types.Events.SelectorTiming|null = null;\n let topSelectorMatchAttempts: Types.Events.SelectorTiming|null = null;\n\n if (selectorTimings.length > 0) {\n // find the selector with most elapsed time\n topSelectorElapsedMs = selectorTimings.reduce((a, b) => {\n return a[Types.Events.SelectorTimingsKey.Elapsed] > b[Types.Events.SelectorTimingsKey.Elapsed] ? a : b;\n });\n\n // check if the slowest selector is slow enough to trigger insights info\n if (topSelectorElapsedMs &&\n topSelectorElapsedMs[Types.Events.SelectorTimingsKey.Elapsed] < slowCSSSelectorThreshold) {\n topSelectorElapsedMs = null;\n }\n\n // find the selector with most match attempts\n topSelectorMatchAttempts = selectorTimings.reduce((a, b) => {\n return a[Types.Events.SelectorTimingsKey.MatchAttempts] > b[Types.Events.SelectorTimingsKey.MatchAttempts] ? a :\n b;\n });\n }\n\n return finalize({\n // TODO: should we identify RecalcStyle events as linked to this insight?\n relatedEvents: [],\n totalElapsedMs: Types.Timing.Milli(totalElapsedUs / 1000.0),\n totalMatchAttempts,\n totalMatchCount,\n topSelectorElapsedMs,\n topSelectorMatchAttempts,\n });\n}\n\nexport function createOverlays(_: SlowCSSSelectorInsightModel): Types.Overlays.Overlay[] {\n return [];\n}\n"]}
|
|
@@ -9,9 +9,14 @@ declare class LargestContentfulPaint extends Metric {
|
|
|
9
9
|
* resource that is required for LCP. Our LCP graphs include everything except for these images.
|
|
10
10
|
*/
|
|
11
11
|
static isNotLowPriorityImageNode(node: Graph.Node): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Finds the NetworkNode corresponding to the LCP image in the dependency graph, if LCP was an image.
|
|
14
|
+
*/
|
|
15
|
+
static findLcpNode(dependencyGraph: Graph.Node, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.NetworkNode | null;
|
|
16
|
+
static isSameFrameTextLcp(processedNavigation: Types.Simulation.ProcessedNavigation): boolean;
|
|
12
17
|
static getOptimisticGraph(dependencyGraph: Graph.Node, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node;
|
|
13
18
|
static getPessimisticGraph(dependencyGraph: Graph.Node, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node;
|
|
14
|
-
static getEstimateFromSimulation(simulationResult: Simulation.Result): Simulation.Result;
|
|
19
|
+
static getEstimateFromSimulation(simulationResult: Simulation.Result, extras?: Extras): Simulation.Result;
|
|
15
20
|
static compute(data: MetricComputationDataInput, extras?: Omit<Extras, 'optimistic'>): MetricResult;
|
|
16
21
|
}
|
|
17
22
|
export { LargestContentfulPaint };
|
|
@@ -4,6 +4,24 @@
|
|
|
4
4
|
import * as Core from '../core/core.js';
|
|
5
5
|
import { FirstContentfulPaint } from './FirstContentfulPaint.js';
|
|
6
6
|
import { Metric, } from './Metric.js';
|
|
7
|
+
// Prior to https://crbug.com/583885865, Blink wrote largestContentfulPaint::Candidate
|
|
8
|
+
// with the exact base::TimeTicks presentation timestamp while firstContentfulPaint
|
|
9
|
+
// round-tripped through double seconds (InSecondsF -> base::Seconds), which could
|
|
10
|
+
// truncate the FCP trace timestamp by 1 µs for the exact same frame presentation.
|
|
11
|
+
const SAME_FRAME_TIMESTAMP_TOLERANCE_US = 10;
|
|
12
|
+
function stripUrlHash(urlStr) {
|
|
13
|
+
if (!urlStr.includes('#')) {
|
|
14
|
+
return urlStr;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const url = new URL(urlStr);
|
|
18
|
+
url.hash = '';
|
|
19
|
+
return url.href;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return urlStr;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
7
25
|
class LargestContentfulPaint extends Metric {
|
|
8
26
|
static get coefficients() {
|
|
9
27
|
return {
|
|
@@ -24,25 +42,129 @@ class LargestContentfulPaint extends Metric {
|
|
|
24
42
|
const isLowPriority = node.request.priority === 'Low' || node.request.priority === 'VeryLow';
|
|
25
43
|
return !isImage || !isLowPriority;
|
|
26
44
|
}
|
|
27
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Finds the NetworkNode corresponding to the LCP image in the dependency graph, if LCP was an image.
|
|
47
|
+
*/
|
|
48
|
+
static findLcpNode(dependencyGraph, processedNavigation) {
|
|
49
|
+
const lcp = processedNavigation.timestamps.largestContentfulPaint;
|
|
50
|
+
if (!lcp) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const lcpEvent = processedNavigation.largestContentfulPaintEvt;
|
|
54
|
+
if (lcpEvent?.args?.data?.type && lcpEvent.args.data.type !== 'image') {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const { lcpRequestId, lcpImageUrl } = processedNavigation;
|
|
58
|
+
if (!lcpRequestId && !lcpImageUrl) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (lcpRequestId) {
|
|
62
|
+
const idMatches = [];
|
|
63
|
+
dependencyGraph.traverse(node => {
|
|
64
|
+
if (node.type !== 'network' || node.request.redirectDestination) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (node.request.finished === false || node.endTime < 0 || node.startTime > lcp) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const baseRequestId = node.request.requestId.replace(/(:redirect|:duplicate)+$/, '');
|
|
71
|
+
if (baseRequestId === lcpRequestId) {
|
|
72
|
+
idMatches.push(node);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (idMatches.length) {
|
|
76
|
+
idMatches.sort((a, b) => a.endTime - b.endTime);
|
|
77
|
+
return idMatches[0];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (!lcpImageUrl) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const normalizedLcpUrl = stripUrlHash(lcpImageUrl);
|
|
84
|
+
const lcpFrameId = lcpEvent?.args?.frame;
|
|
85
|
+
const urlMatches = [];
|
|
86
|
+
dependencyGraph.traverse(node => {
|
|
87
|
+
if (node.type !== 'network' || node.request.redirectDestination) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (node.request.finished === false || node.endTime < 0 || node.startTime > lcp) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (lcpFrameId && node.request.frameId && node.request.frameId !== lcpFrameId) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (node.request.resourceType && node.request.resourceType !== 'Image' && node.request.resourceType !== 'Media') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const matchesUrl = node.request.url === lcpImageUrl || stripUrlHash(node.request.url) === normalizedLcpUrl ||
|
|
100
|
+
Boolean(node.request.redirects?.some(r => r.url === lcpImageUrl || stripUrlHash(r.url) === normalizedLcpUrl));
|
|
101
|
+
if (matchesUrl) {
|
|
102
|
+
urlMatches.push(node);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
if (!urlMatches.length) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
urlMatches.sort((a, b) => a.endTime - b.endTime);
|
|
109
|
+
return urlMatches[0];
|
|
110
|
+
}
|
|
111
|
+
static isSameFrameTextLcp(processedNavigation) {
|
|
28
112
|
const { firstContentfulPaint: fcp, largestContentfulPaint: lcp } = processedNavigation.timestamps;
|
|
113
|
+
if (!lcp) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return Math.abs(lcp - fcp) <= SAME_FRAME_TIMESTAMP_TOLERANCE_US &&
|
|
117
|
+
processedNavigation.largestContentfulPaintEvt?.args?.data?.type === 'text';
|
|
118
|
+
}
|
|
119
|
+
static getOptimisticGraph(dependencyGraph, processedNavigation) {
|
|
120
|
+
const lcp = processedNavigation.timestamps.largestContentfulPaint;
|
|
29
121
|
if (!lcp) {
|
|
30
122
|
throw new Core.LanternError('NO_LCP');
|
|
31
123
|
}
|
|
32
|
-
if (
|
|
124
|
+
if (LargestContentfulPaint.isSameFrameTextLcp(processedNavigation)) {
|
|
33
125
|
return FirstContentfulPaint.getOptimisticGraph(dependencyGraph, processedNavigation);
|
|
34
126
|
}
|
|
127
|
+
const lcpNode = LargestContentfulPaint.findLcpNode(dependencyGraph, processedNavigation);
|
|
128
|
+
if (lcpNode) {
|
|
129
|
+
const fcpOptimisticGraph = FirstContentfulPaint.getOptimisticGraph(dependencyGraph, processedNavigation);
|
|
130
|
+
const criticalNodeIds = new Set();
|
|
131
|
+
fcpOptimisticGraph.traverse(node => criticalNodeIds.add(node.id));
|
|
132
|
+
criticalNodeIds.add(lcpNode.id);
|
|
133
|
+
// PageDependencyGraph.linkCPUNodes does not add CPUNode -> Image edges, so if the LCP image
|
|
134
|
+
// has any Script dependencies (e.g. JS-injected hero image or JS-injected stylesheet),
|
|
135
|
+
// include the CPU tasks that evaluated those scripts prior to the LCP request.
|
|
136
|
+
const initiatorScriptUrls = new Set();
|
|
137
|
+
lcpNode.traverse(node => {
|
|
138
|
+
if (node.type === 'network' && node.request.resourceType === 'Script') {
|
|
139
|
+
initiatorScriptUrls.add(node.request.url);
|
|
140
|
+
}
|
|
141
|
+
}, node => node.getDependencies());
|
|
142
|
+
if (initiatorScriptUrls.size) {
|
|
143
|
+
dependencyGraph.traverse(node => {
|
|
144
|
+
if (node.type !== 'cpu' || node.startTime > lcpNode.startTime) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
for (const url of node.getEvaluateScriptURLs()) {
|
|
148
|
+
if (initiatorScriptUrls.has(url)) {
|
|
149
|
+
criticalNodeIds.add(node.id);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return dependencyGraph.cloneWithRelationships(node => criticalNodeIds.has(node.id));
|
|
156
|
+
}
|
|
35
157
|
return FirstContentfulPaint.getFirstPaintBasedGraph(dependencyGraph, {
|
|
36
158
|
cutoffTimestamp: lcp,
|
|
37
159
|
treatNodeAsRenderBlocking: LargestContentfulPaint.isNotLowPriorityImageNode,
|
|
38
160
|
});
|
|
39
161
|
}
|
|
40
162
|
static getPessimisticGraph(dependencyGraph, processedNavigation) {
|
|
41
|
-
const
|
|
163
|
+
const lcp = processedNavigation.timestamps.largestContentfulPaint;
|
|
42
164
|
if (!lcp) {
|
|
43
165
|
throw new Core.LanternError('NO_LCP');
|
|
44
166
|
}
|
|
45
|
-
if (
|
|
167
|
+
if (LargestContentfulPaint.isSameFrameTextLcp(processedNavigation)) {
|
|
46
168
|
return FirstContentfulPaint.getPessimisticGraph(dependencyGraph, processedNavigation);
|
|
47
169
|
}
|
|
48
170
|
return FirstContentfulPaint.getFirstPaintBasedGraph(dependencyGraph, {
|
|
@@ -52,7 +174,10 @@ class LargestContentfulPaint extends Metric {
|
|
|
52
174
|
additionalCpuNodesToTreatAsRenderBlocking: node => node.didPerformLayout(),
|
|
53
175
|
});
|
|
54
176
|
}
|
|
55
|
-
static getEstimateFromSimulation(simulationResult) {
|
|
177
|
+
static getEstimateFromSimulation(simulationResult, extras) {
|
|
178
|
+
if (extras?.optimistic) {
|
|
179
|
+
return simulationResult;
|
|
180
|
+
}
|
|
56
181
|
const nodeTimesNotOffscreenImages = Array.from(simulationResult.nodeTimings.entries())
|
|
57
182
|
.filter(entry => LargestContentfulPaint.isNotLowPriorityImageNode(entry[0]))
|
|
58
183
|
.map(entry => entry[1].endTime);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LargestContentfulPaint.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAKxC,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAEL,MAAM,GAIP,MAAM,aAAa,CAAC;AAErB,MAAM,sBAAuB,SAAQ,MAAM;IACzC,MAAM,KAAc,YAAY;QAC9B,OAAO;YACL,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,GAAG;YACf,WAAW,EAAE,GAAG;SACjB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,yBAAyB,CAAC,IAAgB;QAC/C,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,KAAK,OAAO,CAAC;QACtD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,KAAK,IAAI,IAAI,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C,eAAe,EAAE;YACnE,eAAe,EAAE,GAAG;YACpB,yBAAyB,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI;YACpC,uDAAuD;YACvD,yCAAyC,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE;SAC3E,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAU,yBAAyB,CAAC,gBAAmC;QAC3E,MAAM,2BAA2B,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;aAC7C,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3E,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAExE,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,2BAA2B,CAAC;YAClD,WAAW,EAAE,gBAAgB,CAAC,WAAW;SAC1C,CAAC;IACJ,CAAC;IAED,MAAM,CAAU,OAAO,CAAC,IAAgC,EAAE,MAAmC;QAC3F,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAC;QACpC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,6CAA6C,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjD,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QACtE,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAED,OAAO,EAAC,sBAAsB,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Core from '../core/core.js';\nimport type * as Graph from '../graph/graph.js';\nimport type * as Simulation from '../simulation/simulation.js';\nimport type * as Types from '../types/types.js';\n\nimport {FirstContentfulPaint} from './FirstContentfulPaint.js';\nimport {\n type Extras,\n Metric,\n type MetricCoefficients,\n type MetricComputationDataInput,\n type MetricResult,\n} from './Metric.js';\n\nclass LargestContentfulPaint extends Metric {\n static override get coefficients(): MetricCoefficients {\n return {\n intercept: 0,\n optimistic: 0.5,\n pessimistic: 0.5,\n };\n }\n\n /**\n * Low priority image nodes are usually offscreen and very unlikely to be the\n * resource that is required for LCP. Our LCP graphs include everything except for these images.\n */\n static isNotLowPriorityImageNode(node: Graph.Node): boolean {\n if (node.type !== 'network') {\n return true;\n }\n const isImage = node.request.resourceType === 'Image';\n const isLowPriority = node.request.priority === 'Low' || node.request.priority === 'VeryLow';\n return !isImage || !isLowPriority;\n }\n\n static override getOptimisticGraph(\n dependencyGraph: Graph.Node, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node {\n const {firstContentfulPaint: fcp, largestContentfulPaint: lcp} = processedNavigation.timestamps;\n if (!lcp) {\n throw new Core.LanternError('NO_LCP');\n }\n if (fcp === lcp && processedNavigation.largestContentfulPaintEvt?.args?.data?.type === 'text') {\n return FirstContentfulPaint.getOptimisticGraph(dependencyGraph, processedNavigation);\n }\n\n return FirstContentfulPaint.getFirstPaintBasedGraph(dependencyGraph, {\n cutoffTimestamp: lcp,\n treatNodeAsRenderBlocking: LargestContentfulPaint.isNotLowPriorityImageNode,\n });\n }\n\n static override getPessimisticGraph(\n dependencyGraph: Graph.Node, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node {\n const {firstContentfulPaint: fcp, largestContentfulPaint: lcp} = processedNavigation.timestamps;\n if (!lcp) {\n throw new Core.LanternError('NO_LCP');\n }\n if (fcp === lcp && processedNavigation.largestContentfulPaintEvt?.args?.data?.type === 'text') {\n return FirstContentfulPaint.getPessimisticGraph(dependencyGraph, processedNavigation);\n }\n\n return FirstContentfulPaint.getFirstPaintBasedGraph(dependencyGraph, {\n cutoffTimestamp: lcp,\n treatNodeAsRenderBlocking: _ => true,\n // For pessimistic LCP we'll include *all* layout nodes\n additionalCpuNodesToTreatAsRenderBlocking: node => node.didPerformLayout(),\n });\n }\n\n static override getEstimateFromSimulation(simulationResult: Simulation.Result): Simulation.Result {\n const nodeTimesNotOffscreenImages = Array.from(simulationResult.nodeTimings.entries())\n .filter(entry => LargestContentfulPaint.isNotLowPriorityImageNode(entry[0]))\n .map(entry => entry[1].endTime);\n\n return {\n timeInMs: Math.max(...nodeTimesNotOffscreenImages),\n nodeTimings: simulationResult.nodeTimings,\n };\n }\n\n static override compute(data: MetricComputationDataInput, extras?: Omit<Extras, 'optimistic'>): MetricResult {\n const fcpResult = extras?.fcpResult;\n if (!fcpResult) {\n throw new Core.LanternError('FCP is required to calculate the LCP metric');\n }\n\n const metricResult = super.compute(data, extras);\n metricResult.timing = Math.max(metricResult.timing, fcpResult.timing);\n return metricResult;\n }\n}\n\nexport {LargestContentfulPaint};\n"]}
|
|
1
|
+
{"version":3,"file":"LargestContentfulPaint.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAKxC,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAEL,MAAM,GAIP,MAAM,aAAa,CAAC;AAErB,sFAAsF;AACtF,mFAAmF;AACnF,kFAAkF;AAClF,kFAAkF;AAClF,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAE7C,SAAS,YAAY,CAAC,MAAc;IAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,GAAG,GAA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3F,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAC;QACpC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,6CAA6C,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjD,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QACtE,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAED,OAAO,EAAC,sBAAsB,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Core from '../core/core.js';\nimport type * as Graph from '../graph/graph.js';\nimport type * as Simulation from '../simulation/simulation.js';\nimport type * as Types from '../types/types.js';\n\nimport {FirstContentfulPaint} from './FirstContentfulPaint.js';\nimport {\n type Extras,\n Metric,\n type MetricCoefficients,\n type MetricComputationDataInput,\n type MetricResult,\n} from './Metric.js';\n\n// Prior to https://crbug.com/583885865, Blink wrote largestContentfulPaint::Candidate\n// with the exact base::TimeTicks presentation timestamp while firstContentfulPaint\n// round-tripped through double seconds (InSecondsF -> base::Seconds), which could\n// truncate the FCP trace timestamp by 1 µs for the exact same frame presentation.\nconst SAME_FRAME_TIMESTAMP_TOLERANCE_US = 10;\n\nfunction stripUrlHash(urlStr: string): string {\n if (!urlStr.includes('#')) {\n return urlStr;\n }\n try {\n const url = new URL(urlStr);\n url.hash = '';\n return url.href;\n } catch {\n return urlStr;\n }\n}\n\nclass LargestContentfulPaint extends Metric {\n static override get coefficients(): MetricCoefficients {\n return {\n intercept: 0,\n optimistic: 0.5,\n pessimistic: 0.5,\n };\n }\n\n /**\n * Low priority image nodes are usually offscreen and very unlikely to be the\n * resource that is required for LCP. Our LCP graphs include everything except for these images.\n */\n static isNotLowPriorityImageNode(node: Graph.Node): boolean {\n if (node.type !== 'network') {\n return true;\n }\n const isImage = node.request.resourceType === 'Image';\n const isLowPriority = node.request.priority === 'Low' || node.request.priority === 'VeryLow';\n return !isImage || !isLowPriority;\n }\n\n /**\n * Finds the NetworkNode corresponding to the LCP image in the dependency graph, if LCP was an image.\n */\n static findLcpNode(dependencyGraph: Graph.Node,\n processedNavigation: Types.Simulation.ProcessedNavigation): Graph.NetworkNode|null {\n const lcp = processedNavigation.timestamps.largestContentfulPaint;\n if (!lcp) {\n return null;\n }\n\n const lcpEvent = processedNavigation.largestContentfulPaintEvt;\n if (lcpEvent?.args?.data?.type && lcpEvent.args.data.type !== 'image') {\n return null;\n }\n\n const {lcpRequestId, lcpImageUrl} = processedNavigation;\n if (!lcpRequestId && !lcpImageUrl) {\n return null;\n }\n\n if (lcpRequestId) {\n const idMatches: Graph.NetworkNode[] = [];\n dependencyGraph.traverse(node => {\n if (node.type !== 'network' || node.request.redirectDestination) {\n return;\n }\n if (node.request.finished === false || node.endTime < 0 || node.startTime > lcp) {\n return;\n }\n const baseRequestId = node.request.requestId.replace(/(:redirect|:duplicate)+$/, '');\n if (baseRequestId === lcpRequestId) {\n idMatches.push(node);\n }\n });\n if (idMatches.length) {\n idMatches.sort((a, b) => a.endTime - b.endTime);\n return idMatches[0];\n }\n }\n\n if (!lcpImageUrl) {\n return null;\n }\n\n const normalizedLcpUrl = stripUrlHash(lcpImageUrl);\n const lcpFrameId = lcpEvent?.args?.frame;\n const urlMatches: Graph.NetworkNode[] = [];\n dependencyGraph.traverse(node => {\n if (node.type !== 'network' || node.request.redirectDestination) {\n return;\n }\n if (node.request.finished === false || node.endTime < 0 || node.startTime > lcp) {\n return;\n }\n if (lcpFrameId && node.request.frameId && node.request.frameId !== lcpFrameId) {\n return;\n }\n if (node.request.resourceType && node.request.resourceType !== 'Image' && node.request.resourceType !== 'Media') {\n return;\n }\n const matchesUrl = node.request.url === lcpImageUrl || stripUrlHash(node.request.url) === normalizedLcpUrl ||\n Boolean(node.request.redirects?.some(r => r.url === lcpImageUrl || stripUrlHash(r.url) === normalizedLcpUrl));\n if (matchesUrl) {\n urlMatches.push(node);\n }\n });\n\n if (!urlMatches.length) {\n return null;\n }\n urlMatches.sort((a, b) => a.endTime - b.endTime);\n return urlMatches[0];\n }\n\n static isSameFrameTextLcp(processedNavigation: Types.Simulation.ProcessedNavigation): boolean {\n const {firstContentfulPaint: fcp, largestContentfulPaint: lcp} = processedNavigation.timestamps;\n if (!lcp) {\n return false;\n }\n return Math.abs(lcp - fcp) <= SAME_FRAME_TIMESTAMP_TOLERANCE_US &&\n processedNavigation.largestContentfulPaintEvt?.args?.data?.type === 'text';\n }\n\n static override getOptimisticGraph(\n dependencyGraph: Graph.Node, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node {\n const lcp = processedNavigation.timestamps.largestContentfulPaint;\n if (!lcp) {\n throw new Core.LanternError('NO_LCP');\n }\n if (LargestContentfulPaint.isSameFrameTextLcp(processedNavigation)) {\n return FirstContentfulPaint.getOptimisticGraph(dependencyGraph, processedNavigation);\n }\n\n const lcpNode = LargestContentfulPaint.findLcpNode(dependencyGraph, processedNavigation);\n if (lcpNode) {\n const fcpOptimisticGraph = FirstContentfulPaint.getOptimisticGraph(dependencyGraph, processedNavigation);\n const criticalNodeIds = new Set<string>();\n fcpOptimisticGraph.traverse(node => criticalNodeIds.add(node.id));\n criticalNodeIds.add(lcpNode.id);\n\n // PageDependencyGraph.linkCPUNodes does not add CPUNode -> Image edges, so if the LCP image\n // has any Script dependencies (e.g. JS-injected hero image or JS-injected stylesheet),\n // include the CPU tasks that evaluated those scripts prior to the LCP request.\n const initiatorScriptUrls = new Set<string>();\n lcpNode.traverse(node => {\n if (node.type === 'network' && node.request.resourceType === 'Script') {\n initiatorScriptUrls.add(node.request.url);\n }\n }, node => node.getDependencies());\n\n if (initiatorScriptUrls.size) {\n dependencyGraph.traverse(node => {\n if (node.type !== 'cpu' || node.startTime > lcpNode.startTime) {\n return;\n }\n for (const url of node.getEvaluateScriptURLs()) {\n if (initiatorScriptUrls.has(url)) {\n criticalNodeIds.add(node.id);\n break;\n }\n }\n });\n }\n\n return dependencyGraph.cloneWithRelationships(node => criticalNodeIds.has(node.id));\n }\n\n return FirstContentfulPaint.getFirstPaintBasedGraph(dependencyGraph, {\n cutoffTimestamp: lcp,\n treatNodeAsRenderBlocking: LargestContentfulPaint.isNotLowPriorityImageNode,\n });\n }\n\n static override getPessimisticGraph(\n dependencyGraph: Graph.Node, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node {\n const lcp = processedNavigation.timestamps.largestContentfulPaint;\n if (!lcp) {\n throw new Core.LanternError('NO_LCP');\n }\n if (LargestContentfulPaint.isSameFrameTextLcp(processedNavigation)) {\n return FirstContentfulPaint.getPessimisticGraph(dependencyGraph, processedNavigation);\n }\n\n return FirstContentfulPaint.getFirstPaintBasedGraph(dependencyGraph, {\n cutoffTimestamp: lcp,\n treatNodeAsRenderBlocking: _ => true,\n // For pessimistic LCP we'll include *all* layout nodes\n additionalCpuNodesToTreatAsRenderBlocking: node => node.didPerformLayout(),\n });\n }\n\n static override getEstimateFromSimulation(simulationResult: Simulation.Result, extras?: Extras): Simulation.Result {\n if (extras?.optimistic) {\n return simulationResult;\n }\n\n const nodeTimesNotOffscreenImages = Array.from(simulationResult.nodeTimings.entries())\n .filter(entry => LargestContentfulPaint.isNotLowPriorityImageNode(entry[0]))\n .map(entry => entry[1].endTime);\n\n return {\n timeInMs: Math.max(...nodeTimesNotOffscreenImages),\n nodeTimings: simulationResult.nodeTimings,\n };\n }\n\n static override compute(data: MetricComputationDataInput, extras?: Omit<Extras, 'optimistic'>): MetricResult {\n const fcpResult = extras?.fcpResult;\n if (!fcpResult) {\n throw new Core.LanternError('FCP is required to calculate the LCP metric');\n }\n\n const metricResult = super.compute(data, extras);\n metricResult.timing = Math.max(metricResult.timing, fcpResult.timing);\n return metricResult;\n }\n}\n\nexport {LargestContentfulPaint};\n"]}
|
|
@@ -73,6 +73,10 @@ declare class Simulator<T = Lantern.AnyNetworkObject> {
|
|
|
73
73
|
label?: string;
|
|
74
74
|
}): Result<T>;
|
|
75
75
|
computeWastedMsFromWastedBytes(wastedBytes: number): number;
|
|
76
|
+
/**
|
|
77
|
+
* Lighthouse's asset-saver reads this map. TraceProcessor clears it after
|
|
78
|
+
* every parse and on reset() so it does not retain the Lantern dependency graph.
|
|
79
|
+
*/
|
|
76
80
|
static get allNodeTimings(): Map<string, Map<Graph.Node, CompleteNodeTiming>>;
|
|
77
81
|
/**
|
|
78
82
|
* We attempt to start nodes by their observed start time using the request priority as a tie breaker.
|
|
@@ -210,6 +210,9 @@ class Simulator {
|
|
|
210
210
|
if (!connection) {
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
|
+
if (this.nodeTimings.getQueued(node).queuedTime === totalElapsedTime) {
|
|
214
|
+
connection.setH2OverflowBytesDownloaded(0);
|
|
215
|
+
}
|
|
213
216
|
}
|
|
214
217
|
this.markNodeAsInProgress(node, totalElapsedTime);
|
|
215
218
|
}
|
|
@@ -348,6 +351,7 @@ class Simulator {
|
|
|
348
351
|
{
|
|
349
352
|
startTime: timing.startTime,
|
|
350
353
|
endTime: timing.endTime,
|
|
354
|
+
queuedTime: timing.queuedTime,
|
|
351
355
|
duration: timing.endTime - timing.startTime,
|
|
352
356
|
},
|
|
353
357
|
];
|
|
@@ -437,7 +441,10 @@ class Simulator {
|
|
|
437
441
|
// This is an estimate of wasted time, so we won't be more precise than 10ms.
|
|
438
442
|
return Math.round(wastedMs / 10) * 10;
|
|
439
443
|
}
|
|
440
|
-
|
|
444
|
+
/**
|
|
445
|
+
* Lighthouse's asset-saver reads this map. TraceProcessor clears it after
|
|
446
|
+
* every parse and on reset() so it does not retain the Lantern dependency graph.
|
|
447
|
+
*/
|
|
441
448
|
static get allNodeTimings() {
|
|
442
449
|
return ALL_SIMULATION_NODE_TIMINGS;
|
|
443
450
|
}
|