@paulirish/trace_engine 0.0.51 → 0.0.53
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/core/platform/DOMUtilities.d.ts +8 -0
- package/core/platform/DOMUtilities.js +14 -0
- package/core/platform/DOMUtilities.js.map +1 -1
- package/core/platform/StringUtilities.d.ts +1 -5
- package/core/platform/StringUtilities.js +4 -1
- package/core/platform/StringUtilities.js.map +1 -1
- package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/core/platform/platform-tsconfig.json +1 -1
- package/generated/protocol.d.ts +345 -44
- package/locales/af.json +11 -5
- package/locales/am.json +7 -1
- package/locales/ar.json +7 -1
- package/locales/as.json +7 -1
- package/locales/az.json +7 -1
- package/locales/be.json +7 -1
- package/locales/bg.json +7 -1
- package/locales/bn.json +7 -1
- package/locales/bs.json +7 -1
- package/locales/ca.json +7 -1
- package/locales/cs.json +7 -1
- package/locales/cy.json +7 -1
- package/locales/da.json +7 -1
- package/locales/de.json +7 -1
- package/locales/el.json +7 -1
- package/locales/en-GB.json +7 -1
- package/locales/en-US.json +52 -7
- package/locales/en-XL.json +52 -7
- package/locales/es-419.json +7 -1
- package/locales/es.json +7 -1
- package/locales/et.json +7 -1
- package/locales/eu.json +7 -1
- package/locales/fa.json +7 -1
- package/locales/fi.json +7 -1
- package/locales/fil.json +7 -1
- package/locales/fr-CA.json +7 -1
- package/locales/fr.json +7 -1
- package/locales/gl.json +7 -1
- package/locales/gu.json +7 -1
- package/locales/he.json +7 -1
- package/locales/hi.json +7 -1
- package/locales/hr.json +7 -1
- package/locales/hu.json +7 -1
- package/locales/hy.json +7 -1
- package/locales/id.json +7 -1
- package/locales/is.json +7 -1
- package/locales/it.json +7 -1
- package/locales/ja.json +7 -1
- package/locales/ka.json +7 -1
- package/locales/kk.json +7 -1
- package/locales/km.json +7 -1
- package/locales/kn.json +7 -1
- package/locales/ko.json +7 -1
- package/locales/ky.json +7 -1
- package/locales/lo.json +7 -1
- package/locales/lt.json +7 -1
- package/locales/lv.json +7 -1
- package/locales/mk.json +7 -1
- package/locales/ml.json +7 -1
- package/locales/mn.json +7 -1
- package/locales/mr.json +7 -1
- package/locales/ms.json +7 -1
- package/locales/my.json +7 -1
- package/locales/ne.json +7 -1
- package/locales/nl.json +7 -1
- package/locales/no.json +7 -1
- package/locales/or.json +7 -1
- package/locales/pa.json +7 -1
- package/locales/pl.json +7 -1
- package/locales/pt-PT.json +7 -1
- package/locales/pt.json +7 -1
- package/locales/ro.json +7 -1
- package/locales/ru.json +7 -1
- package/locales/si.json +7 -1
- package/locales/sk.json +7 -1
- package/locales/sl.json +7 -1
- package/locales/sq.json +7 -1
- package/locales/sr-Latn.json +7 -1
- package/locales/sr.json +7 -1
- package/locales/sv.json +7 -1
- package/locales/sw.json +7 -1
- package/locales/ta.json +7 -1
- package/locales/te.json +7 -1
- package/locales/th.json +7 -1
- package/locales/tr.json +7 -1
- package/locales/uk.json +7 -1
- package/locales/ur.json +7 -1
- package/locales/uz.json +7 -1
- package/locales/vi.json +7 -1
- package/locales/zh-HK.json +7 -1
- package/locales/zh-TW.json +7 -1
- package/locales/zh.json +7 -1
- package/locales/zu.json +7 -1
- package/models/cpu_profile/cpu_profile-tsconfig.json +1 -1
- package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/LanternComputationData.js +3 -3
- package/models/trace/LanternComputationData.js.map +1 -1
- package/models/trace/Processor.d.ts +1 -3
- package/models/trace/Processor.js +1 -1
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/TracingManager.js.map +1 -1
- package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/extras/ScriptDuplication.d.ts +5 -2
- package/models/trace/extras/ScriptDuplication.js +4 -2
- package/models/trace/extras/ScriptDuplication.js.map +1 -1
- package/models/trace/extras/StackTraceForEvent.js +88 -47
- package/models/trace/extras/StackTraceForEvent.js.map +1 -1
- package/models/trace/extras/ThirdParties.d.ts +13 -12
- package/models/trace/extras/ThirdParties.js +50 -19
- package/models/trace/extras/ThirdParties.js.map +1 -1
- package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/extras/extras-tsconfig.json +1 -1
- package/models/trace/extras/extras.d.ts +98 -6
- package/models/trace/extras/extras.js +98 -6
- package/models/trace/handlers/AsyncJSCallsHandler.d.ts +5 -0
- package/models/trace/handlers/AsyncJSCallsHandler.js +12 -9
- package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -1
- package/models/trace/handlers/FramesHandler.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.d.ts +1 -0
- package/models/trace/handlers/NetworkRequestsHandler.js +37 -23
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/ScriptsHandler.d.ts +5 -1
- package/models/trace/handlers/ScriptsHandler.js +59 -22
- package/models/trace/handlers/ScriptsHandler.js.map +1 -1
- package/models/trace/handlers/WarningsHandler.js +14 -2
- package/models/trace/handlers/WarningsHandler.js.map +1 -1
- package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/handlers/handlers-tsconfig.json +1 -1
- package/models/trace/handlers/helpers.js +12 -0
- package/models/trace/handlers/helpers.js.map +1 -1
- package/models/trace/handlers/types.d.ts +2 -6
- package/models/trace/handlers/types.js.map +1 -1
- package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/helpers/helpers-tsconfig.json +1 -1
- package/models/trace/insights/CLSCulprits.d.ts +6 -1
- package/models/trace/insights/CLSCulprits.js +11 -2
- package/models/trace/insights/CLSCulprits.js.map +1 -1
- package/models/trace/insights/Cache.d.ts +0 -1
- package/models/trace/insights/Cache.js +8 -7
- package/models/trace/insights/Cache.js.map +1 -1
- package/models/trace/insights/Common.js +6 -0
- package/models/trace/insights/Common.js.map +1 -1
- package/models/trace/insights/DocumentLatency.d.ts +7 -3
- package/models/trace/insights/DocumentLatency.js +25 -8
- package/models/trace/insights/DocumentLatency.js.map +1 -1
- package/models/trace/insights/DuplicatedJavaScript.js +9 -3
- package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
- package/models/trace/insights/ImageDelivery.d.ts +0 -1
- package/models/trace/insights/ImageDelivery.js +1 -1
- package/models/trace/insights/ImageDelivery.js.map +1 -1
- package/models/trace/insights/LCPPhases.d.ts +1 -1
- package/models/trace/insights/LCPPhases.js +1 -1
- package/models/trace/insights/LCPPhases.js.map +1 -1
- package/models/trace/insights/LegacyJavaScript.d.ts +1 -1
- package/models/trace/insights/LegacyJavaScript.js +6 -3
- package/models/trace/insights/LegacyJavaScript.js.map +1 -1
- package/models/trace/insights/NetworkDependencyTree.d.ts +151 -3
- package/models/trace/insights/NetworkDependencyTree.js +648 -10
- package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
- package/models/trace/insights/RenderBlocking.js +1 -1
- package/models/trace/insights/RenderBlocking.js.map +1 -1
- package/models/trace/insights/ThirdParties.d.ts +1 -1
- package/models/trace/insights/ThirdParties.js +7 -7
- package/models/trace/insights/ThirdParties.js.map +1 -1
- package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/insights/insights-tsconfig.json +1 -1
- package/models/trace/insights/types.d.ts +11 -0
- package/models/trace/insights/types.js.map +1 -1
- package/models/trace/lantern/core/core-tsconfig.json +1 -1
- package/models/trace/lantern/core/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/lantern/graph/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/lantern/graph/graph-tsconfig.json +1 -1
- package/models/trace/lantern/lantern-tsconfig.json +1 -1
- package/models/trace/lantern/metrics/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/lantern/metrics/metrics-tsconfig.json +1 -1
- package/models/trace/lantern/simulation/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/lantern/simulation/simulation-tsconfig.json +1 -1
- package/models/trace/lantern/types/Lantern.d.ts +4 -7
- package/models/trace/lantern/types/Lantern.js +1 -0
- package/models/trace/lantern/types/Lantern.js.map +1 -1
- package/models/trace/lantern/types/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/lantern/types/types-tsconfig.json +1 -1
- package/models/trace/trace-tsconfig.json +1 -1
- package/models/trace/types/Configuration.d.ts +2 -0
- package/models/trace/types/Configuration.js.map +1 -1
- package/models/trace/types/Extensions.d.ts +1 -3
- package/models/trace/types/Extensions.js.map +1 -1
- package/models/trace/types/File.d.ts +2 -1
- package/models/trace/types/File.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +51 -26
- package/models/trace/types/TraceEvents.js +6 -0
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -1
- package/models/trace/types/types-tsconfig.json +1 -1
- package/package.json +1 -1
- package/test/test-trace-engine.mjs +2 -2
package/locales/vi.json
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"generated/Deprecation.ts | CanRequestURLHTTPContainingNewline": {
|
|
12
12
|
"message": "C\u00e1c y\u00eau c\u1ea7u t\u00e0i nguy\u00ean c\u00f3 URL ch\u1ee9a c\u1ea3 k\u00fd t\u1ef1 \\(n|r|t) kho\u1ea3ng tr\u1eafng \u0111\u00e3 b\u1ecb xo\u00e1 v\u00e0 k\u00fd t\u1ef1 nh\u1ecf h\u01a1n (<) s\u1ebd b\u1ecb ch\u1eb7n. Vui l\u00f2ng xo\u00e1 c\u00e1c d\u00f2ng m\u1edbi v\u00e0 m\u00e3 ho\u00e1 k\u00fd t\u1ef1 nh\u1ecf h\u01a1n kh\u1ecfi c\u00e1c v\u1ecb tr\u00ed nh\u01b0 gi\u00e1 tr\u1ecb thu\u1ed9c t\u00ednh ph\u1ea7n t\u1eed \u0111\u1ec3 t\u1ea3i nh\u1eefng t\u00e0i nguy\u00ean nh\u01b0 v\u1eady."
|
|
13
13
|
},
|
|
14
|
+
"generated/Deprecation.ts | CharsetAutoDetectionISO2022JP": {
|
|
15
|
+
"message": "T\u00ednh n\u0103ng t\u1ef1 \u0111\u1ed9ng ph\u00e1t hi\u1ec7n b\u1ed9 k\u00fd t\u1ef1 ISO-2022-JP kh\u00f4ng \u0111\u01b0\u1ee3c d\u00f9ng n\u1eefa v\u00e0 s\u1ebd b\u1ecb t\u1eaft trong t\u01b0\u01a1ng lai g\u1ea7n. Vui l\u00f2ng ch\u1ec9 \u0111\u1ecbnh b\u1ed9 k\u00fd t\u1ef1 trong ti\u00eau \u0111\u1ec1 Lo\u1ea1i n\u1ed9i dung ho\u1eb7c b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng th\u1ebb meta (https://developer.mozilla.org/en-US/docs/Glossary/Character_encoding)."
|
|
16
|
+
},
|
|
14
17
|
"generated/Deprecation.ts | ChromeLoadTimesConnectionInfo": {
|
|
15
18
|
"message": "chrome.loadTimes() kh\u00f4ng \u0111\u01b0\u1ee3c d\u00f9ng n\u1eefa; thay v\u00e0o \u0111\u00f3, h\u00e3y s\u1eed d\u1ee5ng API \u0111\u00e3 chu\u1ea9n ho\u00e1: Navigation Timing 2."
|
|
16
19
|
},
|
|
@@ -305,6 +308,9 @@
|
|
|
305
308
|
"models/trace/insights/FontDisplay.ts | wastedTimeColumn": {
|
|
306
309
|
"message": "Th\u1eddi gian b\u1ecb l\u00e3ng ph\u00ed"
|
|
307
310
|
},
|
|
311
|
+
"models/trace/insights/ForcedReflow.ts | anonymous": {
|
|
312
|
+
"message": "(\u1ea9n danh)"
|
|
313
|
+
},
|
|
308
314
|
"models/trace/insights/ForcedReflow.ts | description": {
|
|
309
315
|
"message": "Nhi\u1ec1u API, th\u01b0\u1eddng \u0111\u1ecdc h\u00ecnh h\u1ecdc b\u1ed1 c\u1ee5c, bu\u1ed9c c\u00f4ng c\u1ee5 k\u1ebft xu\u1ea5t ph\u1ea3i t\u1ea1m d\u1eebng th\u1ef1c thi t\u1eadp l\u1ec7nh \u0111\u1ec3 t\u00ednh to\u00e1n ki\u1ec3u v\u00e0 b\u1ed1 c\u1ee5c. T\u00ecm hi\u1ec3u th\u00eam v\u1ec1 [ch\u1ebf \u0111\u1ed9 bu\u1ed9c ch\u1ec9nh l\u1ea1i lu\u1ed3ng](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing#avoid-forced-synchronous-layouts) v\u00e0 c\u00e1ch gi\u1ea3m thi\u1ec3u t\u00e1c \u0111\u1ed9ng c\u1ee7a ch\u1ebf \u0111\u1ed9 n\u00e0y."
|
|
310
316
|
},
|
|
@@ -321,7 +327,7 @@
|
|
|
321
327
|
"message": "T\u1ed5ng th\u1eddi gian chi\u0309nh la\u0323i lu\u1ed3ng"
|
|
322
328
|
},
|
|
323
329
|
"models/trace/insights/ForcedReflow.ts | unattributed": {
|
|
324
|
-
"message": "
|
|
330
|
+
"message": "[ch\u01b0a \u0111\u01b0\u1ee3c ph\u00e2n b\u1ed5]"
|
|
325
331
|
},
|
|
326
332
|
"models/trace/insights/ImageDelivery.ts | description": {
|
|
327
333
|
"message": "Vi\u1ec7c gi\u1ea3m th\u1eddi gian t\u1ea3i h\u00ecnh \u1ea3nh xu\u1ed1ng c\u00f3 th\u1ec3 c\u1ea3i thi\u1ec7n th\u1eddi gian t\u1ea3i trang v\u00e0 LCP \u0111\u01b0\u1ee3c c\u1ea3m nh\u1eadn. [T\u00ecm hi\u1ec3u th\u00eam v\u1ec1 c\u00e1ch t\u1ed1i \u01b0u ho\u00e1 k\u00edch th\u01b0\u1edbc h\u00ecnh \u1ea3nh](https://developer.chrome.com/docs/lighthouse/performance/uses-optimized-images/)"
|
package/locales/zh-HK.json
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"generated/Deprecation.ts | CanRequestURLHTTPContainingNewline": {
|
|
12
12
|
"message": "\u7cfb\u7d71\u5c07\u5c01\u9396\u7db2\u5740\u540c\u6642\u5305\u542b\u5df2\u79fb\u9664\u7684\u7a7a\u767d \\(n|r|t) \u5b57\u5143\u548c\u5c0f\u65bc\u5b57\u5143 (<) \u7684\u8cc7\u6e90\u8981\u6c42\u3002\u8acb\u5f9e\u5143\u7d20\u5c6c\u6027\u503c\u7b49\u4f4d\u7f6e\u79fb\u9664\u63db\u884c\u7b26\u865f\uff0c\u4e26\u7de8\u78bc\u5c0f\u65bc\u5b57\u5143\uff0c\u4ee5\u4fbf\u8f09\u5165\u9019\u4e9b\u8cc7\u6e90\u3002"
|
|
13
13
|
},
|
|
14
|
+
"generated/Deprecation.ts | CharsetAutoDetectionISO2022JP": {
|
|
15
|
+
"message": "\u81ea\u52d5\u5075\u6e2c ISO-2022-JP \u5b57\u5143\u8a2d\u5b9a\u7684\u529f\u80fd\u5df2\u6dd8\u6c70\uff0c\u4e26\u5373\u5c07\u505c\u7528\u3002\u8acb\u5728\u300c\u5167\u5bb9\u985e\u578b\u300d\u6a19\u984c\u4e2d\u6216\u4f7f\u7528\u4e2d\u7e7c\u6a19\u7c64\u6307\u660e\u5b57\u5143\u8a2d\u5b9a (https://developer.mozilla.org/en-US/docs/Glossary/Character_encoding)\u3002"
|
|
16
|
+
},
|
|
14
17
|
"generated/Deprecation.ts | ChromeLoadTimesConnectionInfo": {
|
|
15
18
|
"message": "chrome.loadTimes() \u5df2\u6dd8\u6c70\uff0c\u8acb\u6539\u7528\u6a19\u6e96\u5316 API\uff1aNavigation Timing 2\u3002"
|
|
16
19
|
},
|
|
@@ -305,6 +308,9 @@
|
|
|
305
308
|
"models/trace/insights/FontDisplay.ts | wastedTimeColumn": {
|
|
306
309
|
"message": "\u6d6a\u8cbb\u7684\u6642\u9593"
|
|
307
310
|
},
|
|
311
|
+
"models/trace/insights/ForcedReflow.ts | anonymous": {
|
|
312
|
+
"message": "(\u533f\u540d)"
|
|
313
|
+
},
|
|
308
314
|
"models/trace/insights/ForcedReflow.ts | description": {
|
|
309
315
|
"message": "\u5f88\u591a API (\u901a\u5e38\u8b80\u53d6\u7248\u9762\u914d\u7f6e\u5e7e\u4f55\u5716\u5f62) \u6703\u5f37\u5236\u8f38\u51fa\u5f15\u64ce\u66ab\u505c\u57f7\u884c\u6307\u4ee4\u78bc\uff0c\u4ee5\u8a08\u7b97\u6a23\u5f0f\u548c\u7248\u9762\u914d\u7f6e\u3002\u9032\u4e00\u6b65\u77ad\u89e3[\u5f37\u5236\u91cd\u6392](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing#avoid-forced-synchronous-layouts)\u53ca\u5176\u7de9\u89e3\u63aa\u65bd\u3002"
|
|
310
316
|
},
|
|
@@ -321,7 +327,7 @@
|
|
|
321
327
|
"message": "\u91cd\u6392\u7e3d\u6642\u9593"
|
|
322
328
|
},
|
|
323
329
|
"models/trace/insights/ForcedReflow.ts | unattributed": {
|
|
324
|
-
"message": "\u672a\u6b78\u56e0"
|
|
330
|
+
"message": "[\u672a\u6b78\u56e0]"
|
|
325
331
|
},
|
|
326
332
|
"models/trace/insights/ImageDelivery.ts | description": {
|
|
327
333
|
"message": "\u7e2e\u77ed\u5716\u50cf\u4e0b\u8f09\u6642\u9593\uff0c\u53ef\u7e2e\u6e1b\u4f7f\u7528\u8005\u611f\u77e5\u7684\u7db2\u9801\u8f09\u5165\u6642\u9593\uff0c\u4e26\u63d0\u5347 LCP \u6578\u64da\u7684\u8868\u73fe\u3002[\u9032\u4e00\u6b65\u77ad\u89e3\u5982\u4f55\u512a\u5316\u5716\u50cf\u5927\u5c0f](https://developer.chrome.com/docs/lighthouse/performance/uses-optimized-images/)"
|
package/locales/zh-TW.json
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"generated/Deprecation.ts | CanRequestURLHTTPContainingNewline": {
|
|
12
12
|
"message": "\u5982\u679c\u8cc7\u6e90\u8981\u6c42\u7db2\u5740\u4e2d\u540c\u6642\u5305\u542b\u5df2\u79fb\u9664\u7684 \\(n|r|t) \u5b57\u5143\u548c\u5c0f\u65bc\u5b57\u5143 (<)\uff0c\u7cfb\u7d71\u6703\u4e88\u4ee5\u5c01\u9396\u3002\u8acb\u5f9e\u5143\u7d20\u5c6c\u6027\u503c\u7b49\u4f4d\u7f6e\u79fb\u9664\u63db\u884c\u7b26\u865f\uff0c\u4e26\u7de8\u78bc\u5c0f\u65bc\u5b57\u5143\uff0c\u4ee5\u4fbf\u8f09\u5165\u9019\u4e9b\u8cc7\u6e90\u3002"
|
|
13
13
|
},
|
|
14
|
+
"generated/Deprecation.ts | CharsetAutoDetectionISO2022JP": {
|
|
15
|
+
"message": "\u81ea\u52d5\u5075\u6e2c ISO-2022-JP \u5b57\u5143\u96c6\u7684\u529f\u80fd\u5df2\u6dd8\u6c70\uff0c\u8fd1\u671f\u5373\u5c07\u505c\u7528\u3002\u8acb\u5728\u300cContent Type\u300d\u6a19\u982d\uff0c\u6216\u662f\u4f7f\u7528\u4e2d\u7e7c\u6a19\u8a18 (https://developer.mozilla.org/en-US/docs/Glossary/Character_encoding)\uff0c\u6307\u5b9a\u5b57\u5143\u96c6\u3002"
|
|
16
|
+
},
|
|
14
17
|
"generated/Deprecation.ts | ChromeLoadTimesConnectionInfo": {
|
|
15
18
|
"message": "chrome.loadTimes() \u5df2\u6dd8\u6c70\uff0c\u8acb\u6539\u7528\u6a19\u6e96\u5316 API\uff1aNavigation Timing 2\u3002"
|
|
16
19
|
},
|
|
@@ -305,6 +308,9 @@
|
|
|
305
308
|
"models/trace/insights/FontDisplay.ts | wastedTimeColumn": {
|
|
306
309
|
"message": "\u6d6a\u8cbb\u7684\u6642\u9593"
|
|
307
310
|
},
|
|
311
|
+
"models/trace/insights/ForcedReflow.ts | anonymous": {
|
|
312
|
+
"message": "(\u533f\u540d)"
|
|
313
|
+
},
|
|
308
314
|
"models/trace/insights/ForcedReflow.ts | description": {
|
|
309
315
|
"message": "\u8a31\u591a API (\u901a\u5e38\u662f\u8b80\u53d6\u7248\u9762\u914d\u7f6e\u5e7e\u4f55\u5716\u5f62) \u6703\u5f37\u5236\u8f49\u8b6f\u5f15\u64ce\u66ab\u505c\u6307\u4ee4\u78bc\u57f7\u884c\uff0c\u4ee5\u8a08\u7b97\u6a23\u5f0f\u548c\u7248\u9762\u914d\u7f6e\u3002\u9032\u4e00\u6b65\u77ad\u89e3[\u5f37\u5236\u81ea\u52d5\u91cd\u6392](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing#avoid-forced-synchronous-layouts)\u53ca\u5176\u56e0\u61c9\u63aa\u65bd\u3002"
|
|
310
316
|
},
|
|
@@ -321,7 +327,7 @@
|
|
|
321
327
|
"message": "\u81ea\u52d5\u91cd\u6392\u7e3d\u6642\u9593"
|
|
322
328
|
},
|
|
323
329
|
"models/trace/insights/ForcedReflow.ts | unattributed": {
|
|
324
|
-
"message": "\u627e\u4e0d\u5230\u51fa\u8655"
|
|
330
|
+
"message": "[\u627e\u4e0d\u5230\u51fa\u8655]"
|
|
325
331
|
},
|
|
326
332
|
"models/trace/insights/ImageDelivery.ts | description": {
|
|
327
333
|
"message": "\u7e2e\u77ed\u5716\u7247\u4e0b\u8f09\u6642\u9593\uff0c\u53ef\u7e2e\u6e1b\u4f7f\u7528\u8005\u611f\u77e5\u7684\u7db2\u9801\u8f09\u5165\u6642\u9593\uff0c\u4e26\u63d0\u5347 LCP \u6307\u6a19\u7684\u8868\u73fe\u3002[\u9032\u4e00\u6b65\u77ad\u89e3\u5982\u4f55\u6700\u4f73\u5316\u5716\u7247\u5927\u5c0f](https://developer.chrome.com/docs/lighthouse/performance/uses-optimized-images/)"
|
package/locales/zh.json
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"generated/Deprecation.ts | CanRequestURLHTTPContainingNewline": {
|
|
12
12
|
"message": "\u5982\u679c\u5bf9\u5e94\u7684\u7f51\u5740\u540c\u65f6\u5305\u542b\u5df2\u79fb\u9664\u7684\u7a7a\u767d\u5b57\u7b26 \\(n|r|t) \u548c\u5c0f\u4e8e\u5b57\u7b26 (<)\uff0c\u8d44\u6e90\u8bf7\u6c42\u4f1a\u88ab\u5c4f\u853d\u3002\u8bf7\u4ece\u5143\u7d20\u5c5e\u6027\u503c\u7b49\u4f4d\u7f6e\u79fb\u9664\u6362\u884c\u7b26\u5e76\u7f16\u7801\u5c0f\u4e8e\u5b57\u7b26\uff0c\u4ee5\u4fbf\u52a0\u8f7d\u8fd9\u4e9b\u8d44\u6e90\u3002"
|
|
13
13
|
},
|
|
14
|
+
"generated/Deprecation.ts | CharsetAutoDetectionISO2022JP": {
|
|
15
|
+
"message": "ISO-2022-JP \u5b57\u7b26\u96c6\u7684\u81ea\u52a8\u68c0\u6d4b\u529f\u80fd\u5df2\u88ab\u5f03\u7528\uff0c\u5e76\u5c06\u5728\u4e0d\u4e45\u7684\u5c06\u6765\u505c\u7528\u3002\u8bf7\u5728\u201c\u5185\u5bb9\u7c7b\u578b\u201d\u6807\u5934\u4e2d\u6216\u901a\u8fc7\u4f7f\u7528\u5143\u6807\u8bb0 (https://developer.mozilla.org/zh-CN/docs/Glossary/Character_encoding) \u6307\u5b9a\u5b57\u7b26\u96c6\u3002"
|
|
16
|
+
},
|
|
14
17
|
"generated/Deprecation.ts | ChromeLoadTimesConnectionInfo": {
|
|
15
18
|
"message": "chrome.loadTimes() \u5df2\u88ab\u5f03\u7528\uff0c\u8bf7\u6539\u7528\u6807\u51c6\u5316 API\uff1aNavigation Timing 2\u3002"
|
|
16
19
|
},
|
|
@@ -305,6 +308,9 @@
|
|
|
305
308
|
"models/trace/insights/FontDisplay.ts | wastedTimeColumn": {
|
|
306
309
|
"message": "\u6d6a\u8d39\u7684\u65f6\u95f4"
|
|
307
310
|
},
|
|
311
|
+
"models/trace/insights/ForcedReflow.ts | anonymous": {
|
|
312
|
+
"message": "\uff08\u533f\u540d\uff09"
|
|
313
|
+
},
|
|
308
314
|
"models/trace/insights/ForcedReflow.ts | description": {
|
|
309
315
|
"message": "\u8bb8\u591a API\uff08\u901a\u5e38\u7528\u4e8e\u8bfb\u53d6\u5e03\u5c40\u51e0\u4f55\u56fe\u5f62\u4fe1\u606f\uff09\u4f1a\u5f3a\u5236\u6e32\u67d3\u5f15\u64ce\u6682\u505c\u811a\u672c\u6267\u884c\uff0c\u4ee5\u4fbf\u8ba1\u7b97\u6837\u5f0f\u548c\u5e03\u5c40\u3002\u8be6\u7ec6\u4e86\u89e3[\u5f3a\u5236\u81ea\u52a8\u91cd\u6392](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing#avoid-forced-synchronous-layouts)\u53ca\u5176\u7f13\u89e3\u63aa\u65bd\u3002"
|
|
310
316
|
},
|
|
@@ -321,7 +327,7 @@
|
|
|
321
327
|
"message": "\u603b\u81ea\u52a8\u91cd\u6392\u65f6\u95f4"
|
|
322
328
|
},
|
|
323
329
|
"models/trace/insights/ForcedReflow.ts | unattributed": {
|
|
324
|
-
"message": "\
|
|
330
|
+
"message": "[\u672a\u5f52\u56e0]"
|
|
325
331
|
},
|
|
326
332
|
"models/trace/insights/ImageDelivery.ts | description": {
|
|
327
333
|
"message": "\u7f29\u77ed\u56fe\u7247\u4e0b\u8f7d\u65f6\u95f4\u53ef\u4f18\u5316\u7f51\u9875\u7684\u611f\u77e5\u52a0\u8f7d\u65f6\u95f4\u548c LCP\u3002[\u8be6\u7ec6\u4e86\u89e3\u56fe\u7247\u5927\u5c0f\u4f18\u5316](https://developer.chrome.com/docs/lighthouse/performance/uses-optimized-images/)"
|
package/locales/zu.json
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"generated/Deprecation.ts | CanRequestURLHTTPContainingNewline": {
|
|
12
12
|
"message": "Izicelo zezinsiza ama-URL azo aqukethe womabili ama-whitespace asusiwe wezinhlamvu ze-\\(n|r|t) nezinhlamvu ezingaphansi (<) zivinjiwe. Sicela ususe imigqa emisha futhi ufake ikhodi ngaphansi kwezinhlamvu ezindaweni ezifana namanani esibaluli sesakhi ukuze ulayishe lezi zinsiza."
|
|
13
13
|
},
|
|
14
|
+
"generated/Deprecation.ts | CharsetAutoDetectionISO2022JP": {
|
|
15
|
+
"message": "Ukutholwa okuzenzekelayo kwesethi yezinhlamvu ze-ISO-2022-JP kuhoxisiwe futhi kuzoyekiswa ukusebenza esikhathini esiseduze esizayo. Sicela ucacise isethi yezinhlamvu esihlokweni soHlobo Lwekhontenti noma ngokusebenzisa ithegi ye-meta (https://developer.mozilla.org/en-US/docs/Glossary/Character_encoding)."
|
|
16
|
+
},
|
|
14
17
|
"generated/Deprecation.ts | ChromeLoadTimesConnectionInfo": {
|
|
15
18
|
"message": "I-chrome.loadTimes() yehlisiwe, esikhundleni salokho sebenzisa i-API ejwayelekile: Isikhathi Sokufuna 2."
|
|
16
19
|
},
|
|
@@ -305,6 +308,9 @@
|
|
|
305
308
|
"models/trace/insights/FontDisplay.ts | wastedTimeColumn": {
|
|
306
309
|
"message": "Isikhathi esichithiwe"
|
|
307
310
|
},
|
|
311
|
+
"models/trace/insights/ForcedReflow.ts | anonymous": {
|
|
312
|
+
"message": "(akwaziwa)"
|
|
313
|
+
},
|
|
308
314
|
"models/trace/insights/ForcedReflow.ts | description": {
|
|
309
315
|
"message": "Ama-API amaningi, ngokuvamile ukufunda ijiyomethri yohlaka, aphoqa injini yokunikezela ukuba imise ukusetshenziswa kwesikriphti ukuze abale isitayela nohlaka. Funda kabanzi mayelana [nereflow ephoqelelwe](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing#avoid-forced-synchronous-layouts) kanye nezixazululo zayo."
|
|
310
316
|
},
|
|
@@ -321,7 +327,7 @@
|
|
|
321
327
|
"message": "Isamba sesikhathi sereflow"
|
|
322
328
|
},
|
|
323
329
|
"models/trace/insights/ForcedReflow.ts | unattributed": {
|
|
324
|
-
"message": "
|
|
330
|
+
"message": "[akwabelwanga]"
|
|
325
331
|
},
|
|
326
332
|
"models/trace/insights/ImageDelivery.ts | description": {
|
|
327
333
|
"message": "Ukunciphisa isikhathi sokudawuniloda izithobe kungathuthukisa isikhathi sokulayisha sekhasi esilindelekile kanye ne-LCP. [Funda kabanzi ngokulungiselela ubungakho besithombe](https://developer.chrome.com/docs/lighthouse/performance/uses-optimized-images/)"
|
|
@@ -69,7 +69,7 @@ function findWorkerThreads(trace) {
|
|
|
69
69
|
return workerThreads;
|
|
70
70
|
}
|
|
71
71
|
function createLanternRequest(parsedTrace, workerThreads, request) {
|
|
72
|
-
if (request.args.data.
|
|
72
|
+
if (request.args.data.hasResponse && request.args.data.connectionId === undefined) {
|
|
73
73
|
throw new Lantern.Core.LanternError('Trace is too old');
|
|
74
74
|
}
|
|
75
75
|
let url;
|
|
@@ -141,8 +141,8 @@ function createLanternRequest(parsedTrace, workerThreads, request) {
|
|
|
141
141
|
return {
|
|
142
142
|
rawRequest: request,
|
|
143
143
|
requestId: request.args.data.requestId,
|
|
144
|
-
connectionId: request.args.data.connectionId,
|
|
145
|
-
connectionReused: request.args.data.connectionReused,
|
|
144
|
+
connectionId: request.args.data.connectionId ?? 0,
|
|
145
|
+
connectionReused: request.args.data.connectionReused ?? false,
|
|
146
146
|
url: request.args.data.url,
|
|
147
147
|
protocol: request.args.data.protocol,
|
|
148
148
|
parsedURL: createParsedUrl(url),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanternComputationData.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/LanternComputationData.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAKhD,SAAS,yBAAyB,CAAC,WAAuC,EAAE,OAAe,EAAE,YAAoB;IAE/G,MAAM,WAAW,GAAG,WAAW,CAAC,e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,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG;YAC7B,eAAe,EAAE,EAAE;SACpB,CAAC;QAEF,IAAI,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,OAAO,CAAC,mBAAmB,EAAE,CAAC;YACnC,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;QACxC,CAAC;QACD,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IACpC,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,gBAAgB,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;AACxF,CAAC;AAED,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,yBAAyB,GAC1B,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Protocol from '../../generated/protocol.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Lantern from './lantern/lantern.js';\nimport type * as Types from './types/types.js';\n\ntype NetworkRequest = Lantern.Types.NetworkRequest<Types.Events.SyntheticNetworkRequest>;\n\nfunction createProcessedNavigation(parsedTrace: Handlers.Types.ParsedTrace, frameId: string, navigationId: string):\n Lantern.Types.Simulation.ProcessedNavigation {\n const scoresByNav = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(frameId);\n if (!scoresByNav) {\n throw new Lantern.Core.LanternError('missing metric scores for frame');\n }\n\n const scores = scoresByNav.get(navigationId);\n if (!scores) {\n throw new Lantern.Core.LanternError('missing metric scores for specified navigation');\n }\n\n const getTimestampOrUndefined =\n (metric: Handlers.ModelHandlers.PageLoadMetrics.MetricName): Types.Timing.Micro|undefined => {\n const metricScore = scores.get(metric);\n if (!metricScore?.event) {\n return;\n }\n return metricScore.event.ts;\n };\n const getTimestamp = (metric: Handlers.ModelHandlers.PageLoadMetrics.MetricName): Types.Timing.Micro => {\n const metricScore = scores.get(metric);\n if (!metricScore?.event) {\n throw new Lantern.Core.LanternError(`missing metric: ${metric}`);\n }\n return metricScore.event.ts;\n };\n return {\n timestamps: {\n firstContentfulPaint: getTimestamp(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FCP),\n largestContentfulPaint: getTimestampOrUndefined(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP),\n },\n };\n}\n\nfunction createParsedUrl(url: URL|string): Lantern.Types.ParsedURL {\n if (typeof url === 'string') {\n url = new URL(url);\n }\n return {\n scheme: url.protocol.split(':')[0],\n // Intentional, DevTools uses different terminology\n host: url.hostname,\n securityOrigin: url.origin,\n };\n}\n\n/**\n * Returns a map of `pid` -> `tid[]`.\n */\nfunction findWorkerThreads(trace: Lantern.Types.Trace): Map<number, number[]> {\n // TODO: WorkersHandler in Trace Engine needs to be updated to also include `pid` (only had `tid`).\n const workerThreads = new Map();\n const workerCreationEvents = ['ServiceWorker thread', 'DedicatedWorker thread'];\n\n for (const event of trace.traceEvents) {\n if (event.name !== 'thread_name' || !event.args.name) {\n continue;\n }\n if (!workerCreationEvents.includes(event.args.name)) {\n continue;\n }\n\n const tids = workerThreads.get(event.pid);\n if (tids) {\n tids.push(event.tid);\n } else {\n workerThreads.set(event.pid, [event.tid]);\n }\n }\n\n return workerThreads;\n}\n\nfunction createLanternRequest(\n parsedTrace: Readonly<Handlers.Types.ParsedTrace>, workerThreads: Map<number, number[]>,\n request: Types.Events.SyntheticNetworkRequest): NetworkRequest|undefined {\n if (request.args.data.connectionId === undefined || request.args.data.connectionReused === undefined) {\n throw new Lantern.Core.LanternError('Trace is too old');\n }\n\n let url;\n try {\n url = new URL(request.args.data.url);\n } catch {\n return;\n }\n\n const timing = request.args.data.timing ? {\n // These two timings are not included in the trace.\n workerFetchStart: -1,\n workerRespondWithSettled: -1,\n ...request.args.data.timing,\n } :\n undefined;\n\n const networkRequestTime = timing ? timing.requestTime * 1000 : request.args.data.syntheticData.downloadStart / 1000;\n\n let fromWorker = false;\n const tids = workerThreads.get(request.pid);\n if (tids?.includes(request.tid)) {\n fromWorker = true;\n }\n\n // Trace Engine collects worker thread ids in a different manner than `workerThreads` does.\n // AFAIK these should be equivalent, but in case they are not let's also check this for now.\n if (parsedTrace.Workers.workerIdByThread.has(request.tid)) {\n fromWorker = true;\n }\n\n // `initiator` in the trace does not contain the stack trace for JS-initiated\n // requests. Instead, that is stored in the `stackTrace` property of the SyntheticNetworkRequest.\n // There are some minor differences in the fields, accounted for here.\n // Most importantly, there seems to be fewer frames in the trace than the equivalent\n // events over the CDP. This results in less accuracy in determining the initiator request,\n // which means less edges in the graph, which mean worse results.\n // TODO: Should fix in Chromium.\n const initiator: Lantern.Types.NetworkRequest['initiator'] =\n request.args.data.initiator ?? {type: Protocol.Network.InitiatorType.Other};\n if (request.args.data.stackTrace) {\n const callFrames = request.args.data.stackTrace.map(f => {\n return {\n scriptId: String(f.scriptId) as Protocol.Runtime.ScriptId,\n url: f.url,\n lineNumber: f.lineNumber - 1,\n columnNumber: f.columnNumber - 1,\n functionName: f.functionName,\n };\n });\n initiator.stack = {callFrames};\n // Note: there is no `parent` to set ...\n }\n\n let resourceType = request.args.data.resourceType;\n if (request.args.data.initiator?.fetchType === 'xmlhttprequest') {\n // @ts-expect-error yes XHR is a valid ResourceType. TypeScript const enums are so unhelpful.\n resourceType = 'XHR';\n } else if (request.args.data.initiator?.fetchType === 'fetch') {\n // @ts-expect-error yes Fetch is a valid ResourceType. TypeScript const enums are so unhelpful.\n resourceType = 'Fetch';\n }\n\n // TODO: set decodedBodyLength for data urls in Trace Engine.\n let resourceSize = request.args.data.decodedBodyLength ?? 0;\n if (url.protocol === 'data:' && resourceSize === 0) {\n const commaIndex = url.pathname.indexOf(',');\n if (url.pathname.substring(0, commaIndex).includes(';base64')) {\n resourceSize = atob(url.pathname.substring(commaIndex + 1)).length;\n } else {\n resourceSize = url.pathname.length - commaIndex - 1;\n }\n }\n\n return {\n rawRequest: request,\n requestId: request.args.data.requestId,\n connectionId: request.args.data.connectionId,\n connectionReused: request.args.data.connectionReused,\n url: request.args.data.url,\n protocol: request.args.data.protocol,\n parsedURL: createParsedUrl(url),\n documentURL: request.args.data.requestingFrameUrl,\n rendererStartTime: request.ts / 1000,\n networkRequestTime,\n responseHeadersEndTime: request.args.data.syntheticData.downloadStart / 1000,\n networkEndTime: request.args.data.syntheticData.finishTime / 1000,\n transferSize: request.args.data.encodedDataLength,\n resourceSize,\n fromDiskCache: request.args.data.syntheticData.isDiskCached,\n fromMemoryCache: request.args.data.syntheticData.isMemoryCached,\n isLinkPreload: request.args.data.isLinkPreload,\n finished: request.args.data.finished,\n failed: request.args.data.failed,\n statusCode: request.args.data.statusCode,\n initiator,\n timing,\n resourceType,\n mimeType: request.args.data.mimeType,\n priority: request.args.data.priority,\n frameId: request.args.data.frame,\n fromWorker,\n // Set later.\n redirects: undefined,\n redirectSource: undefined,\n redirectDestination: undefined,\n initiatorRequest: undefined,\n };\n}\n\n/**\n * @param request The request to find the initiator of\n */\nfunction chooseInitiatorRequest(request: NetworkRequest, requestsByURL: Map<string, NetworkRequest[]>): NetworkRequest|\n null {\n if (request.redirectSource) {\n return request.redirectSource;\n }\n\n const initiatorURL = Lantern.Graph.PageDependencyGraph.getNetworkInitiators(request)[0];\n let candidates = requestsByURL.get(initiatorURL) || [];\n // The (valid) initiator must come before the initiated request.\n candidates = candidates.filter(c => {\n return c.responseHeadersEndTime <= request.rendererStartTime && c.finished && !c.failed;\n });\n if (candidates.length > 1) {\n // Disambiguate based on prefetch. Prefetch requests have type 'Other' and cannot\n // initiate requests, so we drop them here.\n const nonPrefetchCandidates =\n candidates.filter(cand => cand.resourceType !== Lantern.Types.NetworkRequestTypes.Other);\n if (nonPrefetchCandidates.length) {\n candidates = nonPrefetchCandidates;\n }\n }\n if (candidates.length > 1) {\n // Disambiguate based on frame. It's likely that the initiator comes from the same frame.\n const sameFrameCandidates = candidates.filter(cand => cand.frameId === request.frameId);\n if (sameFrameCandidates.length) {\n candidates = sameFrameCandidates;\n }\n }\n if (candidates.length > 1 && request.initiator.type === 'parser') {\n // Filter to just Documents when initiator type is parser.\n const documentCandidates =\n candidates.filter(cand => cand.resourceType === Lantern.Types.NetworkRequestTypes.Document);\n if (documentCandidates.length) {\n candidates = documentCandidates;\n }\n }\n if (candidates.length > 1) {\n // If all real loads came from successful preloads (url preloaded and\n // loads came from the cache), filter to link rel=preload request(s).\n const linkPreloadCandidates = candidates.filter(c => c.isLinkPreload);\n if (linkPreloadCandidates.length) {\n const nonPreloadCandidates = candidates.filter(c => !c.isLinkPreload);\n const allPreloaded = nonPreloadCandidates.every(c => c.fromDiskCache || c.fromMemoryCache);\n if (nonPreloadCandidates.length && allPreloaded) {\n candidates = linkPreloadCandidates;\n }\n }\n }\n\n // Only return an initiator if the result is unambiguous.\n return candidates.length === 1 ? candidates[0] : null;\n}\n\nfunction linkInitiators(lanternRequests: NetworkRequest[]): void {\n const requestsByURL = new Map<string, NetworkRequest[]>();\n for (const request of lanternRequests) {\n const requests = requestsByURL.get(request.url) || [];\n requests.push(request);\n requestsByURL.set(request.url, requests);\n }\n\n for (const request of lanternRequests) {\n const initiatorRequest = chooseInitiatorRequest(request, requestsByURL);\n if (initiatorRequest) {\n request.initiatorRequest = initiatorRequest;\n }\n }\n}\n\nfunction createNetworkRequests(\n trace: Lantern.Types.Trace, parsedTrace: Handlers.Types.ParsedTrace, startTime = 0,\n endTime = Number.POSITIVE_INFINITY): NetworkRequest[] {\n const workerThreads = findWorkerThreads(trace);\n\n const lanternRequests: NetworkRequest[] = [];\n for (const request of parsedTrace.NetworkRequests.byTime) {\n if (request.ts >= startTime && request.ts < endTime) {\n const lanternRequest = createLanternRequest(parsedTrace, workerThreads, request);\n if (lanternRequest) {\n lanternRequests.push(lanternRequest);\n }\n }\n }\n\n // Trace Engine consolidates all redirects into a single request object, but lantern needs\n // an entry for each redirected request.\n for (const request of [...lanternRequests]) {\n if (!request.rawRequest) {\n continue;\n }\n\n const redirects = request.rawRequest.args.data.redirects;\n if (!redirects.length) {\n continue;\n }\n\n const requestChain = [];\n for (const redirect of redirects) {\n const redirectedRequest = structuredClone(request);\n\n redirectedRequest.networkRequestTime = redirect.ts / 1000;\n redirectedRequest.rendererStartTime = redirectedRequest.networkRequestTime;\n\n redirectedRequest.networkEndTime = (redirect.ts + redirect.dur) / 1000;\n redirectedRequest.responseHeadersEndTime = redirectedRequest.networkEndTime;\n\n redirectedRequest.timing = {\n requestTime: redirectedRequest.networkRequestTime / 1000,\n receiveHeadersStart: redirectedRequest.responseHeadersEndTime,\n receiveHeadersEnd: redirectedRequest.responseHeadersEndTime,\n proxyStart: -1,\n proxyEnd: -1,\n dnsStart: -1,\n dnsEnd: -1,\n connectStart: -1,\n connectEnd: -1,\n sslStart: -1,\n sslEnd: -1,\n sendStart: -1,\n sendEnd: -1,\n workerStart: -1,\n workerReady: -1,\n workerFetchStart: -1,\n workerRespondWithSettled: -1,\n pushStart: -1,\n pushEnd: -1,\n };\n\n redirectedRequest.url = redirect.url;\n redirectedRequest.parsedURL = createParsedUrl(redirect.url);\n // TODO: Trace Engine is not retaining the actual status code.\n redirectedRequest.statusCode = 302;\n redirectedRequest.resourceType = undefined;\n // TODO: Trace Engine is not retaining transfer size of redirected request.\n redirectedRequest.transferSize = 400;\n requestChain.push(redirectedRequest);\n lanternRequests.push(redirectedRequest);\n }\n requestChain.push(request);\n\n for (let i = 0; i < requestChain.length; i++) {\n const request = requestChain[i];\n if (i > 0) {\n request.redirectSource = requestChain[i - 1];\n request.redirects = requestChain.slice(0, i);\n }\n if (i !== requestChain.length - 1) {\n request.redirectDestination = requestChain[i + 1];\n }\n }\n\n // Apply the `:redirect` requestId convention: only redirects[0].requestId is the actual\n // requestId, all the rest have n occurrences of `:redirect` as a suffix.\n for (let i = 1; i < requestChain.length; i++) {\n requestChain[i].requestId = `${requestChain[i - 1].requestId}:redirect`;\n }\n }\n\n linkInitiators(lanternRequests);\n\n // This would already be sorted by rendererStartTime, if not for the redirect unwrapping done\n // above.\n return lanternRequests.sort((a, b) => a.rendererStartTime - b.rendererStartTime);\n}\n\nfunction collectMainThreadEvents(\n trace: Lantern.Types.Trace, parsedTrace: Handlers.Types.ParsedTrace): Lantern.Types.TraceEvent[] {\n const Meta = parsedTrace.Meta;\n const mainFramePids = Meta.mainFrameNavigations.length ? new Set(Meta.mainFrameNavigations.map(nav => nav.pid)) :\n Meta.topLevelRendererIds;\n\n const rendererPidToTid = new Map();\n for (const pid of mainFramePids) {\n const threads = Meta.threadsInProcess.get(pid) ?? [];\n\n let found = false;\n for (const [tid, thread] of threads) {\n if (thread.args.name === 'CrRendererMain') {\n rendererPidToTid.set(pid, tid);\n found = true;\n break;\n }\n }\n\n if (found) {\n continue;\n }\n\n // `CrRendererMain` can be missing if chrome is launched with the `--single-process` flag.\n // In this case, page tasks will be run in the browser thread.\n for (const [tid, thread] of threads) {\n if (thread.args.name === 'CrBrowserMain') {\n rendererPidToTid.set(pid, tid);\n found = true;\n break;\n }\n }\n }\n\n return trace.traceEvents.filter(e => rendererPidToTid.get(e.pid) === e.tid);\n}\n\nfunction createGraph(\n requests: Lantern.Types.NetworkRequest[], trace: Lantern.Types.Trace, parsedTrace: Handlers.Types.ParsedTrace,\n url?: Lantern.Types.Simulation.URL): Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest> {\n const mainThreadEvents = collectMainThreadEvents(trace, parsedTrace);\n\n // url defines the initial request that the Lantern graph starts at (the root node) and the\n // main document request. These are equal if there are no redirects.\n if (!url) {\n url = {\n requestedUrl: requests[0].url,\n mainDocumentUrl: '',\n };\n\n let request = requests[0];\n while (request.redirectDestination) {\n request = request.redirectDestination;\n }\n url.mainDocumentUrl = request.url;\n }\n\n return Lantern.Graph.PageDependencyGraph.createGraph(mainThreadEvents, requests, url);\n}\n\nexport {\n createGraph,\n createNetworkRequests,\n createProcessedNavigation,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"LanternComputationData.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/LanternComputationData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C,GAAG,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,WAAW,CAChB,QAAwC,EAAE,KAA0B,EAAE,WAAuC,EAC7G,GAAkC;IACpC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAErE,2FAA2F;IAC3F,oEAAoE;IACpE,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG;YACJ,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG;YAC7B,eAAe,EAAE,EAAE;SACpB,CAAC;QAEF,IAAI,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,OAAO,CAAC,mBAAmB,EAAE,CAAC;YACnC,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;QACxC,CAAC;QACD,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IACpC,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,gBAAgB,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;AACxF,CAAC;AAED,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,yBAAyB,GAC1B,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Protocol from '../../generated/protocol.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Lantern from './lantern/lantern.js';\nimport type * as Types from './types/types.js';\n\ntype NetworkRequest = Lantern.Types.NetworkRequest<Types.Events.SyntheticNetworkRequest>;\n\nfunction createProcessedNavigation(parsedTrace: Handlers.Types.ParsedTrace, frameId: string, navigationId: string):\n Lantern.Types.Simulation.ProcessedNavigation {\n const scoresByNav = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(frameId);\n if (!scoresByNav) {\n throw new Lantern.Core.LanternError('missing metric scores for frame');\n }\n\n const scores = scoresByNav.get(navigationId);\n if (!scores) {\n throw new Lantern.Core.LanternError('missing metric scores for specified navigation');\n }\n\n const getTimestampOrUndefined =\n (metric: Handlers.ModelHandlers.PageLoadMetrics.MetricName): Types.Timing.Micro|undefined => {\n const metricScore = scores.get(metric);\n if (!metricScore?.event) {\n return;\n }\n return metricScore.event.ts;\n };\n const getTimestamp = (metric: Handlers.ModelHandlers.PageLoadMetrics.MetricName): Types.Timing.Micro => {\n const metricScore = scores.get(metric);\n if (!metricScore?.event) {\n throw new Lantern.Core.LanternError(`missing metric: ${metric}`);\n }\n return metricScore.event.ts;\n };\n return {\n timestamps: {\n firstContentfulPaint: getTimestamp(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FCP),\n largestContentfulPaint: getTimestampOrUndefined(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP),\n },\n };\n}\n\nfunction createParsedUrl(url: URL|string): Lantern.Types.ParsedURL {\n if (typeof url === 'string') {\n url = new URL(url);\n }\n return {\n scheme: url.protocol.split(':')[0],\n // Intentional, DevTools uses different terminology\n host: url.hostname,\n securityOrigin: url.origin,\n };\n}\n\n/**\n * Returns a map of `pid` -> `tid[]`.\n */\nfunction findWorkerThreads(trace: Lantern.Types.Trace): Map<number, number[]> {\n // TODO: WorkersHandler in Trace Engine needs to be updated to also include `pid` (only had `tid`).\n const workerThreads = new Map();\n const workerCreationEvents = ['ServiceWorker thread', 'DedicatedWorker thread'];\n\n for (const event of trace.traceEvents) {\n if (event.name !== 'thread_name' || !event.args.name) {\n continue;\n }\n if (!workerCreationEvents.includes(event.args.name)) {\n continue;\n }\n\n const tids = workerThreads.get(event.pid);\n if (tids) {\n tids.push(event.tid);\n } else {\n workerThreads.set(event.pid, [event.tid]);\n }\n }\n\n return workerThreads;\n}\n\nfunction createLanternRequest(\n parsedTrace: Readonly<Handlers.Types.ParsedTrace>, workerThreads: Map<number, number[]>,\n request: Types.Events.SyntheticNetworkRequest): NetworkRequest|undefined {\n if (request.args.data.hasResponse && request.args.data.connectionId === undefined) {\n throw new Lantern.Core.LanternError('Trace is too old');\n }\n\n let url;\n try {\n url = new URL(request.args.data.url);\n } catch {\n return;\n }\n\n const timing = request.args.data.timing ? {\n // These two timings are not included in the trace.\n workerFetchStart: -1,\n workerRespondWithSettled: -1,\n ...request.args.data.timing,\n } :\n undefined;\n\n const networkRequestTime = timing ? timing.requestTime * 1000 : request.args.data.syntheticData.downloadStart / 1000;\n\n let fromWorker = false;\n const tids = workerThreads.get(request.pid);\n if (tids?.includes(request.tid)) {\n fromWorker = true;\n }\n\n // Trace Engine collects worker thread ids in a different manner than `workerThreads` does.\n // AFAIK these should be equivalent, but in case they are not let's also check this for now.\n if (parsedTrace.Workers.workerIdByThread.has(request.tid)) {\n fromWorker = true;\n }\n\n // `initiator` in the trace does not contain the stack trace for JS-initiated\n // requests. Instead, that is stored in the `stackTrace` property of the SyntheticNetworkRequest.\n // There are some minor differences in the fields, accounted for here.\n // Most importantly, there seems to be fewer frames in the trace than the equivalent\n // events over the CDP. This results in less accuracy in determining the initiator request,\n // which means less edges in the graph, which mean worse results.\n // TODO: Should fix in Chromium.\n const initiator: Lantern.Types.NetworkRequest['initiator'] =\n request.args.data.initiator ?? {type: Protocol.Network.InitiatorType.Other};\n if (request.args.data.stackTrace) {\n const callFrames = request.args.data.stackTrace.map(f => {\n return {\n scriptId: String(f.scriptId) as Protocol.Runtime.ScriptId,\n url: f.url,\n lineNumber: f.lineNumber - 1,\n columnNumber: f.columnNumber - 1,\n functionName: f.functionName,\n };\n });\n initiator.stack = {callFrames};\n // Note: there is no `parent` to set ...\n }\n\n let resourceType = request.args.data.resourceType;\n if (request.args.data.initiator?.fetchType === 'xmlhttprequest') {\n // @ts-expect-error yes XHR is a valid ResourceType. TypeScript const enums are so unhelpful.\n resourceType = 'XHR';\n } else if (request.args.data.initiator?.fetchType === 'fetch') {\n // @ts-expect-error yes Fetch is a valid ResourceType. TypeScript const enums are so unhelpful.\n resourceType = 'Fetch';\n }\n\n // TODO: set decodedBodyLength for data urls in Trace Engine.\n let resourceSize = request.args.data.decodedBodyLength ?? 0;\n if (url.protocol === 'data:' && resourceSize === 0) {\n const commaIndex = url.pathname.indexOf(',');\n if (url.pathname.substring(0, commaIndex).includes(';base64')) {\n resourceSize = atob(url.pathname.substring(commaIndex + 1)).length;\n } else {\n resourceSize = url.pathname.length - commaIndex - 1;\n }\n }\n\n return {\n rawRequest: request,\n requestId: request.args.data.requestId,\n connectionId: request.args.data.connectionId ?? 0,\n connectionReused: request.args.data.connectionReused ?? false,\n url: request.args.data.url,\n protocol: request.args.data.protocol,\n parsedURL: createParsedUrl(url),\n documentURL: request.args.data.requestingFrameUrl,\n rendererStartTime: request.ts / 1000,\n networkRequestTime,\n responseHeadersEndTime: request.args.data.syntheticData.downloadStart / 1000,\n networkEndTime: request.args.data.syntheticData.finishTime / 1000,\n transferSize: request.args.data.encodedDataLength,\n resourceSize,\n fromDiskCache: request.args.data.syntheticData.isDiskCached,\n fromMemoryCache: request.args.data.syntheticData.isMemoryCached,\n isLinkPreload: request.args.data.isLinkPreload,\n finished: request.args.data.finished,\n failed: request.args.data.failed,\n statusCode: request.args.data.statusCode,\n initiator,\n timing,\n resourceType,\n mimeType: request.args.data.mimeType,\n priority: request.args.data.priority,\n frameId: request.args.data.frame,\n fromWorker,\n // Set later.\n redirects: undefined,\n redirectSource: undefined,\n redirectDestination: undefined,\n initiatorRequest: undefined,\n };\n}\n\n/**\n * @param request The request to find the initiator of\n */\nfunction chooseInitiatorRequest(request: NetworkRequest, requestsByURL: Map<string, NetworkRequest[]>): NetworkRequest|\n null {\n if (request.redirectSource) {\n return request.redirectSource;\n }\n\n const initiatorURL = Lantern.Graph.PageDependencyGraph.getNetworkInitiators(request)[0];\n let candidates = requestsByURL.get(initiatorURL) || [];\n // The (valid) initiator must come before the initiated request.\n candidates = candidates.filter(c => {\n return c.responseHeadersEndTime <= request.rendererStartTime && c.finished && !c.failed;\n });\n if (candidates.length > 1) {\n // Disambiguate based on prefetch. Prefetch requests have type 'Other' and cannot\n // initiate requests, so we drop them here.\n const nonPrefetchCandidates =\n candidates.filter(cand => cand.resourceType !== Lantern.Types.NetworkRequestTypes.Other);\n if (nonPrefetchCandidates.length) {\n candidates = nonPrefetchCandidates;\n }\n }\n if (candidates.length > 1) {\n // Disambiguate based on frame. It's likely that the initiator comes from the same frame.\n const sameFrameCandidates = candidates.filter(cand => cand.frameId === request.frameId);\n if (sameFrameCandidates.length) {\n candidates = sameFrameCandidates;\n }\n }\n if (candidates.length > 1 && request.initiator.type === 'parser') {\n // Filter to just Documents when initiator type is parser.\n const documentCandidates =\n candidates.filter(cand => cand.resourceType === Lantern.Types.NetworkRequestTypes.Document);\n if (documentCandidates.length) {\n candidates = documentCandidates;\n }\n }\n if (candidates.length > 1) {\n // If all real loads came from successful preloads (url preloaded and\n // loads came from the cache), filter to link rel=preload request(s).\n const linkPreloadCandidates = candidates.filter(c => c.isLinkPreload);\n if (linkPreloadCandidates.length) {\n const nonPreloadCandidates = candidates.filter(c => !c.isLinkPreload);\n const allPreloaded = nonPreloadCandidates.every(c => c.fromDiskCache || c.fromMemoryCache);\n if (nonPreloadCandidates.length && allPreloaded) {\n candidates = linkPreloadCandidates;\n }\n }\n }\n\n // Only return an initiator if the result is unambiguous.\n return candidates.length === 1 ? candidates[0] : null;\n}\n\nfunction linkInitiators(lanternRequests: NetworkRequest[]): void {\n const requestsByURL = new Map<string, NetworkRequest[]>();\n for (const request of lanternRequests) {\n const requests = requestsByURL.get(request.url) || [];\n requests.push(request);\n requestsByURL.set(request.url, requests);\n }\n\n for (const request of lanternRequests) {\n const initiatorRequest = chooseInitiatorRequest(request, requestsByURL);\n if (initiatorRequest) {\n request.initiatorRequest = initiatorRequest;\n }\n }\n}\n\nfunction createNetworkRequests(\n trace: Lantern.Types.Trace, parsedTrace: Handlers.Types.ParsedTrace, startTime = 0,\n endTime = Number.POSITIVE_INFINITY): NetworkRequest[] {\n const workerThreads = findWorkerThreads(trace);\n\n const lanternRequests: NetworkRequest[] = [];\n for (const request of parsedTrace.NetworkRequests.byTime) {\n if (request.ts >= startTime && request.ts < endTime) {\n const lanternRequest = createLanternRequest(parsedTrace, workerThreads, request);\n if (lanternRequest) {\n lanternRequests.push(lanternRequest);\n }\n }\n }\n\n // Trace Engine consolidates all redirects into a single request object, but lantern needs\n // an entry for each redirected request.\n for (const request of [...lanternRequests]) {\n if (!request.rawRequest) {\n continue;\n }\n\n const redirects = request.rawRequest.args.data.redirects;\n if (!redirects.length) {\n continue;\n }\n\n const requestChain = [];\n for (const redirect of redirects) {\n const redirectedRequest = structuredClone(request);\n\n redirectedRequest.networkRequestTime = redirect.ts / 1000;\n redirectedRequest.rendererStartTime = redirectedRequest.networkRequestTime;\n\n redirectedRequest.networkEndTime = (redirect.ts + redirect.dur) / 1000;\n redirectedRequest.responseHeadersEndTime = redirectedRequest.networkEndTime;\n\n redirectedRequest.timing = {\n requestTime: redirectedRequest.networkRequestTime / 1000,\n receiveHeadersStart: redirectedRequest.responseHeadersEndTime,\n receiveHeadersEnd: redirectedRequest.responseHeadersEndTime,\n proxyStart: -1,\n proxyEnd: -1,\n dnsStart: -1,\n dnsEnd: -1,\n connectStart: -1,\n connectEnd: -1,\n sslStart: -1,\n sslEnd: -1,\n sendStart: -1,\n sendEnd: -1,\n workerStart: -1,\n workerReady: -1,\n workerFetchStart: -1,\n workerRespondWithSettled: -1,\n pushStart: -1,\n pushEnd: -1,\n };\n\n redirectedRequest.url = redirect.url;\n redirectedRequest.parsedURL = createParsedUrl(redirect.url);\n // TODO: Trace Engine is not retaining the actual status code.\n redirectedRequest.statusCode = 302;\n redirectedRequest.resourceType = undefined;\n // TODO: Trace Engine is not retaining transfer size of redirected request.\n redirectedRequest.transferSize = 400;\n requestChain.push(redirectedRequest);\n lanternRequests.push(redirectedRequest);\n }\n requestChain.push(request);\n\n for (let i = 0; i < requestChain.length; i++) {\n const request = requestChain[i];\n if (i > 0) {\n request.redirectSource = requestChain[i - 1];\n request.redirects = requestChain.slice(0, i);\n }\n if (i !== requestChain.length - 1) {\n request.redirectDestination = requestChain[i + 1];\n }\n }\n\n // Apply the `:redirect` requestId convention: only redirects[0].requestId is the actual\n // requestId, all the rest have n occurrences of `:redirect` as a suffix.\n for (let i = 1; i < requestChain.length; i++) {\n requestChain[i].requestId = `${requestChain[i - 1].requestId}:redirect`;\n }\n }\n\n linkInitiators(lanternRequests);\n\n // This would already be sorted by rendererStartTime, if not for the redirect unwrapping done\n // above.\n return lanternRequests.sort((a, b) => a.rendererStartTime - b.rendererStartTime);\n}\n\nfunction collectMainThreadEvents(\n trace: Lantern.Types.Trace, parsedTrace: Handlers.Types.ParsedTrace): Lantern.Types.TraceEvent[] {\n const Meta = parsedTrace.Meta;\n const mainFramePids = Meta.mainFrameNavigations.length ? new Set(Meta.mainFrameNavigations.map(nav => nav.pid)) :\n Meta.topLevelRendererIds;\n\n const rendererPidToTid = new Map();\n for (const pid of mainFramePids) {\n const threads = Meta.threadsInProcess.get(pid) ?? [];\n\n let found = false;\n for (const [tid, thread] of threads) {\n if (thread.args.name === 'CrRendererMain') {\n rendererPidToTid.set(pid, tid);\n found = true;\n break;\n }\n }\n\n if (found) {\n continue;\n }\n\n // `CrRendererMain` can be missing if chrome is launched with the `--single-process` flag.\n // In this case, page tasks will be run in the browser thread.\n for (const [tid, thread] of threads) {\n if (thread.args.name === 'CrBrowserMain') {\n rendererPidToTid.set(pid, tid);\n found = true;\n break;\n }\n }\n }\n\n return trace.traceEvents.filter(e => rendererPidToTid.get(e.pid) === e.tid);\n}\n\nfunction createGraph(\n requests: Lantern.Types.NetworkRequest[], trace: Lantern.Types.Trace, parsedTrace: Handlers.Types.ParsedTrace,\n url?: Lantern.Types.Simulation.URL): Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest> {\n const mainThreadEvents = collectMainThreadEvents(trace, parsedTrace);\n\n // url defines the initial request that the Lantern graph starts at (the root node) and the\n // main document request. These are equal if there are no redirects.\n if (!url) {\n url = {\n requestedUrl: requests[0].url,\n mainDocumentUrl: '',\n };\n\n let request = requests[0];\n while (request.redirectDestination) {\n request = request.redirectDestination;\n }\n url.mainDocumentUrl = request.url;\n }\n\n return Lantern.Graph.PageDependencyGraph.createGraph(mainThreadEvents, requests, url);\n}\n\nexport {\n createGraph,\n createNetworkRequests,\n createProcessedNavigation,\n};\n"]}
|
|
@@ -36,6 +36,4 @@ export declare class TraceProcessor extends EventTarget {
|
|
|
36
36
|
* @returns A map from trace event handler name to trace event handler whose entries
|
|
37
37
|
* iterate in such a way that each handler is visited after its dependencies.
|
|
38
38
|
*/
|
|
39
|
-
export declare function sortHandlers(traceHandlers: Partial<
|
|
40
|
-
[key in Handlers.Types.HandlerName]: Handlers.Types.Handler;
|
|
41
|
-
}>): Map<Handlers.Types.HandlerName, Handlers.Types.Handler>;
|
|
39
|
+
export declare function sortHandlers(traceHandlers: Partial<Record<Handlers.Types.HandlerName, Handlers.Types.Handler>>): Map<Handlers.Types.HandlerName, Handlers.Types.Handler>;
|
|
@@ -277,7 +277,7 @@ export class TraceProcessor extends EventTarget {
|
|
|
277
277
|
largestContentfulPaint: lcpResult,
|
|
278
278
|
totalBlockingTime: tbtResult,
|
|
279
279
|
};
|
|
280
|
-
return { graph, simulator, metrics };
|
|
280
|
+
return { requests, graph, simulator, metrics };
|
|
281
281
|
}
|
|
282
282
|
/**
|
|
283
283
|
* Sort the insight models based on the impact of each insight's estimated savings, additionally weighted by the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Processor.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/Processor.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,sBAAsB,MAAM,6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C,WAAW,CAAC,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7B,IAAI,SAAS,GAAG,EAAE,CAAC;YACnB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;gBAC9B,IAAI,SAAS,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;oBACzC,SAAS,IAAI,GAAG,OAAO,IAAI,CAAC;gBAC9B,CAAC;YACH,CAAC;YACD,SAAS,IAAI,WAAW,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,mDAAmD,SAAS,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9B,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACrD,YAAY,CAAC,WAAyC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Lantern from './lantern/lantern.js';\nimport * as LanternComputationData from './LanternComputationData.js';\nimport type * as Model from './ModelImpl.js';\nimport * as Types from './types/types.js';\n\nconst enum Status {\n IDLE = 'IDLE',\n PARSING = 'PARSING',\n FINISHED_PARSING = 'FINISHED_PARSING',\n ERRORED_WHILE_PARSING = 'ERRORED_WHILE_PARSING',\n}\n\nexport class TraceParseProgressEvent extends Event {\n static readonly eventName = 'traceparseprogress';\n constructor(public data: Model.TraceParseEventProgressData, init: EventInit = {bubbles: true}) {\n super(TraceParseProgressEvent.eventName, init);\n }\n}\n\n/**\n * Parsing a trace can take time. On large traces we see a breakdown of time like so:\n * - handleEvent() loop: ~20%\n * - finalize() loop: ~60%\n * - shallowClone calls: ~20%\n * The numbers below are set so we can report a progress percentage of [0...1]\n */\nconst enum ProgressPhase {\n HANDLE_EVENT = 0.2,\n FINALIZE = 0.8,\n CLONE = 1.0,\n}\nfunction calculateProgress(value: number, phase: ProgressPhase): number {\n // Finalize values should be [0.2...0.8]\n if (phase === ProgressPhase.FINALIZE) {\n return (value * (ProgressPhase.FINALIZE - ProgressPhase.HANDLE_EVENT)) + ProgressPhase.HANDLE_EVENT;\n }\n return value * phase;\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n [TraceParseProgressEvent.eventName]: TraceParseProgressEvent;\n }\n}\n\nexport class TraceProcessor extends EventTarget {\n // We force the Meta handler to be enabled, so the TraceHandlers type here is\n // the model handlers the user passes in and the Meta handler.\n readonly #traceHandlers: Partial<Handlers.Types.Handlers>;\n #status = Status.IDLE;\n #modelConfiguration = Types.Configuration.defaults();\n #data: Handlers.Types.ParsedTrace|null = null;\n #insights: Insights.Types.TraceInsightSets|null = null;\n\n static createWithAllHandlers(): TraceProcessor {\n return new TraceProcessor(Handlers.ModelHandlers, Types.Configuration.defaults());\n }\n\n /**\n * This function is kept for testing with `stub`.\n */\n static getInsightRunners(): Insights.Types.InsightModelsType {\n return {...Insights.Models};\n }\n\n constructor(traceHandlers: Partial<Handlers.Types.Handlers>, modelConfiguration?: Types.Configuration.Configuration) {\n super();\n\n this.#verifyHandlers(traceHandlers);\n this.#traceHandlers = {\n Meta: Handlers.ModelHandlers.Meta,\n ...traceHandlers,\n };\n if (modelConfiguration) {\n this.#modelConfiguration = modelConfiguration;\n }\n this.#passConfigToHandlers();\n }\n\n #passConfigToHandlers(): void {\n for (const handler of Object.values(this.#traceHandlers)) {\n // Bit of an odd double check, but without this TypeScript refuses to let\n // you call the function as it thinks it might be undefined.\n if ('handleUserConfig' in handler && handler.handleUserConfig) {\n handler.handleUserConfig(this.#modelConfiguration);\n }\n }\n }\n\n /**\n * When the user passes in a set of handlers, we want to ensure that we have all\n * the required handlers. Handlers can depend on other handlers, so if the user\n * passes in FooHandler which depends on BarHandler, they must also pass in\n * BarHandler too. This method verifies that all dependencies are met, and\n * throws if not.\n **/\n #verifyHandlers(providedHandlers: Partial<Handlers.Types.Handlers>): void {\n // Tiny optimisation: if the amount of provided handlers matches the amount\n // of handlers in the Handlers.ModelHandlers object, that means that the\n // user has passed in every handler we have. So therefore they cannot have\n // missed any, and there is no need to iterate through the handlers and\n // check the dependencies.\n if (Object.keys(providedHandlers).length === Object.keys(Handlers.ModelHandlers).length) {\n return;\n }\n const requiredHandlerKeys = new Set<Handlers.Types.HandlerName>();\n for (const [handlerName, handler] of Object.entries(providedHandlers)) {\n requiredHandlerKeys.add(handlerName as Handlers.Types.HandlerName);\n const deps = 'deps' in handler ? handler.deps() : [];\n for (const depName of deps) {\n requiredHandlerKeys.add(depName);\n }\n }\n\n const providedHandlerKeys = new Set(Object.keys(providedHandlers));\n // We always force the Meta handler to be enabled when creating the\n // Processor, so if it is missing from the set the user gave us that is OK,\n // as we will have enabled it anyway.\n requiredHandlerKeys.delete('Meta');\n\n for (const requiredKey of requiredHandlerKeys) {\n if (!providedHandlerKeys.has(requiredKey)) {\n throw new Error(`Required handler ${requiredKey} not provided.`);\n }\n }\n }\n\n reset(): void {\n if (this.#status === Status.PARSING) {\n throw new Error('Trace processor can\\'t reset while parsing.');\n }\n\n const handlers = Object.values(this.#traceHandlers);\n for (const handler of handlers) {\n handler.reset();\n }\n\n this.#data = null;\n this.#insights = null;\n this.#status = Status.IDLE;\n }\n\n async parse(traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions): Promise<void> {\n if (this.#status !== Status.IDLE) {\n throw new Error(`Trace processor can't start parsing when not idle. Current state: ${this.#status}`);\n }\n\n options.logger?.start('total');\n try {\n this.#status = Status.PARSING;\n options.logger?.start('parse');\n await this.#computeParsedTrace(traceEvents, options);\n options.logger?.end('parse');\n if (this.#data && !options.isCPUProfile) { // We do not calculate insights for CPU Profiles.\n options.logger?.start('insights');\n this.#computeInsights(this.#data, traceEvents, options);\n options.logger?.end('insights');\n }\n this.#status = Status.FINISHED_PARSING;\n } catch (e) {\n this.#status = Status.ERRORED_WHILE_PARSING;\n throw e;\n } finally {\n options.logger?.end('total');\n }\n }\n\n /**\n * Run all the handlers and set the result to `#data`.\n */\n async #computeParsedTrace(traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions):\n Promise<void> {\n /**\n * We want to yield regularly to maintain responsiveness. If we yield too often, we're wasting idle time.\n * We could do this by checking `performance.now()` regularly, but it's an expensive call in such a hot loop.\n * `eventsPerChunk` is an approximated proxy metric.\n * But how big a chunk? We're aiming for long tasks that are no smaller than 100ms and not bigger than 200ms.\n * It's CPU dependent, so it should be calibrated on oldish hardware.\n * Illustration of a previous change to `eventsPerChunk`: https://imgur.com/wzp8BnR\n */\n const eventsPerChunk = 50_000;\n // Convert to array so that we are able to iterate all handlers multiple times.\n const sortedHandlers = [...sortHandlers(this.#traceHandlers).entries()];\n\n // Reset.\n for (const [, handler] of sortedHandlers) {\n handler.reset();\n }\n\n options.logger?.start('parse:handleEvent');\n\n // Handle each event.\n for (let i = 0; i < traceEvents.length; ++i) {\n // Every so often we take a break just to render.\n if (i % eventsPerChunk === 0 && i) {\n // Take the opportunity to provide status update events.\n const percent = calculateProgress(i / traceEvents.length, ProgressPhase.HANDLE_EVENT);\n this.dispatchEvent(new TraceParseProgressEvent({percent}));\n // TODO(paulirish): consider using `scheduler.yield()` or `scheduler.postTask(() => {}, {priority: 'user-blocking'})`\n await new Promise(resolve => setTimeout(resolve, 0));\n }\n const event = traceEvents[i];\n for (let j = 0; j < sortedHandlers.length; ++j) {\n const [, handler] = sortedHandlers[j];\n handler.handleEvent(event);\n }\n }\n\n options.logger?.end('parse:handleEvent');\n\n // Finalize.\n for (let i = 0; i < sortedHandlers.length; i++) {\n const [name, handler] = sortedHandlers[i];\n if (handler.finalize) {\n options.logger?.start(`parse:${name}:finalize`);\n // Yield to the UI because finalize() calls can be expensive\n // TODO(jacktfranklin): consider using `scheduler.yield()` or `scheduler.postTask(() => {}, {priority: 'user-blocking'})`\n await new Promise(resolve => setTimeout(resolve, 0));\n await handler.finalize(options);\n options.logger?.end(`parse:${name}:finalize`);\n }\n const percent = calculateProgress(i / sortedHandlers.length, ProgressPhase.FINALIZE);\n this.dispatchEvent(new TraceParseProgressEvent({percent}));\n }\n\n // Handlers that depend on other handlers do so via .data(), which used to always\n // return a shallow clone of its internal data structures. However, that pattern\n // easily results in egregious amounts of allocation. Now .data() does not do any\n // cloning, and it happens here instead so that users of the trace processor may\n // still assume that the parsed data is theirs.\n // See: crbug/41484172\n const shallowClone = (value: unknown, recurse = true): unknown => {\n if (value instanceof Map) {\n return new Map(value);\n }\n if (value instanceof Set) {\n return new Set(value);\n }\n if (Array.isArray(value)) {\n return [...value];\n }\n if (typeof value === 'object' && value && recurse) {\n const obj: Record<string, unknown> = {};\n for (const [key, v] of Object.entries(value)) {\n obj[key] = shallowClone(v, false);\n }\n return obj;\n }\n return value;\n };\n\n options.logger?.start('parse:clone');\n const parsedTrace = {};\n for (const [name, handler] of Object.entries(this.#traceHandlers)) {\n const data = shallowClone(handler.data());\n Object.assign(parsedTrace, {[name]: data});\n }\n options.logger?.end('parse:clone');\n\n this.dispatchEvent(new TraceParseProgressEvent({percent: ProgressPhase.CLONE}));\n\n this.#data = parsedTrace as Handlers.Types.ParsedTrace;\n }\n\n get parsedTrace(): Handlers.Types.ParsedTrace|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n return this.#data;\n }\n\n get insights(): Insights.Types.TraceInsightSets|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n return this.#insights;\n }\n\n #createLanternContext(\n parsedTrace: Handlers.Types.ParsedTrace, traceEvents: readonly Types.Events.Event[], frameId: string,\n navigationId: string, options: Types.Configuration.ParseOptions): Insights.Types.LanternContext|undefined {\n // Check for required handlers.\n if (!parsedTrace.NetworkRequests || !parsedTrace.Workers || !parsedTrace.PageLoadMetrics) {\n return;\n }\n if (!parsedTrace.NetworkRequests.byTime.length) {\n throw new Lantern.Core.LanternError('No network requests found in trace');\n }\n\n const navStarts = parsedTrace.Meta.navigationsByFrameId.get(frameId);\n const navStartIndex = navStarts?.findIndex(n => n.args.data?.navigationId === navigationId);\n if (!navStarts || navStartIndex === undefined || navStartIndex === -1) {\n throw new Lantern.Core.LanternError('Could not find navigation start');\n }\n\n const startTime = navStarts[navStartIndex].ts;\n const endTime = navStartIndex + 1 < navStarts.length ? navStarts[navStartIndex + 1].ts : Number.POSITIVE_INFINITY;\n const boundedTraceEvents = traceEvents.filter(e => e.ts >= startTime && e.ts < endTime);\n\n // Lantern.Types.TraceEvent and Types.Events.Event represent the same\n // object - a trace event - but one is more flexible than the other. It should be safe to cast between them.\n const trace: Lantern.Types.Trace = {\n traceEvents: boundedTraceEvents as unknown as Lantern.Types.TraceEvent[],\n };\n\n const requests = LanternComputationData.createNetworkRequests(trace, parsedTrace, startTime, endTime);\n const graph = LanternComputationData.createGraph(requests, trace, parsedTrace);\n const processedNavigation = LanternComputationData.createProcessedNavigation(parsedTrace, frameId, navigationId);\n\n const networkAnalysis = Lantern.Core.NetworkAnalyzer.analyze(requests);\n if (!networkAnalysis) {\n return;\n }\n\n const lanternSettings: Lantern.Types.Simulation.Settings = {\n // TODO(crbug.com/372674229): if devtools throttling was on, does this network analysis capture\n // that? Do we need to set 'devtools' throttlingMethod?\n networkAnalysis,\n throttlingMethod: 'provided',\n ...options.lanternSettings,\n };\n const simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest> =\n Lantern.Simulation.Simulator.createSimulator(lanternSettings);\n\n const computeData = {graph, simulator, processedNavigation};\n const fcpResult = Lantern.Metrics.FirstContentfulPaint.compute(computeData);\n const lcpResult = Lantern.Metrics.LargestContentfulPaint.compute(computeData, {fcpResult});\n const interactiveResult = Lantern.Metrics.Interactive.compute(computeData, {lcpResult});\n const tbtResult = Lantern.Metrics.TotalBlockingTime.compute(computeData, {fcpResult, interactiveResult});\n const metrics = {\n firstContentfulPaint: fcpResult,\n interactive: interactiveResult,\n largestContentfulPaint: lcpResult,\n totalBlockingTime: tbtResult,\n };\n\n return {graph, simulator, metrics};\n }\n\n /**\n * Sort the insight models based on the impact of each insight's estimated savings, additionally weighted by the\n * worst metrics according to field data (if present).\n */\n sortInsightSet(insightSet: Insights.Types.InsightSet, metadata: Types.File.MetaData|null): void {\n // The initial order of the insights is alphabetical, based on `front_end/models/trace/insights/Models.ts`.\n // The order here provides a baseline that groups insights in a more logical way.\n const baselineOrder: Record<keyof Insights.Types.InsightModels, null> = {\n InteractionToNextPaint: null,\n LCPPhases: null,\n LCPDiscovery: null,\n CLSCulprits: null,\n RenderBlocking: null,\n NetworkDependencyTree: null,\n ImageDelivery: null,\n DocumentLatency: null,\n FontDisplay: null,\n Viewport: null,\n DOMSize: null,\n ThirdParties: null,\n DuplicatedJavaScript: null,\n SlowCSSSelector: null,\n ForcedReflow: null,\n Cache: null,\n ModernHTTP: null,\n LegacyJavaScript: null,\n };\n\n // Determine the weights for each metric based on field data, utilizing the same scoring curve that Lighthouse uses.\n const weights = Insights.Common.calculateMetricWeightsForSorting(insightSet, metadata);\n\n // Normalize the estimated savings to a single number, weighted by its relative impact\n // to the page experience based on the same scoring curve that Lighthouse uses.\n const observedLcpMicro = Insights.Common.getLCP(this.#insights, insightSet.id)?.value;\n const observedLcp = observedLcpMicro ? Helpers.Timing.microToMilli(observedLcpMicro) : Types.Timing.Milli(0);\n const observedCls = Insights.Common.getCLS(this.#insights, insightSet.id).value;\n\n // INP is special - if users did not interact with the page, we'll have no INP, but we should still\n // be able to prioritize insights based on this metric. When we observe no interaction, instead use\n // a default value for the baseline INP.\n const observedInpMicro = Insights.Common.getINP(this.#insights, insightSet.id)?.value;\n const observedInp = observedInpMicro ? Helpers.Timing.microToMilli(observedInpMicro) : Types.Timing.Milli(200);\n\n const observedLcpScore =\n observedLcp !== undefined ? Insights.Common.evaluateLCPMetricScore(observedLcp) : undefined;\n const observedInpScore = Insights.Common.evaluateINPMetricScore(observedInp);\n const observedClsScore = Insights.Common.evaluateCLSMetricScore(observedCls);\n\n const insightToSortingRank = new Map<string, number>();\n for (const [name, model] of Object.entries(insightSet.model)) {\n const lcp = model.metricSavings?.LCP ?? 0;\n const inp = model.metricSavings?.INP ?? 0;\n const cls = model.metricSavings?.CLS ?? 0;\n\n const lcpPostSavings =\n observedLcp !== undefined ? Math.max(0, observedLcp - lcp) as Types.Timing.Milli : undefined;\n const inpPostSavings = Math.max(0, observedInp - inp) as Types.Timing.Milli;\n const clsPostSavings = Math.max(0, observedCls - cls);\n\n let score = 0;\n if (weights.lcp && lcp && observedLcpScore !== undefined && lcpPostSavings !== undefined) {\n score += weights.lcp * (Insights.Common.evaluateLCPMetricScore(lcpPostSavings) - observedLcpScore);\n }\n if (weights.inp && inp && observedInpScore !== undefined) {\n score += weights.inp * (Insights.Common.evaluateINPMetricScore(inpPostSavings) - observedInpScore);\n }\n if (weights.cls && cls && observedClsScore !== undefined) {\n score += weights.cls * (Insights.Common.evaluateCLSMetricScore(clsPostSavings) - observedClsScore);\n }\n\n insightToSortingRank.set(name, score);\n }\n\n // Now perform the actual sorting.\n const baselineOrderKeys = Object.keys(baselineOrder);\n const orderedKeys = Object.keys(insightSet.model);\n orderedKeys.sort((a, b) => {\n const a1 = baselineOrderKeys.indexOf(a);\n const b1 = baselineOrderKeys.indexOf(b);\n if (a1 >= 0 && b1 >= 0) {\n return a1 - b1;\n }\n if (a1 >= 0) {\n return -1;\n }\n if (b1 >= 0) {\n return 1;\n }\n return 0;\n });\n orderedKeys.sort((a, b) => (insightToSortingRank.get(b) ?? 0) - (insightToSortingRank.get(a) ?? 0));\n\n const newModel = {} as Insights.Types.InsightModels;\n for (const key of orderedKeys as Array<keyof Insights.Types.InsightModels>) {\n const model = insightSet.model[key];\n // @ts-expect-error Maybe someday typescript will be powerful enough to handle this.\n newModel[key] = model;\n }\n insightSet.model = newModel;\n }\n\n #computeInsightSet(\n parsedTrace: Handlers.Types.ParsedTrace, context: Insights.Types.InsightSetContext,\n options: Types.Configuration.ParseOptions): void {\n let id, urlString, navigation;\n if (context.navigation) {\n id = context.navigationId;\n urlString =\n parsedTrace.Meta.finalDisplayUrlByNavigationId.get(context.navigationId) ?? parsedTrace.Meta.mainFrameURL;\n navigation = context.navigation;\n } else {\n id = Types.Events.NO_NAVIGATION;\n urlString = parsedTrace.Meta.finalDisplayUrlByNavigationId.get('') ?? parsedTrace.Meta.mainFrameURL;\n }\n\n const model = {} as Insights.Types.InsightSet['model'];\n\n for (const [name, insight] of Object.entries(TraceProcessor.getInsightRunners())) {\n let insightResult;\n try {\n options.logger?.start(`insights:${name}`);\n insightResult = insight.generateInsight(parsedTrace, context);\n insightResult.frameId = context.frameId;\n const navId = context.navigation?.args.data?.navigationId;\n if (navId) {\n insightResult.navigationId = navId;\n }\n } catch (err) {\n insightResult = err;\n } finally {\n options.logger?.end(`insights:${name}`);\n }\n Object.assign(model, {[name]: insightResult});\n }\n\n let url;\n try {\n url = new URL(urlString);\n } catch {\n // We're pretty sure this only happens for our test fixture: missing-url.json.gz. Shouldn't\n // happen for real traces.\n return;\n }\n\n const insightSet: Insights.Types.InsightSet = {\n id,\n url,\n navigation,\n frameId: context.frameId,\n bounds: context.bounds,\n model,\n };\n if (!this.#insights) {\n this.#insights = new Map();\n }\n this.#insights.set(insightSet.id, insightSet);\n this.sortInsightSet(insightSet, options.metadata ?? null);\n }\n\n /**\n * Run all the insights and set the result to `#insights`.\n */\n #computeInsights(\n parsedTrace: Handlers.Types.ParsedTrace, traceEvents: readonly Types.Events.Event[],\n options: Types.Configuration.ParseOptions): void {\n // This insights map will be populated by the helper methods.\n this.#insights = new Map();\n\n // Filter main frame navigations to those that have the necessary data (frameId and navigationId).\n // TODO(cjamcl): Does this filtering makes the \"use the next nav as the end time\" logic potentially broken? Are navs without nav id or frame even real?\n const navigations = parsedTrace.Meta.mainFrameNavigations.filter(\n navigation => navigation.args.frame && navigation.args.data?.navigationId);\n\n this.#computeInsightsForInitialTracePeriod(parsedTrace, navigations, options);\n\n for (const [index, navigation] of navigations.entries()) {\n const min = navigation.ts;\n // Use trace end for the last navigation, otherwise use the start of the next navigation.\n const max = index + 1 < navigations.length ? navigations[index + 1].ts : parsedTrace.Meta.traceBounds.max;\n const bounds = Helpers.Timing.traceWindowFromMicroSeconds(min, max);\n this.#computeInsightsForNavigation(navigation, bounds, parsedTrace, traceEvents, options);\n }\n }\n\n /**\n * Computes insights for the period before the first navigation, or for the entire trace if no navigations exist.\n */\n #computeInsightsForInitialTracePeriod(\n parsedTrace: Handlers.Types.ParsedTrace, navigations: readonly Types.Events.NavigationStart[],\n options: Types.Configuration.ParseOptions): void {\n // Determine bounds: Use the period before the first navigation if navigations exist, otherwise use the entire trace bounds.\n const bounds = navigations.length > 0 ?\n Helpers.Timing.traceWindowFromMicroSeconds(parsedTrace.Meta.traceBounds.min, navigations[0].ts) :\n parsedTrace.Meta.traceBounds;\n\n // Define threshold for considering the pre-navigation period significant enough to analyze.\n // When using \"Record and reload\" option, it typically takes ~5ms. So use 50ms to be safe.\n const threshold = Helpers.Timing.milliToMicro(50 as Types.Timing.Milli);\n\n // Compute insights if either:\n // 1. There are no navigations (we analyze the whole trace).\n // 2. There are navigations, AND the initial period before the first navigation is longer than the threshold.\n const shouldComputeInsights = navigations.length === 0 || bounds.range > threshold;\n\n // If navigations exist but the initial period is below the threshold, we intentionally do nothing for this portion of the trace.\n if (shouldComputeInsights) {\n const context: Insights.Types.InsightSetContext = {\n bounds,\n frameId: parsedTrace.Meta.mainFrameId,\n // No navigation or lantern context applies to this initial/no-navigation period.\n };\n this.#computeInsightSet(parsedTrace, context, options);\n }\n }\n\n /**\n * Computes insights for a specific navigation event.\n */\n #computeInsightsForNavigation(\n navigation: Types.Events.NavigationStart, bounds: Types.Timing.TraceWindowMicro,\n parsedTrace: Handlers.Types.ParsedTrace, traceEvents: readonly Types.Events.Event[],\n options: Types.Configuration.ParseOptions): void {\n const frameId = navigation.args.frame;\n // Guaranteed by the filter in #computeInsights\n const navigationId = navigation.args.data?.navigationId as string;\n\n // The lantern sub-context is optional on InsightSetContext, so not setting it is OK.\n // This is also a hedge against an error inside Lantern resulting in breaking the entire performance panel.\n // Additionally, many trace fixtures are too old to be processed by Lantern.\n let lantern: Insights.Types.LanternContext|undefined;\n try {\n options.logger?.start('insights:createLanternContext');\n lantern = this.#createLanternContext(parsedTrace, traceEvents, frameId, navigationId, options);\n } catch (e) {\n // Handle Lantern errors gracefully\n // Don't allow an error in constructing the Lantern graphs to break the rest of the trace processor.\n // Log unexpected errors, but suppress anything that occurs from a trace being too old.\n // Otherwise tests using old fixtures become way too noisy.\n const expectedErrors = [\n 'mainDocumentRequest not found',\n 'missing metric scores for main frame',\n 'missing metric: FCP',\n 'missing metric: LCP',\n 'No network requests found in trace',\n 'Trace is too old',\n ];\n if (!(e instanceof Lantern.Core.LanternError)) {\n // If this wasn't a managed LanternError, the stack trace is likely needed for debugging.\n console.error(e);\n } else if (!expectedErrors.some(err => e.message === err)) {\n // To reduce noise from tests, only print errors that are not expected to occur because a trace is\n // too old (for which there is no single check).\n console.error(e);\n }\n } finally {\n options.logger?.end('insights:createLanternContext');\n }\n\n const context: Insights.Types.InsightSetContext = {\n bounds,\n frameId,\n navigation,\n navigationId,\n lantern,\n };\n this.#computeInsightSet(parsedTrace, context, options);\n }\n}\n\n/**\n * Some Handlers need data provided by others. Dependencies of a handler handler are\n * declared in the `deps` field.\n * @returns A map from trace event handler name to trace event handler whose entries\n * iterate in such a way that each handler is visited after its dependencies.\n */\nexport function sortHandlers(traceHandlers: Partial<{[key in Handlers.Types.HandlerName]: Handlers.Types.Handler}>):\n Map<Handlers.Types.HandlerName, Handlers.Types.Handler> {\n const sortedMap = new Map<Handlers.Types.HandlerName, Handlers.Types.Handler>();\n const visited = new Set<Handlers.Types.HandlerName>();\n const visitHandler = (handlerName: Handlers.Types.HandlerName): void => {\n if (sortedMap.has(handlerName)) {\n return;\n }\n if (visited.has(handlerName)) {\n let stackPath = '';\n for (const handler of visited) {\n if (stackPath || handler === handlerName) {\n stackPath += `${handler}->`;\n }\n }\n stackPath += handlerName;\n throw new Error(`Found dependency cycle in trace event handlers: ${stackPath}`);\n }\n visited.add(handlerName);\n const handler = traceHandlers[handlerName];\n if (!handler) {\n return;\n }\n const deps = handler.deps?.();\n if (deps) {\n deps.forEach(visitHandler);\n }\n sortedMap.set(handlerName, handler);\n };\n\n for (const handlerName of Object.keys(traceHandlers)) {\n visitHandler(handlerName as Handlers.Types.HandlerName);\n }\n return sortedMap;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Processor.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/Processor.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAEtE,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAS1C,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAE7B;IADnB,MAAM,CAAU,SAAS,GAAG,oBAAoB,CAAC;IACjD,YAAmB,IAAuC,EA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AAM,OAAO,IAAI,OAAO,EAAE,CAAC;gBAC9B,IAAI,SAAS,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;oBACzC,SAAS,IAAI,GAAG,OAAO,IAAI,CAAC;gBAC9B,CAAC;YACH,CAAC;YACD,SAAS,IAAI,WAAW,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,mDAAmD,SAAS,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9B,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACrD,YAAY,CAAC,WAAyC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Lantern from './lantern/lantern.js';\nimport * as LanternComputationData from './LanternComputationData.js';\nimport type * as Model from './ModelImpl.js';\nimport * as Types from './types/types.js';\n\nconst enum Status {\n IDLE = 'IDLE',\n PARSING = 'PARSING',\n FINISHED_PARSING = 'FINISHED_PARSING',\n ERRORED_WHILE_PARSING = 'ERRORED_WHILE_PARSING',\n}\n\nexport class TraceParseProgressEvent extends Event {\n static readonly eventName = 'traceparseprogress';\n constructor(public data: Model.TraceParseEventProgressData, init: EventInit = {bubbles: true}) {\n super(TraceParseProgressEvent.eventName, init);\n }\n}\n\n/**\n * Parsing a trace can take time. On large traces we see a breakdown of time like so:\n * - handleEvent() loop: ~20%\n * - finalize() loop: ~60%\n * - shallowClone calls: ~20%\n * The numbers below are set so we can report a progress percentage of [0...1]\n */\nconst enum ProgressPhase {\n HANDLE_EVENT = 0.2,\n FINALIZE = 0.8,\n CLONE = 1.0,\n}\nfunction calculateProgress(value: number, phase: ProgressPhase): number {\n // Finalize values should be [0.2...0.8]\n if (phase === ProgressPhase.FINALIZE) {\n return (value * (ProgressPhase.FINALIZE - ProgressPhase.HANDLE_EVENT)) + ProgressPhase.HANDLE_EVENT;\n }\n return value * phase;\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n [TraceParseProgressEvent.eventName]: TraceParseProgressEvent;\n }\n}\n\nexport class TraceProcessor extends EventTarget {\n // We force the Meta handler to be enabled, so the TraceHandlers type here is\n // the model handlers the user passes in and the Meta handler.\n readonly #traceHandlers: Partial<Handlers.Types.Handlers>;\n #status = Status.IDLE;\n #modelConfiguration = Types.Configuration.defaults();\n #data: Handlers.Types.ParsedTrace|null = null;\n #insights: Insights.Types.TraceInsightSets|null = null;\n\n static createWithAllHandlers(): TraceProcessor {\n return new TraceProcessor(Handlers.ModelHandlers, Types.Configuration.defaults());\n }\n\n /**\n * This function is kept for testing with `stub`.\n */\n static getInsightRunners(): Insights.Types.InsightModelsType {\n return {...Insights.Models};\n }\n\n constructor(traceHandlers: Partial<Handlers.Types.Handlers>, modelConfiguration?: Types.Configuration.Configuration) {\n super();\n\n this.#verifyHandlers(traceHandlers);\n this.#traceHandlers = {\n Meta: Handlers.ModelHandlers.Meta,\n ...traceHandlers,\n };\n if (modelConfiguration) {\n this.#modelConfiguration = modelConfiguration;\n }\n this.#passConfigToHandlers();\n }\n\n #passConfigToHandlers(): void {\n for (const handler of Object.values(this.#traceHandlers)) {\n // Bit of an odd double check, but without this TypeScript refuses to let\n // you call the function as it thinks it might be undefined.\n if ('handleUserConfig' in handler && handler.handleUserConfig) {\n handler.handleUserConfig(this.#modelConfiguration);\n }\n }\n }\n\n /**\n * When the user passes in a set of handlers, we want to ensure that we have all\n * the required handlers. Handlers can depend on other handlers, so if the user\n * passes in FooHandler which depends on BarHandler, they must also pass in\n * BarHandler too. This method verifies that all dependencies are met, and\n * throws if not.\n **/\n #verifyHandlers(providedHandlers: Partial<Handlers.Types.Handlers>): void {\n // Tiny optimisation: if the amount of provided handlers matches the amount\n // of handlers in the Handlers.ModelHandlers object, that means that the\n // user has passed in every handler we have. So therefore they cannot have\n // missed any, and there is no need to iterate through the handlers and\n // check the dependencies.\n if (Object.keys(providedHandlers).length === Object.keys(Handlers.ModelHandlers).length) {\n return;\n }\n const requiredHandlerKeys = new Set<Handlers.Types.HandlerName>();\n for (const [handlerName, handler] of Object.entries(providedHandlers)) {\n requiredHandlerKeys.add(handlerName as Handlers.Types.HandlerName);\n const deps = 'deps' in handler ? handler.deps() : [];\n for (const depName of deps) {\n requiredHandlerKeys.add(depName);\n }\n }\n\n const providedHandlerKeys = new Set(Object.keys(providedHandlers));\n // We always force the Meta handler to be enabled when creating the\n // Processor, so if it is missing from the set the user gave us that is OK,\n // as we will have enabled it anyway.\n requiredHandlerKeys.delete('Meta');\n\n for (const requiredKey of requiredHandlerKeys) {\n if (!providedHandlerKeys.has(requiredKey)) {\n throw new Error(`Required handler ${requiredKey} not provided.`);\n }\n }\n }\n\n reset(): void {\n if (this.#status === Status.PARSING) {\n throw new Error('Trace processor can\\'t reset while parsing.');\n }\n\n const handlers = Object.values(this.#traceHandlers);\n for (const handler of handlers) {\n handler.reset();\n }\n\n this.#data = null;\n this.#insights = null;\n this.#status = Status.IDLE;\n }\n\n async parse(traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions): Promise<void> {\n if (this.#status !== Status.IDLE) {\n throw new Error(`Trace processor can't start parsing when not idle. Current state: ${this.#status}`);\n }\n\n options.logger?.start('total');\n try {\n this.#status = Status.PARSING;\n options.logger?.start('parse');\n await this.#computeParsedTrace(traceEvents, options);\n options.logger?.end('parse');\n if (this.#data && !options.isCPUProfile) { // We do not calculate insights for CPU Profiles.\n options.logger?.start('insights');\n this.#computeInsights(this.#data, traceEvents, options);\n options.logger?.end('insights');\n }\n this.#status = Status.FINISHED_PARSING;\n } catch (e) {\n this.#status = Status.ERRORED_WHILE_PARSING;\n throw e;\n } finally {\n options.logger?.end('total');\n }\n }\n\n /**\n * Run all the handlers and set the result to `#data`.\n */\n async #computeParsedTrace(traceEvents: readonly Types.Events.Event[], options: Types.Configuration.ParseOptions):\n Promise<void> {\n /**\n * We want to yield regularly to maintain responsiveness. If we yield too often, we're wasting idle time.\n * We could do this by checking `performance.now()` regularly, but it's an expensive call in such a hot loop.\n * `eventsPerChunk` is an approximated proxy metric.\n * But how big a chunk? We're aiming for long tasks that are no smaller than 100ms and not bigger than 200ms.\n * It's CPU dependent, so it should be calibrated on oldish hardware.\n * Illustration of a previous change to `eventsPerChunk`: https://imgur.com/wzp8BnR\n */\n const eventsPerChunk = 50_000;\n // Convert to array so that we are able to iterate all handlers multiple times.\n const sortedHandlers = [...sortHandlers(this.#traceHandlers).entries()];\n\n // Reset.\n for (const [, handler] of sortedHandlers) {\n handler.reset();\n }\n\n options.logger?.start('parse:handleEvent');\n\n // Handle each event.\n for (let i = 0; i < traceEvents.length; ++i) {\n // Every so often we take a break just to render.\n if (i % eventsPerChunk === 0 && i) {\n // Take the opportunity to provide status update events.\n const percent = calculateProgress(i / traceEvents.length, ProgressPhase.HANDLE_EVENT);\n this.dispatchEvent(new TraceParseProgressEvent({percent}));\n // TODO(paulirish): consider using `scheduler.yield()` or `scheduler.postTask(() => {}, {priority: 'user-blocking'})`\n await new Promise(resolve => setTimeout(resolve, 0));\n }\n const event = traceEvents[i];\n for (let j = 0; j < sortedHandlers.length; ++j) {\n const [, handler] = sortedHandlers[j];\n handler.handleEvent(event);\n }\n }\n\n options.logger?.end('parse:handleEvent');\n\n // Finalize.\n for (let i = 0; i < sortedHandlers.length; i++) {\n const [name, handler] = sortedHandlers[i];\n if (handler.finalize) {\n options.logger?.start(`parse:${name}:finalize`);\n // Yield to the UI because finalize() calls can be expensive\n // TODO(jacktfranklin): consider using `scheduler.yield()` or `scheduler.postTask(() => {}, {priority: 'user-blocking'})`\n await new Promise(resolve => setTimeout(resolve, 0));\n await handler.finalize(options);\n options.logger?.end(`parse:${name}:finalize`);\n }\n const percent = calculateProgress(i / sortedHandlers.length, ProgressPhase.FINALIZE);\n this.dispatchEvent(new TraceParseProgressEvent({percent}));\n }\n\n // Handlers that depend on other handlers do so via .data(), which used to always\n // return a shallow clone of its internal data structures. However, that pattern\n // easily results in egregious amounts of allocation. Now .data() does not do any\n // cloning, and it happens here instead so that users of the trace processor may\n // still assume that the parsed data is theirs.\n // See: crbug/41484172\n const shallowClone = (value: unknown, recurse = true): unknown => {\n if (value instanceof Map) {\n return new Map(value);\n }\n if (value instanceof Set) {\n return new Set(value);\n }\n if (Array.isArray(value)) {\n return [...value];\n }\n if (typeof value === 'object' && value && recurse) {\n const obj: Record<string, unknown> = {};\n for (const [key, v] of Object.entries(value)) {\n obj[key] = shallowClone(v, false);\n }\n return obj;\n }\n return value;\n };\n\n options.logger?.start('parse:clone');\n const parsedTrace = {};\n for (const [name, handler] of Object.entries(this.#traceHandlers)) {\n const data = shallowClone(handler.data());\n Object.assign(parsedTrace, {[name]: data});\n }\n options.logger?.end('parse:clone');\n\n this.dispatchEvent(new TraceParseProgressEvent({percent: ProgressPhase.CLONE}));\n\n this.#data = parsedTrace as Handlers.Types.ParsedTrace;\n }\n\n get parsedTrace(): Handlers.Types.ParsedTrace|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n return this.#data;\n }\n\n get insights(): Insights.Types.TraceInsightSets|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n return this.#insights;\n }\n\n #createLanternContext(\n parsedTrace: Handlers.Types.ParsedTrace, traceEvents: readonly Types.Events.Event[], frameId: string,\n navigationId: string, options: Types.Configuration.ParseOptions): Insights.Types.LanternContext|undefined {\n // Check for required handlers.\n if (!parsedTrace.NetworkRequests || !parsedTrace.Workers || !parsedTrace.PageLoadMetrics) {\n return;\n }\n if (!parsedTrace.NetworkRequests.byTime.length) {\n throw new Lantern.Core.LanternError('No network requests found in trace');\n }\n\n const navStarts = parsedTrace.Meta.navigationsByFrameId.get(frameId);\n const navStartIndex = navStarts?.findIndex(n => n.args.data?.navigationId === navigationId);\n if (!navStarts || navStartIndex === undefined || navStartIndex === -1) {\n throw new Lantern.Core.LanternError('Could not find navigation start');\n }\n\n const startTime = navStarts[navStartIndex].ts;\n const endTime = navStartIndex + 1 < navStarts.length ? navStarts[navStartIndex + 1].ts : Number.POSITIVE_INFINITY;\n const boundedTraceEvents = traceEvents.filter(e => e.ts >= startTime && e.ts < endTime);\n\n // Lantern.Types.TraceEvent and Types.Events.Event represent the same\n // object - a trace event - but one is more flexible than the other. It should be safe to cast between them.\n const trace: Lantern.Types.Trace = {\n traceEvents: boundedTraceEvents as unknown as Lantern.Types.TraceEvent[],\n };\n\n const requests = LanternComputationData.createNetworkRequests(trace, parsedTrace, startTime, endTime);\n const graph = LanternComputationData.createGraph(requests, trace, parsedTrace);\n const processedNavigation = LanternComputationData.createProcessedNavigation(parsedTrace, frameId, navigationId);\n\n const networkAnalysis = Lantern.Core.NetworkAnalyzer.analyze(requests);\n if (!networkAnalysis) {\n return;\n }\n\n const lanternSettings: Lantern.Types.Simulation.Settings = {\n // TODO(crbug.com/372674229): if devtools throttling was on, does this network analysis capture\n // that? Do we need to set 'devtools' throttlingMethod?\n networkAnalysis,\n throttlingMethod: 'provided',\n ...options.lanternSettings,\n };\n const simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest> =\n Lantern.Simulation.Simulator.createSimulator(lanternSettings);\n\n const computeData = {graph, simulator, processedNavigation};\n const fcpResult = Lantern.Metrics.FirstContentfulPaint.compute(computeData);\n const lcpResult = Lantern.Metrics.LargestContentfulPaint.compute(computeData, {fcpResult});\n const interactiveResult = Lantern.Metrics.Interactive.compute(computeData, {lcpResult});\n const tbtResult = Lantern.Metrics.TotalBlockingTime.compute(computeData, {fcpResult, interactiveResult});\n const metrics = {\n firstContentfulPaint: fcpResult,\n interactive: interactiveResult,\n largestContentfulPaint: lcpResult,\n totalBlockingTime: tbtResult,\n };\n\n return {requests, graph, simulator, metrics};\n }\n\n /**\n * Sort the insight models based on the impact of each insight's estimated savings, additionally weighted by the\n * worst metrics according to field data (if present).\n */\n sortInsightSet(insightSet: Insights.Types.InsightSet, metadata: Types.File.MetaData|null): void {\n // The initial order of the insights is alphabetical, based on `front_end/models/trace/insights/Models.ts`.\n // The order here provides a baseline that groups insights in a more logical way.\n const baselineOrder: Record<keyof Insights.Types.InsightModels, null> = {\n InteractionToNextPaint: null,\n LCPPhases: null,\n LCPDiscovery: null,\n CLSCulprits: null,\n RenderBlocking: null,\n NetworkDependencyTree: null,\n ImageDelivery: null,\n DocumentLatency: null,\n FontDisplay: null,\n Viewport: null,\n DOMSize: null,\n ThirdParties: null,\n DuplicatedJavaScript: null,\n SlowCSSSelector: null,\n ForcedReflow: null,\n Cache: null,\n ModernHTTP: null,\n LegacyJavaScript: null,\n };\n\n // Determine the weights for each metric based on field data, utilizing the same scoring curve that Lighthouse uses.\n const weights = Insights.Common.calculateMetricWeightsForSorting(insightSet, metadata);\n\n // Normalize the estimated savings to a single number, weighted by its relative impact\n // to the page experience based on the same scoring curve that Lighthouse uses.\n const observedLcpMicro = Insights.Common.getLCP(this.#insights, insightSet.id)?.value;\n const observedLcp = observedLcpMicro ? Helpers.Timing.microToMilli(observedLcpMicro) : Types.Timing.Milli(0);\n const observedCls = Insights.Common.getCLS(this.#insights, insightSet.id).value;\n\n // INP is special - if users did not interact with the page, we'll have no INP, but we should still\n // be able to prioritize insights based on this metric. When we observe no interaction, instead use\n // a default value for the baseline INP.\n const observedInpMicro = Insights.Common.getINP(this.#insights, insightSet.id)?.value;\n const observedInp = observedInpMicro ? Helpers.Timing.microToMilli(observedInpMicro) : Types.Timing.Milli(200);\n\n const observedLcpScore =\n observedLcp !== undefined ? Insights.Common.evaluateLCPMetricScore(observedLcp) : undefined;\n const observedInpScore = Insights.Common.evaluateINPMetricScore(observedInp);\n const observedClsScore = Insights.Common.evaluateCLSMetricScore(observedCls);\n\n const insightToSortingRank = new Map<string, number>();\n for (const [name, model] of Object.entries(insightSet.model)) {\n const lcp = model.metricSavings?.LCP ?? 0;\n const inp = model.metricSavings?.INP ?? 0;\n const cls = model.metricSavings?.CLS ?? 0;\n\n const lcpPostSavings =\n observedLcp !== undefined ? Math.max(0, observedLcp - lcp) as Types.Timing.Milli : undefined;\n const inpPostSavings = Math.max(0, observedInp - inp) as Types.Timing.Milli;\n const clsPostSavings = Math.max(0, observedCls - cls);\n\n let score = 0;\n if (weights.lcp && lcp && observedLcpScore !== undefined && lcpPostSavings !== undefined) {\n score += weights.lcp * (Insights.Common.evaluateLCPMetricScore(lcpPostSavings) - observedLcpScore);\n }\n if (weights.inp && inp && observedInpScore !== undefined) {\n score += weights.inp * (Insights.Common.evaluateINPMetricScore(inpPostSavings) - observedInpScore);\n }\n if (weights.cls && cls && observedClsScore !== undefined) {\n score += weights.cls * (Insights.Common.evaluateCLSMetricScore(clsPostSavings) - observedClsScore);\n }\n\n insightToSortingRank.set(name, score);\n }\n\n // Now perform the actual sorting.\n const baselineOrderKeys = Object.keys(baselineOrder);\n const orderedKeys = Object.keys(insightSet.model);\n orderedKeys.sort((a, b) => {\n const a1 = baselineOrderKeys.indexOf(a);\n const b1 = baselineOrderKeys.indexOf(b);\n if (a1 >= 0 && b1 >= 0) {\n return a1 - b1;\n }\n if (a1 >= 0) {\n return -1;\n }\n if (b1 >= 0) {\n return 1;\n }\n return 0;\n });\n orderedKeys.sort((a, b) => (insightToSortingRank.get(b) ?? 0) - (insightToSortingRank.get(a) ?? 0));\n\n const newModel = {} as Insights.Types.InsightModels;\n for (const key of orderedKeys as Array<keyof Insights.Types.InsightModels>) {\n const model = insightSet.model[key];\n // @ts-expect-error Maybe someday typescript will be powerful enough to handle this.\n newModel[key] = model;\n }\n insightSet.model = newModel;\n }\n\n #computeInsightSet(\n parsedTrace: Handlers.Types.ParsedTrace, context: Insights.Types.InsightSetContext,\n options: Types.Configuration.ParseOptions): void {\n let id, urlString, navigation;\n if (context.navigation) {\n id = context.navigationId;\n urlString =\n parsedTrace.Meta.finalDisplayUrlByNavigationId.get(context.navigationId) ?? parsedTrace.Meta.mainFrameURL;\n navigation = context.navigation;\n } else {\n id = Types.Events.NO_NAVIGATION;\n urlString = parsedTrace.Meta.finalDisplayUrlByNavigationId.get('') ?? parsedTrace.Meta.mainFrameURL;\n }\n\n const model = {} as Insights.Types.InsightSet['model'];\n\n for (const [name, insight] of Object.entries(TraceProcessor.getInsightRunners())) {\n let insightResult;\n try {\n options.logger?.start(`insights:${name}`);\n insightResult = insight.generateInsight(parsedTrace, context);\n insightResult.frameId = context.frameId;\n const navId = context.navigation?.args.data?.navigationId;\n if (navId) {\n insightResult.navigationId = navId;\n }\n } catch (err) {\n insightResult = err;\n } finally {\n options.logger?.end(`insights:${name}`);\n }\n Object.assign(model, {[name]: insightResult});\n }\n\n let url;\n try {\n url = new URL(urlString);\n } catch {\n // We're pretty sure this only happens for our test fixture: missing-url.json.gz. Shouldn't\n // happen for real traces.\n return;\n }\n\n const insightSet: Insights.Types.InsightSet = {\n id,\n url,\n navigation,\n frameId: context.frameId,\n bounds: context.bounds,\n model,\n };\n if (!this.#insights) {\n this.#insights = new Map();\n }\n this.#insights.set(insightSet.id, insightSet);\n this.sortInsightSet(insightSet, options.metadata ?? null);\n }\n\n /**\n * Run all the insights and set the result to `#insights`.\n */\n #computeInsights(\n parsedTrace: Handlers.Types.ParsedTrace, traceEvents: readonly Types.Events.Event[],\n options: Types.Configuration.ParseOptions): void {\n // This insights map will be populated by the helper methods.\n this.#insights = new Map();\n\n // Filter main frame navigations to those that have the necessary data (frameId and navigationId).\n // TODO(cjamcl): Does this filtering makes the \"use the next nav as the end time\" logic potentially broken? Are navs without nav id or frame even real?\n const navigations = parsedTrace.Meta.mainFrameNavigations.filter(\n navigation => navigation.args.frame && navigation.args.data?.navigationId);\n\n this.#computeInsightsForInitialTracePeriod(parsedTrace, navigations, options);\n\n for (const [index, navigation] of navigations.entries()) {\n const min = navigation.ts;\n // Use trace end for the last navigation, otherwise use the start of the next navigation.\n const max = index + 1 < navigations.length ? navigations[index + 1].ts : parsedTrace.Meta.traceBounds.max;\n const bounds = Helpers.Timing.traceWindowFromMicroSeconds(min, max);\n this.#computeInsightsForNavigation(navigation, bounds, parsedTrace, traceEvents, options);\n }\n }\n\n /**\n * Computes insights for the period before the first navigation, or for the entire trace if no navigations exist.\n */\n #computeInsightsForInitialTracePeriod(\n parsedTrace: Handlers.Types.ParsedTrace, navigations: readonly Types.Events.NavigationStart[],\n options: Types.Configuration.ParseOptions): void {\n // Determine bounds: Use the period before the first navigation if navigations exist, otherwise use the entire trace bounds.\n const bounds = navigations.length > 0 ?\n Helpers.Timing.traceWindowFromMicroSeconds(parsedTrace.Meta.traceBounds.min, navigations[0].ts) :\n parsedTrace.Meta.traceBounds;\n\n // Define threshold for considering the pre-navigation period significant enough to analyze.\n // When using \"Record and reload\" option, it typically takes ~5ms. So use 50ms to be safe.\n const threshold = Helpers.Timing.milliToMicro(50 as Types.Timing.Milli);\n\n // Compute insights if either:\n // 1. There are no navigations (we analyze the whole trace).\n // 2. There are navigations, AND the initial period before the first navigation is longer than the threshold.\n const shouldComputeInsights = navigations.length === 0 || bounds.range > threshold;\n\n // If navigations exist but the initial period is below the threshold, we intentionally do nothing for this portion of the trace.\n if (shouldComputeInsights) {\n const context: Insights.Types.InsightSetContext = {\n bounds,\n frameId: parsedTrace.Meta.mainFrameId,\n // No navigation or lantern context applies to this initial/no-navigation period.\n };\n this.#computeInsightSet(parsedTrace, context, options);\n }\n }\n\n /**\n * Computes insights for a specific navigation event.\n */\n #computeInsightsForNavigation(\n navigation: Types.Events.NavigationStart, bounds: Types.Timing.TraceWindowMicro,\n parsedTrace: Handlers.Types.ParsedTrace, traceEvents: readonly Types.Events.Event[],\n options: Types.Configuration.ParseOptions): void {\n const frameId = navigation.args.frame;\n // Guaranteed by the filter in #computeInsights\n const navigationId = navigation.args.data?.navigationId as string;\n\n // The lantern sub-context is optional on InsightSetContext, so not setting it is OK.\n // This is also a hedge against an error inside Lantern resulting in breaking the entire performance panel.\n // Additionally, many trace fixtures are too old to be processed by Lantern.\n let lantern: Insights.Types.LanternContext|undefined;\n try {\n options.logger?.start('insights:createLanternContext');\n lantern = this.#createLanternContext(parsedTrace, traceEvents, frameId, navigationId, options);\n } catch (e) {\n // Handle Lantern errors gracefully\n // Don't allow an error in constructing the Lantern graphs to break the rest of the trace processor.\n // Log unexpected errors, but suppress anything that occurs from a trace being too old.\n // Otherwise tests using old fixtures become way too noisy.\n const expectedErrors = [\n 'mainDocumentRequest not found',\n 'missing metric scores for main frame',\n 'missing metric: FCP',\n 'missing metric: LCP',\n 'No network requests found in trace',\n 'Trace is too old',\n ];\n if (!(e instanceof Lantern.Core.LanternError)) {\n // If this wasn't a managed LanternError, the stack trace is likely needed for debugging.\n console.error(e);\n } else if (!expectedErrors.some(err => e.message === err)) {\n // To reduce noise from tests, only print errors that are not expected to occur because a trace is\n // too old (for which there is no single check).\n console.error(e);\n }\n } finally {\n options.logger?.end('insights:createLanternContext');\n }\n\n const context: Insights.Types.InsightSetContext = {\n bounds,\n frameId,\n navigation,\n navigationId,\n lantern,\n };\n this.#computeInsightSet(parsedTrace, context, options);\n }\n}\n\n/**\n * Some Handlers need data provided by others. Dependencies of a handler handler are\n * declared in the `deps` field.\n * @returns A map from trace event handler name to trace event handler whose entries\n * iterate in such a way that each handler is visited after its dependencies.\n */\nexport function sortHandlers(traceHandlers: Partial<Record<Handlers.Types.HandlerName, Handlers.Types.Handler>>):\n Map<Handlers.Types.HandlerName, Handlers.Types.Handler> {\n const sortedMap = new Map<Handlers.Types.HandlerName, Handlers.Types.Handler>();\n const visited = new Set<Handlers.Types.HandlerName>();\n const visitHandler = (handlerName: Handlers.Types.HandlerName): void => {\n if (sortedMap.has(handlerName)) {\n return;\n }\n if (visited.has(handlerName)) {\n let stackPath = '';\n for (const handler of visited) {\n if (stackPath || handler === handlerName) {\n stackPath += `${handler}->`;\n }\n }\n stackPath += handlerName;\n throw new Error(`Found dependency cycle in trace event handlers: ${stackPath}`);\n }\n visited.add(handlerName);\n const handler = traceHandlers[handlerName];\n if (!handler) {\n return;\n }\n const deps = handler.deps?.();\n if (deps) {\n deps.forEach(visitHandler);\n }\n sortedMap.set(handlerName, handler);\n };\n\n for (const handlerName of Object.keys(traceHandlers)) {\n visitHandler(handlerName as Handlers.Types.HandlerName);\n }\n return sortedMap;\n}\n"]}
|