@paulirish/trace_engine 0.0.61 → 0.0.62
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/analyze-trace.d.mts.map +1 -1
- package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
- package/analyze-inspector-issues.mjs +1 -1
- package/analyze-trace.mjs +1 -2
- package/core/platform/ArrayUtilities.d.ts +2 -0
- package/core/platform/ArrayUtilities.js +11 -1
- package/core/platform/ArrayUtilities.js.map +1 -1
- package/core/platform/HostRuntime.d.ts +4 -0
- package/core/platform/HostRuntime.js +25 -0
- package/core/platform/HostRuntime.js.map +1 -0
- package/core/platform/KeyboardUtilities.d.ts +6 -2
- package/core/platform/KeyboardUtilities.js.map +1 -1
- package/core/platform/StringUtilities.d.ts +2 -0
- package/core/platform/StringUtilities.js +64 -13
- package/core/platform/StringUtilities.js.map +1 -1
- package/core/platform/api/HostRuntime.d.ts +36 -0
- package/core/platform/api/HostRuntime.js +5 -0
- package/core/platform/api/HostRuntime.js.map +1 -0
- package/core/platform/api/api-tsconfig.json +43 -0
- package/core/platform/api/api.d.ts +2 -0
- package/core/platform/api/api.js +6 -0
- package/core/platform/api/api.js.map +1 -0
- package/core/platform/api/api_node_typecheck-tsconfig.json +48 -0
- package/core/platform/api/bundle-tsconfig.json +1 -0
- package/core/platform/api/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
- package/core/platform/browser/HostRuntime.d.ts +2 -0
- package/core/platform/browser/HostRuntime.js +64 -0
- package/core/platform/browser/HostRuntime.js.map +1 -0
- package/core/platform/browser/browser-tsconfig.json +48 -0
- package/core/platform/browser/browser.d.ts +2 -0
- package/core/platform/browser/browser.js +6 -0
- package/core/platform/browser/browser.js.map +1 -0
- package/core/platform/browser/bundle-tsconfig.json +1 -0
- package/core/platform/browser/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
- package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/core/platform/node/HostRuntime.d.ts +2 -0
- package/core/platform/node/HostRuntime.js +73 -0
- package/core/platform/node/HostRuntime.js.map +1 -0
- package/core/platform/node/bundle-tsconfig.json +1 -0
- package/core/platform/node/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
- package/core/platform/node/node-tsconfig.json +52 -0
- package/core/platform/node/node.d.ts +2 -0
- package/core/platform/node/node.js +6 -0
- package/core/platform/node/node.js.map +1 -0
- package/core/platform/platform-tsconfig.json +17 -5
- package/core/platform/platform.d.ts +2 -2
- package/core/platform/platform.js +2 -2
- package/core/platform/platform.js.map +1 -1
- package/core/platform/platform_node_typecheck-tsconfig.json +74 -0
- package/generated/protocol.d.ts +1507 -583
- package/locales/af.json +74 -38
- package/locales/am.json +73 -37
- package/locales/ar.json +72 -36
- package/locales/as.json +74 -38
- package/locales/az.json +73 -37
- package/locales/be.json +72 -36
- package/locales/bg.json +72 -36
- package/locales/bn.json +74 -38
- package/locales/bs.json +72 -36
- package/locales/ca.json +72 -36
- package/locales/cs.json +72 -36
- package/locales/cy.json +73 -37
- package/locales/da.json +74 -38
- package/locales/de.json +72 -36
- package/locales/el.json +73 -37
- package/locales/en-GB.json +74 -38
- package/locales/en-US.json +86 -17
- package/locales/en-XL.json +86 -17
- package/locales/es-419.json +72 -36
- package/locales/es.json +73 -37
- package/locales/et.json +74 -38
- package/locales/eu.json +72 -36
- package/locales/fa.json +73 -37
- package/locales/fi.json +72 -36
- package/locales/fil.json +74 -38
- package/locales/fr-CA.json +72 -36
- package/locales/fr.json +162 -126
- package/locales/gl.json +73 -37
- package/locales/gu.json +73 -37
- package/locales/he.json +74 -38
- package/locales/hi.json +73 -37
- package/locales/hr.json +72 -36
- package/locales/hu.json +73 -37
- package/locales/hy.json +73 -37
- package/locales/id.json +74 -38
- package/locales/is.json +73 -37
- package/locales/it.json +72 -36
- package/locales/ja.json +72 -36
- package/locales/ka.json +73 -37
- package/locales/kk.json +72 -36
- package/locales/km.json +73 -37
- package/locales/kn.json +72 -36
- package/locales/ko.json +72 -36
- package/locales/ky.json +72 -36
- package/locales/lo.json +72 -36
- package/locales/lt.json +72 -36
- package/locales/lv.json +72 -36
- package/locales/mk.json +75 -39
- package/locales/ml.json +72 -36
- package/locales/mn.json +73 -37
- package/locales/mr.json +74 -38
- package/locales/ms.json +72 -36
- package/locales/my.json +72 -36
- package/locales/ne.json +73 -37
- package/locales/nl.json +73 -37
- package/locales/no.json +72 -36
- package/locales/or.json +72 -36
- package/locales/pa.json +72 -36
- package/locales/pl.json +72 -36
- package/locales/pt-PT.json +72 -36
- package/locales/pt.json +74 -38
- package/locales/ro.json +72 -36
- package/locales/ru.json +72 -36
- package/locales/si.json +72 -36
- package/locales/sk.json +72 -36
- package/locales/sl.json +72 -36
- package/locales/sq.json +72 -36
- package/locales/sr-Latn.json +73 -37
- package/locales/sr.json +73 -37
- package/locales/sv.json +75 -39
- package/locales/sw.json +74 -38
- package/locales/ta.json +73 -37
- package/locales/te.json +72 -36
- package/locales/th.json +73 -37
- package/locales/tr.json +72 -36
- package/locales/uk.json +72 -36
- package/locales/ur.json +72 -36
- package/locales/uz.json +73 -37
- package/locales/vi.json +74 -38
- package/locales/zh-HK.json +72 -36
- package/locales/zh-TW.json +74 -38
- package/locales/zh.json +75 -39
- package/locales/zu.json +73 -37
- package/models/cpu_profile/CPUProfileDataModel.d.ts +9 -0
- package/models/cpu_profile/CPUProfileDataModel.js +9 -7
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
- package/models/cpu_profile/ProfileTreeModel.d.ts +3 -2
- package/models/cpu_profile/ProfileTreeModel.js +6 -7
- package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
- package/models/cpu_profile/cpu_profile-tsconfig.json +4 -3
- package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/EntityMapper.d.ts +1 -0
- package/models/trace/EntityMapper.js +10 -0
- package/models/trace/EntityMapper.js.map +1 -1
- package/models/trace/EventsSerializer.js +10 -2
- package/models/trace/EventsSerializer.js.map +1 -1
- package/models/trace/LanternComputationData.d.ts +1 -1
- package/models/trace/LanternComputationData.js +3 -8
- package/models/trace/LanternComputationData.js.map +1 -1
- package/models/trace/ModelImpl.d.ts +1 -0
- package/models/trace/ModelImpl.js +9 -6
- package/models/trace/ModelImpl.js.map +1 -1
- package/models/trace/Processor.js +23 -23
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/Styles.js +13 -5
- package/models/trace/Styles.js.map +1 -1
- package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/extras/Initiators.d.ts +12 -0
- package/models/trace/extras/Initiators.js +47 -0
- package/models/trace/extras/Initiators.js.map +1 -0
- package/models/trace/extras/TraceTree.js +13 -5
- package/models/trace/extras/TraceTree.js.map +1 -1
- package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/extras/extras-tsconfig.json +11 -3
- package/models/trace/extras/extras.d.ts +0 -1
- package/models/trace/extras/extras.js +0 -1
- package/models/trace/extras/extras.js.map +1 -1
- package/models/trace/handlers/LargestImagePaintHandler.js +2 -2
- package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.js +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
- package/models/trace/handlers/MetaHandler.d.ts +12 -1
- package/models/trace/handlers/MetaHandler.js +10 -1
- package/models/trace/handlers/MetaHandler.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.d.ts +8 -1
- package/models/trace/handlers/NetworkRequestsHandler.js +22 -4
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/PageLoadMetricsHandler.d.ts +13 -3
- package/models/trace/handlers/PageLoadMetricsHandler.js +71 -27
- package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
- package/models/trace/handlers/SamplesHandler.js +59 -6
- package/models/trace/handlers/SamplesHandler.js.map +1 -1
- package/models/trace/handlers/ScriptsHandler.js +24 -0
- package/models/trace/handlers/ScriptsHandler.js.map +1 -1
- package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/handlers/handlers-tsconfig.json +13 -3
- package/models/trace/helpers/Network.js +1 -1
- package/models/trace/helpers/Network.js.map +1 -1
- package/models/trace/helpers/SamplesIntegrator.js +1 -8
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
- package/models/trace/helpers/Timing.d.ts +1 -1
- package/models/trace/helpers/Timing.js +9 -2
- package/models/trace/helpers/Timing.js.map +1 -1
- package/models/trace/helpers/Trace.d.ts +1 -0
- package/models/trace/helpers/Trace.js +12 -5
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/helpers/helpers-tsconfig.json +7 -3
- package/models/trace/insights/CharacterSet.d.ts +49 -0
- package/models/trace/insights/CharacterSet.js +132 -0
- package/models/trace/insights/CharacterSet.js.map +1 -0
- package/models/trace/insights/Common.d.ts +2 -2
- package/models/trace/insights/Common.js +1 -6
- package/models/trace/insights/Common.js.map +1 -1
- package/models/trace/insights/ForcedReflow.d.ts +1 -1
- package/models/trace/insights/ForcedReflow.js +1 -1
- package/models/trace/insights/ForcedReflow.js.map +1 -1
- package/models/trace/insights/LCPBreakdown.d.ts +1 -1
- package/models/trace/insights/LCPBreakdown.js +2 -2
- package/models/trace/insights/LCPBreakdown.js.map +1 -1
- package/models/trace/insights/LCPDiscovery.d.ts +7 -3
- package/models/trace/insights/LCPDiscovery.js +16 -10
- package/models/trace/insights/LCPDiscovery.js.map +1 -1
- package/models/trace/insights/Models.d.ts +1 -0
- package/models/trace/insights/Models.js +1 -0
- package/models/trace/insights/Models.js.map +1 -1
- package/models/trace/insights/NetworkDependencyTree.js +4 -3
- package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
- package/models/trace/insights/RenderBlocking.d.ts +2 -2
- package/models/trace/insights/RenderBlocking.js +6 -6
- package/models/trace/insights/RenderBlocking.js.map +1 -1
- package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/insights/insights-tsconfig.json +26 -3
- package/models/trace/insights/types.d.ts +15 -5
- package/models/trace/insights/types.js +1 -0
- package/models/trace/insights/types.js.map +1 -1
- package/models/trace/lantern/core/core-tsconfig.json +4 -3
- package/models/trace/lantern/core/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/graph/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/graph/graph-tsconfig.json +4 -3
- package/models/trace/lantern/lantern-tsconfig.json +4 -3
- package/models/trace/lantern/metrics/FirstContentfulPaint.js +6 -6
- package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +1 -1
- package/models/trace/lantern/metrics/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/metrics/metrics-tsconfig.json +4 -3
- package/models/trace/lantern/simulation/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/simulation/simulation-tsconfig.json +4 -3
- package/models/trace/lantern/types/Lantern.d.ts +7 -7
- package/models/trace/lantern/types/Lantern.js.map +1 -1
- package/models/trace/lantern/types/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/types/types-tsconfig.json +4 -3
- package/models/trace/trace-tsconfig.json +7 -3
- package/models/trace/types/Configuration.d.ts +1 -4
- package/models/trace/types/Configuration.js +0 -1
- package/models/trace/types/Configuration.js.map +1 -1
- package/models/trace/types/File.d.ts +8 -0
- package/models/trace/types/File.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +97 -15
- package/models/trace/types/TraceEvents.js +44 -11
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/types/types-tsconfig.json +10 -3
- package/package.json +1 -1
- package/test/test-trace-engine.mjs +8 -9
- package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts +0 -4
- package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts.map +0 -1
- package/core/platform/DOMUtilities.d.ts +0 -16
- package/core/platform/DOMUtilities.js +0 -123
- package/core/platform/DOMUtilities.js.map +0 -1
|
@@ -5,7 +5,7 @@ export declare const UIStrings: {
|
|
|
5
5
|
/**
|
|
6
6
|
* @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.
|
|
7
7
|
*/
|
|
8
|
-
readonly title: "Render
|
|
8
|
+
readonly title: "Render-blocking requests";
|
|
9
9
|
/**
|
|
10
10
|
* @description Text to describe that there are requests blocking rendering, which may affect LCP.
|
|
11
11
|
*/
|
|
@@ -21,7 +21,7 @@ export declare const UIStrings: {
|
|
|
21
21
|
/**
|
|
22
22
|
* @description Text status indicating that no requests blocked the initial render of a navigation
|
|
23
23
|
*/
|
|
24
|
-
readonly noRenderBlocking: "No render
|
|
24
|
+
readonly noRenderBlocking: "No render-blocking requests for this navigation";
|
|
25
25
|
};
|
|
26
26
|
export declare const i18nString: (id: string, values?: Record<string, string> | undefined) => Record<string, string>;
|
|
27
27
|
export declare function isRenderBlockingInsight(insight: InsightModel): insight is RenderBlockingInsightModel;
|
|
@@ -9,7 +9,7 @@ export const UIStrings = {
|
|
|
9
9
|
/**
|
|
10
10
|
* @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.
|
|
11
11
|
*/
|
|
12
|
-
title: 'Render
|
|
12
|
+
title: 'Render-blocking requests',
|
|
13
13
|
/**
|
|
14
14
|
* @description Text to describe that there are requests blocking rendering, which may affect LCP.
|
|
15
15
|
*/
|
|
@@ -27,7 +27,7 @@ export const UIStrings = {
|
|
|
27
27
|
/**
|
|
28
28
|
* @description Text status indicating that no requests blocked the initial render of a navigation
|
|
29
29
|
*/
|
|
30
|
-
noRenderBlocking: 'No render
|
|
30
|
+
noRenderBlocking: 'No render-blocking requests for this navigation',
|
|
31
31
|
};
|
|
32
32
|
// const str_ = i18n.i18n.registerUIStrings('models/trace/insights/RenderBlocking.ts', UIStrings);
|
|
33
33
|
export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
@@ -104,7 +104,7 @@ function computeSavings(data, context, renderBlockingRequests) {
|
|
|
104
104
|
}
|
|
105
105
|
if (requestIdToWastedMs.size) {
|
|
106
106
|
metricSavings.FCP = estimateSavingsWithGraphs(deferredNodeIds, context.lantern);
|
|
107
|
-
// In most cases, render
|
|
107
|
+
// In most cases, render-blocking resources only affect LCP if LCP isn't an image.
|
|
108
108
|
if (!hasImageLCP(data, context)) {
|
|
109
109
|
metricSavings.LCP = metricSavings.FCP;
|
|
110
110
|
}
|
|
@@ -130,7 +130,7 @@ export function generateInsight(data, context) {
|
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
const firstPaintTs = data.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)
|
|
133
|
-
?.get(context.
|
|
133
|
+
?.get(context.navigation)
|
|
134
134
|
?.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP)
|
|
135
135
|
?.event?.ts;
|
|
136
136
|
if (!firstPaintTs) {
|
|
@@ -150,12 +150,12 @@ export function generateInsight(data, context) {
|
|
|
150
150
|
if (req.args.data.syntheticData.finishTime > firstPaintTs) {
|
|
151
151
|
continue;
|
|
152
152
|
}
|
|
153
|
-
// If a request is marked `in_body_parser_blocking` it should only be considered render
|
|
153
|
+
// If a request is marked `in_body_parser_blocking` it should only be considered render-blocking if it is a
|
|
154
154
|
// high enough priority. Some requests (e.g. scripts) are not marked as high priority if they are fetched
|
|
155
155
|
// after a non-preloaded image. (See "early" definition in https://web.dev/articles/fetch-priority)
|
|
156
156
|
//
|
|
157
157
|
// There are edge cases and exceptions (e.g. priority hints) but this gives us the best approximation
|
|
158
|
-
// of render
|
|
158
|
+
// of render-blocking resources in the document body.
|
|
159
159
|
if (req.args.data.renderBlocking === 'in_body_parser_blocking') {
|
|
160
160
|
const priority = req.args.data.priority;
|
|
161
161
|
const isScript = req.args.data.resourceType === "Script" /* Protocol.Network.ResourceType.Script */;
|
|
@@ -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,EAAE,yEAAyE;QAClF,kGAAkG;QAClG,2DAA2D;IAC/D;;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,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAE7E,MAAM,UAAU,uBAAuB,CAAC,OAAqB;IAC3D,OAAO,OAAO,CAAC,UAAU,KAAK,gBAAgB,CAAC;AACjD,CAAC;AAOD,2EAA2E;AAC3E,kGAAkG;AAClG,4FAA4F;AAC5F,qEAAqE;AACrE,MAA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ACd,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: 'Requests are blocking the page\\'s initial render, which may delay LCP. ' +\n '[Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) ' +\n '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.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.Node, nodeTiming: Lantern.Types.Simulation.NodeTiming}> {\n const requestIdToNode =\n new Map<string, {node: Lantern.Graph.Node, nodeTiming: Lantern.Types.Simulation.NodeTiming}>();\n\n for (const [node, nodeTiming] of nodeTimings) {\n if (node.type !== 'network') {\n continue;\n }\n\n requestIdToNode.set(node.request.requestId, {node, nodeTiming});\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 and all its dependents as deferrable\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(node.id, 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) {\n return finalize({\n renderBlockingRequests: [],\n });\n }\n\n const firstPaintTs = data.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)\n ?.get(context.navigationId)\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,EAAE,yEAAyE;QAClF,kGAAkG;QAClG,2DAA2D;IAC/D;;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,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,C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AAC,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: 'Requests are blocking the page\\'s initial render, which may delay LCP. ' +\n '[Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) ' +\n '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.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.Node, nodeTiming: Lantern.Types.Simulation.NodeTiming}> {\n const requestIdToNode =\n new Map<string, {node: Lantern.Graph.Node, nodeTiming: Lantern.Types.Simulation.NodeTiming}>();\n\n for (const [node, nodeTiming] of nodeTimings) {\n if (node.type !== 'network') {\n continue;\n }\n\n requestIdToNode.set(node.request.requestId, {node, nodeTiming});\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 and all its dependents as deferrable\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(node.id, 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) {\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"]}
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "devtools_entrypoint-bundle-typescript-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,11 +31,13 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "insights-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
37
38
|
"../../../../../../../front_end/models/trace/insights/CLSCulprits.ts",
|
|
38
39
|
"../../../../../../../front_end/models/trace/insights/Cache.ts",
|
|
40
|
+
"../../../../../../../front_end/models/trace/insights/CharacterSet.ts",
|
|
39
41
|
"../../../../../../../front_end/models/trace/insights/Common.ts",
|
|
40
42
|
"../../../../../../../front_end/models/trace/insights/DOMSize.ts",
|
|
41
43
|
"../../../../../../../front_end/models/trace/insights/DocumentLatency.ts",
|
|
@@ -61,20 +63,41 @@
|
|
|
61
63
|
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
|
|
62
64
|
],
|
|
63
65
|
"references": [
|
|
66
|
+
{
|
|
67
|
+
"path": "../../../core/common/bundle-tsconfig.json"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"path": "../../../core/i18n/bundle-tsconfig.json"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"path": "../../../core/platform/bundle-tsconfig.json"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"path": "../../../generated/protocol-tsconfig.json"
|
|
77
|
+
},
|
|
64
78
|
{
|
|
65
79
|
"path": "../../../third_party/legacy-javascript/bundle-tsconfig.json"
|
|
66
80
|
},
|
|
67
81
|
{
|
|
68
82
|
"path": "../../../third_party/third-party-web/bundle-tsconfig.json"
|
|
69
83
|
},
|
|
84
|
+
{
|
|
85
|
+
"path": "../../crux-manager/bundle-tsconfig.json"
|
|
86
|
+
},
|
|
70
87
|
{
|
|
71
88
|
"path": "../extras/bundle-tsconfig.json"
|
|
72
89
|
},
|
|
73
90
|
{
|
|
74
91
|
"path": "../handlers/bundle-tsconfig.json"
|
|
75
92
|
},
|
|
93
|
+
{
|
|
94
|
+
"path": "../helpers/bundle-tsconfig.json"
|
|
95
|
+
},
|
|
76
96
|
{
|
|
77
97
|
"path": "../lantern/bundle-tsconfig.json"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"path": "../types/bundle-tsconfig.json"
|
|
78
101
|
}
|
|
79
102
|
]
|
|
80
103
|
}
|
|
@@ -78,7 +78,7 @@ export type InsightModel<UIStrings extends Record<string, string> = Record<strin
|
|
|
78
78
|
/**
|
|
79
79
|
* If this insight is attached to a navigation, this stores its ID.
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
navigation?: Types.Events.NavigationStart;
|
|
82
82
|
/** This is lazily-generated because some insights may create many overlays. */
|
|
83
83
|
createOverlays?: () => Types.Overlays.Overlay[];
|
|
84
84
|
};
|
|
@@ -89,20 +89,29 @@ export type PartialInsightModel<T> = Omit<T, 'strings' | 'title' | 'description'
|
|
|
89
89
|
* navigation (or the end of the trace).
|
|
90
90
|
*/
|
|
91
91
|
export interface InsightSet {
|
|
92
|
-
/** If for a navigation, this is the
|
|
92
|
+
/** If for a navigation, this is of the form "NAVIGATION_(index)". Else it is Trace.Types.Events.NO_NAVIGATION. */
|
|
93
93
|
id: Types.Events.NavigationId;
|
|
94
94
|
/** The URL to show in the accordion list. */
|
|
95
95
|
url: URL;
|
|
96
96
|
frameId: string;
|
|
97
97
|
bounds: Types.Timing.TraceWindowMicro;
|
|
98
|
+
/** Contains results for all non-errored insights. */
|
|
98
99
|
model: InsightModels;
|
|
100
|
+
/** Contains errors for all insights that had an internal error. */
|
|
101
|
+
modelErrors: InsightModelErrors;
|
|
99
102
|
navigation?: Types.Events.NavigationStart;
|
|
100
103
|
}
|
|
101
104
|
/**
|
|
102
|
-
* Contains insights for a specific insight set.
|
|
105
|
+
* Contains insights for a specific insight set. If missing, it error'd.
|
|
103
106
|
*/
|
|
104
107
|
export type InsightModels = {
|
|
105
|
-
[I in keyof InsightModelsType]
|
|
108
|
+
[I in keyof InsightModelsType]?: ReturnType<InsightModelsType[I]['generateInsight']>;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Contains an internal error for each insight in a specific insight set.
|
|
112
|
+
*/
|
|
113
|
+
export type InsightModelErrors = {
|
|
114
|
+
[I in keyof InsightModelsType]?: Error;
|
|
106
115
|
};
|
|
107
116
|
/**
|
|
108
117
|
* Contains insights for the entire trace. Insights are mostly grouped by `navigationId`, with one exception:
|
|
@@ -129,5 +138,6 @@ export declare enum InsightKeys {
|
|
|
129
138
|
SLOW_CSS_SELECTOR = "SlowCSSSelector",
|
|
130
139
|
VIEWPORT = "Viewport",
|
|
131
140
|
MODERN_HTTP = "ModernHTTP",
|
|
132
|
-
CACHE = "Cache"
|
|
141
|
+
CACHE = "Cache",
|
|
142
|
+
CHARACTER_SET = "CharacterSet"
|
|
133
143
|
}
|
|
@@ -36,5 +36,6 @@ export var InsightKeys;
|
|
|
36
36
|
InsightKeys["VIEWPORT"] = "Viewport";
|
|
37
37
|
InsightKeys["MODERN_HTTP"] = "ModernHTTP";
|
|
38
38
|
InsightKeys["CACHE"] = "Cache";
|
|
39
|
+
InsightKeys["CHARACTER_SET"] = "CharacterSet";
|
|
39
40
|
})(InsightKeys || (InsightKeys = {}));
|
|
40
41
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAsC7B,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,uEAAuE;IACvE,6DAA2C,CAAA;IAC3C,yCAAuB,CAAA;AACzB,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAYD,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;AACb,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAsC7B,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,uEAAuE;IACvE,6DAA2C,CAAA;IAC3C,yCAAuB,CAAA;AACzB,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAYD,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;AACb,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAoFD,MAAM,CAAN,IAAY,WAoBX;AApBD,WAAY,WAAW;IACrB,6CAA8B,CAAA;IAC9B,6CAA8B,CAAA;IAC9B,2CAA4B,CAAA;IAC5B,6CAA8B,CAAA;IAC9B,mDAAoC,CAAA;IACpC,mCAAoB,CAAA;IACpB,4DAA6C,CAAA;IAC7C,2CAA4B,CAAA;IAC5B,6CAA8B,CAAA;IAC9B,+CAAgC,CAAA;IAChC,6CAA8B,CAAA;IAC9B,qDAAsC,CAAA;IACtC,gEAAiD,CAAA;IACjD,iDAAkC,CAAA;IAClC,oDAAqC,CAAA;IACrC,oCAAqB,CAAA;IACrB,yCAA0B,CAAA;IAC1B,8BAAe,CAAA;IACf,6CAA8B,CAAA;AAChC,CAAC,EApBW,WAAW,KAAX,WAAW,QAoBtB","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 type * as Common from '../../../core/common/common.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport type * as Models from './Models.js';\n\n/**\n * Context for the portion of the trace an insight should look at.\n */\nexport type InsightSetContext = InsightSetContextWithoutNavigation|InsightSetContextWithNavigation;\n\nexport interface InsightSetContextWithoutNavigation {\n options: Types.Configuration.ParseOptions;\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation?: never;\n}\n\nexport interface InsightSetContextWithNavigation {\n options: Types.Configuration.ParseOptions;\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation: Types.Events.NavigationStart;\n navigationId: string;\n lantern?: LanternContext;\n}\n\nexport interface LanternContext {\n requests: Array<Lantern.Types.NetworkRequest<Types.Events.SyntheticNetworkRequest>>;\n graph: Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>;\n simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest>;\n metrics: Record<string, Lantern.Metrics.MetricResult>;\n}\n\nexport type InsightModelsType = typeof Models;\n\nexport enum InsightWarning {\n NO_FP = 'NO_FP',\n NO_LCP = 'NO_LCP',\n // No network request could be identified as the primary HTML document.\n NO_DOCUMENT_REQUEST = 'NO_DOCUMENT_REQUEST',\n NO_LAYOUT = 'NO_LAYOUT',\n}\n\nexport interface MetricSavings {\n /* eslint-disable @typescript-eslint/naming-convention */\n FCP?: Types.Timing.Milli;\n LCP?: Types.Timing.Milli;\n TBT?: Types.Timing.Milli;\n CLS?: number;\n INP?: Types.Timing.Milli;\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nexport enum InsightCategory {\n ALL = 'All',\n INP = 'INP',\n LCP = 'LCP',\n CLS = 'CLS',\n}\n\nexport type RelatedEventsMap = Map<Types.Events.Event, string[]>;\n\nexport type Checklist<Keys extends string> = Record<Keys, {label: Common.UIString.LocalizedString, value: boolean}>;\n\nexport type InsightModel<UIStrings extends Record<string, string> = Record<string, string>,\n ExtraDetail extends Record<string, unknown> = Record<string, unknown>> =\n ExtraDetail&{\n /** Used internally to identify the type of a model, not shown visibly to users **/\n insightKey: keyof InsightModelsType,\n /** Not used within DevTools - this is for external consumers (like Lighthouse). */\n strings: UIStrings,\n title: Common.UIString.LocalizedString,\n description: Common.UIString.LocalizedString,\n docs: string,\n category: InsightCategory,\n state: 'pass' | 'fail' | 'informative',\n /** Used by RelatedInsightChips.ts */\n relatedEvents?: RelatedEventsMap | Types.Events.Event[],\n warnings?: InsightWarning[],\n metricSavings?: MetricSavings,\n /**\n * An estimate for the number of bytes that this insight deems to have been wasted.\n * Bytes are in terms of transfer size: for each component of savings related to an\n * individual request, the insight will estimate its impact on transfer size by using\n * the compression ratio of the resource.\n *\n * This field is only displayed for informational purposes.\n */\n wastedBytes?: number,\n frameId?: string,\n /**\n * If this insight is attached to a navigation, this stores its ID.\n */\n navigation?: Types.Events.NavigationStart,\n /** This is lazily-generated because some insights may create many overlays. */\n createOverlays?: () => Types.Overlays.Overlay[],\n };\n\nexport type PartialInsightModel<T> =\n Omit<T, 'strings'|'title'|'description'|'docs'|'category'|'state'|'insightKey'|'navigationId'|'frameId'>;\n\n/**\n * Contains insights for a specific navigation. If a trace began after a navigation already started,\n * this could instead represent the duration from the beginning of the trace up to the first recorded\n * navigation (or the end of the trace).\n */\nexport interface InsightSet {\n /** If for a navigation, this is of the form \"NAVIGATION_(index)\". Else it is Trace.Types.Events.NO_NAVIGATION. */\n id: Types.Events.NavigationId;\n /** The URL to show in the accordion list. */\n url: URL;\n frameId: string;\n bounds: Types.Timing.TraceWindowMicro;\n /** Contains results for all non-errored insights. */\n model: InsightModels;\n /** Contains errors for all insights that had an internal error. */\n modelErrors: InsightModelErrors;\n navigation?: Types.Events.NavigationStart;\n}\n\n/**\n * Contains insights for a specific insight set. If missing, it error'd.\n */\nexport type InsightModels = {\n [I in keyof InsightModelsType]?: ReturnType<InsightModelsType[I]['generateInsight']>;\n};\n\n/**\n * Contains an internal error for each insight in a specific insight set.\n */\nexport type InsightModelErrors = {\n [I in keyof InsightModelsType]?: Error;\n};\n\n/**\n * Contains insights for the entire trace. Insights are mostly grouped by `navigationId`, with one exception:\n *\n * If the analyzed trace started after the navigation, and has meaningful work with that span, there is no\n * navigation to map it to. In this case `Types.Events.NO_NAVIGATION` is used for the key.\n */\nexport type TraceInsightSets = Map<Types.Events.NavigationId, InsightSet>;\n\nexport enum InsightKeys {\n LCP_BREAKDOWN = 'LCPBreakdown',\n INP_BREAKDOWN = 'INPBreakdown',\n CLS_CULPRITS = 'CLSCulprits',\n THIRD_PARTIES = 'ThirdParties',\n DOCUMENT_LATENCY = 'DocumentLatency',\n DOM_SIZE = 'DOMSize',\n DUPLICATE_JAVASCRIPT = 'DuplicatedJavaScript',\n FONT_DISPLAY = 'FontDisplay',\n FORCED_REFLOW = 'ForcedReflow',\n IMAGE_DELIVERY = 'ImageDelivery',\n LCP_DISCOVERY = 'LCPDiscovery',\n LEGACY_JAVASCRIPT = 'LegacyJavaScript',\n NETWORK_DEPENDENCY_TREE = 'NetworkDependencyTree',\n RENDER_BLOCKING = 'RenderBlocking',\n SLOW_CSS_SELECTOR = 'SlowCSSSelector',\n VIEWPORT = 'Viewport',\n MODERN_HTTP = 'ModernHTTP',\n CACHE = 'Cache',\n CHARACTER_SET = 'CharacterSet',\n}\n"]}
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "core-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "devtools_entrypoint-bundle-typescript-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "devtools_entrypoint-bundle-typescript-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "devtools_entrypoint-bundle-typescript-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "graph-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "lantern-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -23,8 +23,8 @@ class FirstContentfulPaint extends Metric {
|
|
|
23
23
|
const cpuNodes = [];
|
|
24
24
|
graph.traverse(node => {
|
|
25
25
|
if (node.type === Graph.BaseNode.types.CPU) {
|
|
26
|
-
// A task is *possibly* render
|
|
27
|
-
// We use startTime here because the paint event can be *inside* the task that was render
|
|
26
|
+
// A task is *possibly* render-blocking if it *started* before cutoffTimestamp.
|
|
27
|
+
// We use startTime here because the paint event can be *inside* the task that was render-blocking.
|
|
28
28
|
if (node.startTime <= cutoffTimestamp) {
|
|
29
29
|
cpuNodes.push(node);
|
|
30
30
|
}
|
|
@@ -38,14 +38,14 @@ class FirstContentfulPaint extends Metric {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
cpuNodes.sort((a, b) => a.startTime - b.startTime);
|
|
41
|
-
// A script is *possibly* render
|
|
41
|
+
// A script is *possibly* render-blocking if it finished loading before cutoffTimestamp.
|
|
42
42
|
const possiblyRenderBlockingScriptUrls = Metric.getScriptUrls(graph, node => {
|
|
43
43
|
// The optimistic LCP treatNodeAsRenderBlocking fn wants to exclude some images in the graph,
|
|
44
44
|
// but here it only receives scripts to evaluate. It's a no-op in this case, but it will
|
|
45
45
|
// matter below in the getFirstPaintBasedGraph clone operation.
|
|
46
46
|
return node.endTime <= cutoffTimestamp && treatNodeAsRenderBlocking(node);
|
|
47
47
|
});
|
|
48
|
-
// A script is *definitely not* render
|
|
48
|
+
// A script is *definitely not* render-blocking if its EvaluateScript task started after cutoffTimestamp.
|
|
49
49
|
const definitelyNotRenderBlockingScriptUrls = new Set();
|
|
50
50
|
const renderBlockingCpuNodeIds = new Set();
|
|
51
51
|
for (const url of possiblyRenderBlockingScriptUrls) {
|
|
@@ -110,7 +110,7 @@ class FirstContentfulPaint extends Metric {
|
|
|
110
110
|
if (definitelyNotRenderBlockingScriptUrls.has(url)) {
|
|
111
111
|
return false;
|
|
112
112
|
}
|
|
113
|
-
// Lastly, build up the FCP graph of all nodes we consider render
|
|
113
|
+
// Lastly, build up the FCP graph of all nodes we consider render-blocking
|
|
114
114
|
return treatNodeAsRenderBlocking(node);
|
|
115
115
|
}
|
|
116
116
|
// If it's a CPU node, just check if it was blocking.
|
|
@@ -120,7 +120,7 @@ class FirstContentfulPaint extends Metric {
|
|
|
120
120
|
static getOptimisticGraph(dependencyGraph, processedNavigation) {
|
|
121
121
|
return this.getFirstPaintBasedGraph(dependencyGraph, {
|
|
122
122
|
cutoffTimestamp: processedNavigation.timestamps.firstContentfulPaint,
|
|
123
|
-
// In the optimistic graph we exclude resources that appeared to be render
|
|
123
|
+
// In the optimistic graph we exclude resources that appeared to be render-blocking but were
|
|
124
124
|
// initiated by a script. While they typically have a very high importance and tend to have a
|
|
125
125
|
// significant impact on the page's content, these resources don't technically block rendering.
|
|
126
126
|
treatNodeAsRenderBlocking: node => node.hasRenderBlockingPriority() && node.initiatorType !== 'script',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirstContentfulPaint.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAC,MAAM,EAA0B,MAAM,aAAa,CAAC;AAoB5D,MAAM,oBAAqB,SAAQ,MAAM;IACvC,MAAM,KAAc,YAAY;QAC9B,OAAO;YACL,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,GAAG;YACf,WAAW,EAAE,GAAG;SACjB,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,yBAAyB,CAC5B,KAAiB,EACjB,EAAC,eAAe,EAAE,yBAAyB,EAAE,yCAAyC,EACvD;QAEjC,iGAAiG;QACjG,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAyB,CAAC;QAE5D,MAAM,QAAQ,GAAoB,EAAE,CAAC;QACrC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACpB,IAAI,IAAI,CAAC,IAAI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QAC/C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAU,kBAAkB,CAC9B,eAA8B,EAAE,mBAAyD;QAC3F,OAAO,IAAI,CAAC,uBAAuB,CAAC,eAAe,EAAE;YACnD,eAAe,EAAE,mBAAmB,CAAC,UAAU,CAAC,oBAAoB;YACpE,4FAA4F;YAC5F,6FAA6F;YAC7F,+FAA+F;YAC/F,yBAAyB,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,IAAI,CAAC,aAAa,KAAK,QAAQ;SACvG,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAU,mBAAmB,CAC/B,eAA8B,EAAE,mBAAyD;QAC3F,OAAO,IAAI,CAAC,uBAAuB,CAAC,eAAe,EAAE;YACnD,eAAe,EAAE,mBAAmB,CAAC,UAAU,CAAC,oBAAoB;YACpE,yBAAyB,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,yBAAyB,EAAE;SACpE,CAAC,CAAC;IACL,CAAC;CACF;AAED,OAAO,EAAC,oBAAoB,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 Graph from '../graph/graph.js';\nimport type * as Types from '../types/types.js';\n\nimport {Metric, type MetricCoefficients} from './Metric.js';\n\ninterface FirstPaintBasedGraphOpts<T> {\n /**\n * The timestamp used to filter out tasks that occurred after our paint of interest.\n * Typically this is First Contentful Paint or First Meaningful Paint.\n */\n cutoffTimestamp: number;\n /**\n * The function that determines which resources should be considered *possibly*\n * render-blocking.\n */\n treatNodeAsRenderBlocking: (node: Graph.NetworkNode<T>) => boolean;\n /**\n * The function that determines which CPU nodes should also be included in our\n * blocking node IDs set, beyond what getRenderBlockingNodeData() already includes.\n */\n additionalCpuNodesToTreatAsRenderBlocking?: (node: Graph.CPUNode) => boolean;\n}\n\nclass FirstContentfulPaint 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 * Computes the set of URLs that *appeared* to be render-blocking based on our filter,\n * *but definitely were not* render-blocking based on the timing of their EvaluateScript task.\n * It also computes the set of corresponding CPU node ids that were needed for the paint at the\n * given timestamp.\n */\n static getRenderBlockingNodeData<T = unknown>(\n graph: Graph.Node,\n {cutoffTimestamp, treatNodeAsRenderBlocking, additionalCpuNodesToTreatAsRenderBlocking}:\n FirstPaintBasedGraphOpts<T>,\n ): {definitelyNotRenderBlockingScriptUrls: Set<string>, renderBlockingCpuNodeIds: Set<string>} {\n /** A map of blocking script URLs to the earliest EvaluateScript task node that executed them. */\n const scriptUrlToNodeMap = new Map<string, Graph.CPUNode>();\n\n const cpuNodes: Graph.CPUNode[] = [];\n graph.traverse(node => {\n if (node.type === Graph.BaseNode.types.CPU) {\n // A task is *possibly* render blocking if it *started* before cutoffTimestamp.\n // We use startTime here because the paint event can be *inside* the task that was render blocking.\n if (node.startTime <= cutoffTimestamp) {\n cpuNodes.push(node);\n }\n\n // Build our script URL map to find the earliest EvaluateScript task node.\n const scriptUrls = node.getEvaluateScriptURLs();\n for (const url of scriptUrls) {\n // Use the earliest CPU node we find.\n const existing = scriptUrlToNodeMap.get(url) || node;\n scriptUrlToNodeMap.set(url, node.startTime < existing.startTime ? node : existing);\n }\n }\n });\n\n cpuNodes.sort((a, b) => a.startTime - b.startTime);\n\n // A script is *possibly* render blocking if it finished loading before cutoffTimestamp.\n const possiblyRenderBlockingScriptUrls = Metric.getScriptUrls(graph, node => {\n // The optimistic LCP treatNodeAsRenderBlocking fn wants to exclude some images in the graph,\n // but here it only receives scripts to evaluate. It's a no-op in this case, but it will\n // matter below in the getFirstPaintBasedGraph clone operation.\n return node.endTime <= cutoffTimestamp && treatNodeAsRenderBlocking(node);\n });\n\n // A script is *definitely not* render blocking if its EvaluateScript task started after cutoffTimestamp.\n const definitelyNotRenderBlockingScriptUrls = new Set<string>();\n const renderBlockingCpuNodeIds = new Set<string>();\n for (const url of possiblyRenderBlockingScriptUrls) {\n // Lookup the CPU node that had the earliest EvaluateScript for this URL.\n const cpuNodeForUrl = scriptUrlToNodeMap.get(url);\n\n // If we can't find it at all, we can't conclude anything, so just skip it.\n if (!cpuNodeForUrl) {\n continue;\n }\n\n // If we found it and it was in our `cpuNodes` set that means it finished before cutoffTimestamp, so it really is render-blocking.\n if (cpuNodes.includes(cpuNodeForUrl)) {\n renderBlockingCpuNodeIds.add(cpuNodeForUrl.id);\n continue;\n }\n\n // We couldn't find the evaluate script in the set of CPU nodes that ran before our paint, so\n // it must not have been necessary for the paint.\n definitelyNotRenderBlockingScriptUrls.add(url);\n }\n\n // The first layout, first paint, and first ParseHTML are almost always necessary for first paint,\n // so we always include those CPU nodes.\n const firstLayout = cpuNodes.find(node => node.didPerformLayout());\n if (firstLayout) {\n renderBlockingCpuNodeIds.add(firstLayout.id);\n }\n const firstPaint = cpuNodes.find(node => node.childEvents.some(e => e.name === 'Paint'));\n if (firstPaint) {\n renderBlockingCpuNodeIds.add(firstPaint.id);\n }\n const firstParse = cpuNodes.find(node => node.childEvents.some(e => e.name === 'ParseHTML'));\n if (firstParse) {\n renderBlockingCpuNodeIds.add(firstParse.id);\n }\n\n // If a CPU filter was passed in, we also want to include those extra nodes.\n if (additionalCpuNodesToTreatAsRenderBlocking) {\n cpuNodes.filter(additionalCpuNodesToTreatAsRenderBlocking).forEach(node => renderBlockingCpuNodeIds.add(node.id));\n }\n\n return {\n definitelyNotRenderBlockingScriptUrls,\n renderBlockingCpuNodeIds,\n };\n }\n\n /**\n * Computes the graph required for the first paint of interest.\n */\n static getFirstPaintBasedGraph<T>(\n dependencyGraph: Graph.Node,\n {cutoffTimestamp, treatNodeAsRenderBlocking, additionalCpuNodesToTreatAsRenderBlocking}:\n FirstPaintBasedGraphOpts<T>,\n ): Graph.Node<T> {\n const rbData = this.getRenderBlockingNodeData(dependencyGraph, {\n cutoffTimestamp,\n treatNodeAsRenderBlocking,\n additionalCpuNodesToTreatAsRenderBlocking,\n });\n const {definitelyNotRenderBlockingScriptUrls, renderBlockingCpuNodeIds} = rbData;\n\n return dependencyGraph.cloneWithRelationships(node => {\n if (node.type === Graph.BaseNode.types.NETWORK) {\n // Exclude all nodes that ended after cutoffTimestamp (except for the main document which we always consider necessary)\n // endTime is negative if request does not finish, make sure startTime isn't after cutoffTimestamp in this case.\n const endedAfterPaint = node.endTime > cutoffTimestamp || node.startTime > cutoffTimestamp;\n if (endedAfterPaint && !node.isMainDocument()) {\n return false;\n }\n\n const url = node.request.url;\n // If the URL definitely wasn't render-blocking then we filter it out.\n if (definitelyNotRenderBlockingScriptUrls.has(url)) {\n return false;\n }\n\n // Lastly, build up the FCP graph of all nodes we consider render blocking\n return treatNodeAsRenderBlocking(node);\n }\n // If it's a CPU node, just check if it was blocking.\n return renderBlockingCpuNodeIds.has(node.id);\n });\n }\n\n static override getOptimisticGraph<T>(\n dependencyGraph: Graph.Node<T>, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node<T> {\n return this.getFirstPaintBasedGraph(dependencyGraph, {\n cutoffTimestamp: processedNavigation.timestamps.firstContentfulPaint,\n // In the optimistic graph we exclude resources that appeared to be render blocking but were\n // initiated by a script. While they typically have a very high importance and tend to have a\n // significant impact on the page's content, these resources don't technically block rendering.\n treatNodeAsRenderBlocking: node => node.hasRenderBlockingPriority() && node.initiatorType !== 'script',\n });\n }\n\n static override getPessimisticGraph<T>(\n dependencyGraph: Graph.Node<T>, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node<T> {\n return this.getFirstPaintBasedGraph(dependencyGraph, {\n cutoffTimestamp: processedNavigation.timestamps.firstContentfulPaint,\n treatNodeAsRenderBlocking: node => node.hasRenderBlockingPriority(),\n });\n }\n}\n\nexport {FirstContentfulPaint};\n"]}
|
|
1
|
+
{"version":3,"file":"FirstContentfulPaint.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts"],"names":[],"m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IACL,CAAC;CACF;AAED,OAAO,EAAC,oBAAoB,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 Graph from '../graph/graph.js';\nimport type * as Types from '../types/types.js';\n\nimport {Metric, type MetricCoefficients} from './Metric.js';\n\ninterface FirstPaintBasedGraphOpts<T> {\n /**\n * The timestamp used to filter out tasks that occurred after our paint of interest.\n * Typically this is First Contentful Paint or First Meaningful Paint.\n */\n cutoffTimestamp: number;\n /**\n * The function that determines which resources should be considered *possibly*\n * render-blocking.\n */\n treatNodeAsRenderBlocking: (node: Graph.NetworkNode<T>) => boolean;\n /**\n * The function that determines which CPU nodes should also be included in our\n * blocking node IDs set, beyond what getRenderBlockingNodeData() already includes.\n */\n additionalCpuNodesToTreatAsRenderBlocking?: (node: Graph.CPUNode) => boolean;\n}\n\nclass FirstContentfulPaint 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 * Computes the set of URLs that *appeared* to be render-blocking based on our filter,\n * *but definitely were not* render-blocking based on the timing of their EvaluateScript task.\n * It also computes the set of corresponding CPU node ids that were needed for the paint at the\n * given timestamp.\n */\n static getRenderBlockingNodeData<T = unknown>(\n graph: Graph.Node,\n {cutoffTimestamp, treatNodeAsRenderBlocking, additionalCpuNodesToTreatAsRenderBlocking}:\n FirstPaintBasedGraphOpts<T>,\n ): {definitelyNotRenderBlockingScriptUrls: Set<string>, renderBlockingCpuNodeIds: Set<string>} {\n /** A map of blocking script URLs to the earliest EvaluateScript task node that executed them. */\n const scriptUrlToNodeMap = new Map<string, Graph.CPUNode>();\n\n const cpuNodes: Graph.CPUNode[] = [];\n graph.traverse(node => {\n if (node.type === Graph.BaseNode.types.CPU) {\n // A task is *possibly* render-blocking if it *started* before cutoffTimestamp.\n // We use startTime here because the paint event can be *inside* the task that was render-blocking.\n if (node.startTime <= cutoffTimestamp) {\n cpuNodes.push(node);\n }\n\n // Build our script URL map to find the earliest EvaluateScript task node.\n const scriptUrls = node.getEvaluateScriptURLs();\n for (const url of scriptUrls) {\n // Use the earliest CPU node we find.\n const existing = scriptUrlToNodeMap.get(url) || node;\n scriptUrlToNodeMap.set(url, node.startTime < existing.startTime ? node : existing);\n }\n }\n });\n\n cpuNodes.sort((a, b) => a.startTime - b.startTime);\n\n // A script is *possibly* render-blocking if it finished loading before cutoffTimestamp.\n const possiblyRenderBlockingScriptUrls = Metric.getScriptUrls(graph, node => {\n // The optimistic LCP treatNodeAsRenderBlocking fn wants to exclude some images in the graph,\n // but here it only receives scripts to evaluate. It's a no-op in this case, but it will\n // matter below in the getFirstPaintBasedGraph clone operation.\n return node.endTime <= cutoffTimestamp && treatNodeAsRenderBlocking(node);\n });\n\n // A script is *definitely not* render-blocking if its EvaluateScript task started after cutoffTimestamp.\n const definitelyNotRenderBlockingScriptUrls = new Set<string>();\n const renderBlockingCpuNodeIds = new Set<string>();\n for (const url of possiblyRenderBlockingScriptUrls) {\n // Lookup the CPU node that had the earliest EvaluateScript for this URL.\n const cpuNodeForUrl = scriptUrlToNodeMap.get(url);\n\n // If we can't find it at all, we can't conclude anything, so just skip it.\n if (!cpuNodeForUrl) {\n continue;\n }\n\n // If we found it and it was in our `cpuNodes` set that means it finished before cutoffTimestamp, so it really is render-blocking.\n if (cpuNodes.includes(cpuNodeForUrl)) {\n renderBlockingCpuNodeIds.add(cpuNodeForUrl.id);\n continue;\n }\n\n // We couldn't find the evaluate script in the set of CPU nodes that ran before our paint, so\n // it must not have been necessary for the paint.\n definitelyNotRenderBlockingScriptUrls.add(url);\n }\n\n // The first layout, first paint, and first ParseHTML are almost always necessary for first paint,\n // so we always include those CPU nodes.\n const firstLayout = cpuNodes.find(node => node.didPerformLayout());\n if (firstLayout) {\n renderBlockingCpuNodeIds.add(firstLayout.id);\n }\n const firstPaint = cpuNodes.find(node => node.childEvents.some(e => e.name === 'Paint'));\n if (firstPaint) {\n renderBlockingCpuNodeIds.add(firstPaint.id);\n }\n const firstParse = cpuNodes.find(node => node.childEvents.some(e => e.name === 'ParseHTML'));\n if (firstParse) {\n renderBlockingCpuNodeIds.add(firstParse.id);\n }\n\n // If a CPU filter was passed in, we also want to include those extra nodes.\n if (additionalCpuNodesToTreatAsRenderBlocking) {\n cpuNodes.filter(additionalCpuNodesToTreatAsRenderBlocking).forEach(node => renderBlockingCpuNodeIds.add(node.id));\n }\n\n return {\n definitelyNotRenderBlockingScriptUrls,\n renderBlockingCpuNodeIds,\n };\n }\n\n /**\n * Computes the graph required for the first paint of interest.\n */\n static getFirstPaintBasedGraph<T>(\n dependencyGraph: Graph.Node,\n {cutoffTimestamp, treatNodeAsRenderBlocking, additionalCpuNodesToTreatAsRenderBlocking}:\n FirstPaintBasedGraphOpts<T>,\n ): Graph.Node<T> {\n const rbData = this.getRenderBlockingNodeData(dependencyGraph, {\n cutoffTimestamp,\n treatNodeAsRenderBlocking,\n additionalCpuNodesToTreatAsRenderBlocking,\n });\n const {definitelyNotRenderBlockingScriptUrls, renderBlockingCpuNodeIds} = rbData;\n\n return dependencyGraph.cloneWithRelationships(node => {\n if (node.type === Graph.BaseNode.types.NETWORK) {\n // Exclude all nodes that ended after cutoffTimestamp (except for the main document which we always consider necessary)\n // endTime is negative if request does not finish, make sure startTime isn't after cutoffTimestamp in this case.\n const endedAfterPaint = node.endTime > cutoffTimestamp || node.startTime > cutoffTimestamp;\n if (endedAfterPaint && !node.isMainDocument()) {\n return false;\n }\n\n const url = node.request.url;\n // If the URL definitely wasn't render-blocking then we filter it out.\n if (definitelyNotRenderBlockingScriptUrls.has(url)) {\n return false;\n }\n\n // Lastly, build up the FCP graph of all nodes we consider render-blocking\n return treatNodeAsRenderBlocking(node);\n }\n // If it's a CPU node, just check if it was blocking.\n return renderBlockingCpuNodeIds.has(node.id);\n });\n }\n\n static override getOptimisticGraph<T>(\n dependencyGraph: Graph.Node<T>, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node<T> {\n return this.getFirstPaintBasedGraph(dependencyGraph, {\n cutoffTimestamp: processedNavigation.timestamps.firstContentfulPaint,\n // In the optimistic graph we exclude resources that appeared to be render-blocking but were\n // initiated by a script. While they typically have a very high importance and tend to have a\n // significant impact on the page's content, these resources don't technically block rendering.\n treatNodeAsRenderBlocking: node => node.hasRenderBlockingPriority() && node.initiatorType !== 'script',\n });\n }\n\n static override getPessimisticGraph<T>(\n dependencyGraph: Graph.Node<T>, processedNavigation: Types.Simulation.ProcessedNavigation): Graph.Node<T> {\n return this.getFirstPaintBasedGraph(dependencyGraph, {\n cutoffTimestamp: processedNavigation.timestamps.firstContentfulPaint,\n treatNodeAsRenderBlocking: node => node.hasRenderBlockingPriority(),\n });\n }\n}\n\nexport {FirstContentfulPaint};\n"]}
|