@paulirish/trace_engine 0.0.44 → 0.0.45
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/ArrayUtilities.d.ts +1 -1
- package/core/platform/ArrayUtilities.js.map +1 -1
- package/core/platform/DOMUtilities.js +1 -1
- package/core/platform/DOMUtilities.js.map +1 -1
- package/core/platform/MimeType.js.map +1 -1
- package/core/platform/NumberUtilities.js.map +1 -1
- package/core/platform/ServerTiming.d.ts +2 -2
- package/core/platform/ServerTiming.js.map +1 -1
- package/core/platform/StringUtilities.js +1 -1
- package/core/platform/StringUtilities.js.map +1 -1
- package/core/platform/Timing.d.ts +0 -1
- package/core/platform/Timing.js +0 -3
- package/core/platform/Timing.js.map +1 -1
- package/core/platform/TypedArrayUtilities.js +3 -2
- package/core/platform/TypedArrayUtilities.js.map +1 -1
- package/generated/protocol.d.ts +71 -4
- package/locales/af.json +184 -1
- package/locales/am.json +184 -1
- package/locales/ar.json +184 -1
- package/locales/as.json +184 -1
- package/locales/az.json +184 -1
- package/locales/be.json +184 -1
- package/locales/bg.json +184 -1
- package/locales/bn.json +184 -1
- package/locales/bs.json +184 -1
- package/locales/ca.json +184 -1
- package/locales/cs.json +184 -1
- package/locales/cy.json +184 -1
- package/locales/da.json +184 -1
- package/locales/de.json +184 -1
- package/locales/el.json +184 -1
- package/locales/en-GB.json +184 -1
- package/locales/en-US.json +201 -15
- package/locales/en-XL.json +201 -15
- package/locales/es-419.json +184 -1
- package/locales/es.json +184 -1
- package/locales/et.json +184 -1
- package/locales/eu.json +184 -1
- package/locales/fa.json +184 -1
- package/locales/fi.json +184 -1
- package/locales/fil.json +184 -1
- package/locales/fr-CA.json +184 -1
- package/locales/fr.json +184 -1
- package/locales/gl.json +184 -1
- package/locales/gu.json +184 -1
- package/locales/he.json +185 -2
- package/locales/hi.json +184 -1
- package/locales/hr.json +184 -1
- package/locales/hu.json +184 -1
- package/locales/hy.json +184 -1
- package/locales/id.json +184 -1
- package/locales/is.json +184 -1
- package/locales/it.json +184 -1
- package/locales/ja.json +184 -1
- package/locales/ka.json +184 -1
- package/locales/kk.json +184 -1
- package/locales/km.json +184 -1
- package/locales/kn.json +184 -1
- package/locales/ko.json +184 -1
- package/locales/ky.json +184 -1
- package/locales/lo.json +184 -1
- package/locales/lt.json +184 -1
- package/locales/lv.json +184 -1
- package/locales/mk.json +184 -1
- package/locales/ml.json +184 -1
- package/locales/mn.json +184 -1
- package/locales/mr.json +184 -1
- package/locales/ms.json +184 -1
- package/locales/my.json +184 -1
- package/locales/ne.json +184 -1
- package/locales/nl.json +184 -1
- package/locales/no.json +184 -1
- package/locales/or.json +184 -1
- package/locales/pa.json +184 -1
- package/locales/pl.json +184 -1
- package/locales/pt-PT.json +184 -1
- package/locales/pt.json +184 -1
- package/locales/ro.json +184 -1
- package/locales/ru.json +184 -1
- package/locales/si.json +184 -1
- package/locales/sk.json +184 -1
- package/locales/sl.json +184 -1
- package/locales/sq.json +184 -1
- package/locales/sr-Latn.json +184 -1
- package/locales/sr.json +184 -1
- package/locales/sv.json +184 -1
- package/locales/sw.json +184 -1
- package/locales/ta.json +184 -1
- package/locales/te.json +184 -1
- package/locales/th.json +184 -1
- package/locales/tr.json +184 -1
- package/locales/uk.json +184 -1
- package/locales/ur.json +184 -1
- package/locales/uz.json +184 -1
- package/locales/vi.json +184 -1
- package/locales/zh-HK.json +184 -1
- package/locales/zh-TW.json +184 -1
- package/locales/zh.json +184 -1
- package/locales/zu.json +184 -1
- package/models/cpu_profile/CPUProfileDataModel.js +10 -10
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
- package/models/trace/LanternComputationData.js.map +1 -1
- package/models/trace/ModelImpl.d.ts +1 -0
- package/models/trace/ModelImpl.js +1 -0
- package/models/trace/ModelImpl.js.map +1 -1
- package/models/trace/Processor.js +16 -11
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/extras/FetchNodes.d.ts +1 -1
- package/models/trace/extras/FetchNodes.js +3 -3
- package/models/trace/extras/FetchNodes.js.map +1 -1
- package/models/trace/extras/ScriptDuplication.d.ts +34 -0
- package/models/trace/extras/ScriptDuplication.js +178 -0
- package/models/trace/extras/ScriptDuplication.js.map +1 -0
- package/models/trace/extras/StackTraceForEvent.js +25 -44
- package/models/trace/extras/StackTraceForEvent.js.map +1 -1
- package/models/trace/extras/ThirdParties.js +1 -0
- package/models/trace/extras/ThirdParties.js.map +1 -1
- package/models/trace/extras/TraceTree.d.ts +5 -2
- package/models/trace/extras/TraceTree.js +47 -17
- package/models/trace/extras/TraceTree.js.map +1 -1
- package/models/trace/extras/extras-tsconfig.json +1 -1
- package/models/trace/extras/extras.d.ts +1 -0
- package/models/trace/extras/extras.js +1 -0
- package/models/trace/extras/extras.js.map +1 -1
- package/models/trace/handlers/AnimationFramesHandler.js.map +1 -1
- package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -1
- package/models/trace/handlers/AuctionWorkletsHandler.js.map +1 -1
- package/models/trace/handlers/ExtensionTraceDataHandler.d.ts +1 -1
- package/models/trace/handlers/ExtensionTraceDataHandler.js +2 -1
- package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
- package/models/trace/handlers/FramesHandler.js.map +1 -1
- package/models/trace/handlers/ImagePaintingHandler.js +1 -1
- package/models/trace/handlers/ImagePaintingHandler.js.map +1 -1
- package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
- package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
- package/models/trace/handlers/MetaHandler.d.ts +2 -2
- package/models/trace/handlers/MetaHandler.js +4 -6
- package/models/trace/handlers/MetaHandler.js.map +1 -1
- package/models/trace/handlers/ModelHandlers.d.ts +1 -0
- package/models/trace/handlers/ModelHandlers.js +1 -0
- package/models/trace/handlers/ModelHandlers.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.d.ts +9 -0
- package/models/trace/handlers/NetworkRequestsHandler.js +6 -6
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/PageLoadMetricsHandler.js +1 -1
- package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
- package/models/trace/handlers/RendererHandler.js +3 -4
- package/models/trace/handlers/RendererHandler.js.map +1 -1
- package/models/trace/handlers/ScriptsHandler.d.ts +22 -0
- package/models/trace/handlers/ScriptsHandler.js +116 -0
- package/models/trace/handlers/ScriptsHandler.js.map +1 -0
- package/models/trace/handlers/UserTimingsHandler.d.ts +5 -0
- package/models/trace/handlers/UserTimingsHandler.js +16 -0
- package/models/trace/handlers/UserTimingsHandler.js.map +1 -1
- package/models/trace/handlers/WorkersHandler.js.map +1 -1
- package/models/trace/handlers/handlers-tsconfig.json +1 -0
- package/models/trace/handlers/helpers.d.ts +5 -1
- package/models/trace/handlers/helpers.js +28 -4
- package/models/trace/handlers/helpers.js.map +1 -1
- package/models/trace/helpers/Network.d.ts +1 -0
- package/models/trace/helpers/Network.js +8 -3
- package/models/trace/helpers/Network.js.map +1 -1
- package/models/trace/helpers/SamplesIntegrator.d.ts +8 -1
- package/models/trace/helpers/SamplesIntegrator.js +42 -2
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
- package/models/trace/helpers/Timing.js.map +1 -1
- package/models/trace/helpers/Trace.d.ts +7 -10
- package/models/trace/helpers/Trace.js +25 -10
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/insights/CLSCulprits.d.ts +12 -12
- package/models/trace/insights/CLSCulprits.js +15 -4
- package/models/trace/insights/CLSCulprits.js.map +1 -1
- package/models/trace/insights/Common.d.ts +7 -1
- package/models/trace/insights/Common.js +9 -3
- package/models/trace/insights/Common.js.map +1 -1
- package/models/trace/insights/DOMSize.d.ts +8 -8
- package/models/trace/insights/DOMSize.js +2 -1
- package/models/trace/insights/DOMSize.js.map +1 -1
- package/models/trace/insights/DocumentLatency.d.ts +11 -11
- package/models/trace/insights/DocumentLatency.js +2 -1
- package/models/trace/insights/DocumentLatency.js.map +1 -1
- package/models/trace/insights/DuplicateJavaScript.d.ts +18 -0
- package/models/trace/insights/DuplicateJavaScript.js +49 -0
- package/models/trace/insights/DuplicateJavaScript.js.map +1 -0
- package/models/trace/insights/FontDisplay.d.ts +4 -4
- package/models/trace/insights/FontDisplay.js +2 -1
- package/models/trace/insights/FontDisplay.js.map +1 -1
- package/models/trace/insights/ForcedReflow.d.ts +5 -5
- package/models/trace/insights/ForcedReflow.js +4 -1
- package/models/trace/insights/ForcedReflow.js.map +1 -1
- package/models/trace/insights/ImageDelivery.d.ts +19 -15
- package/models/trace/insights/ImageDelivery.js +26 -20
- package/models/trace/insights/ImageDelivery.js.map +1 -1
- package/models/trace/insights/InteractionToNextPaint.d.ts +8 -8
- package/models/trace/insights/InteractionToNextPaint.js +3 -2
- package/models/trace/insights/InteractionToNextPaint.js.map +1 -1
- package/models/trace/insights/LCPDiscovery.d.ts +9 -9
- package/models/trace/insights/LCPDiscovery.js +6 -3
- package/models/trace/insights/LCPDiscovery.js.map +1 -1
- package/models/trace/insights/LCPPhases.d.ts +15 -10
- package/models/trace/insights/LCPPhases.js +11 -4
- package/models/trace/insights/LCPPhases.js.map +1 -1
- package/models/trace/insights/Models.d.ts +2 -1
- package/models/trace/insights/Models.js +2 -1
- package/models/trace/insights/Models.js.map +1 -1
- package/models/trace/insights/NetworkDependencyTree.d.ts +33 -0
- package/models/trace/insights/NetworkDependencyTree.js +141 -0
- package/models/trace/insights/NetworkDependencyTree.js.map +1 -0
- package/models/trace/insights/RenderBlocking.d.ts +5 -5
- package/models/trace/insights/RenderBlocking.js +2 -1
- package/models/trace/insights/RenderBlocking.js.map +1 -1
- package/models/trace/insights/SlowCSSSelector.d.ts +8 -8
- package/models/trace/insights/SlowCSSSelector.js +4 -2
- package/models/trace/insights/SlowCSSSelector.js.map +1 -1
- package/models/trace/insights/ThirdParties.d.ts +6 -6
- package/models/trace/insights/ThirdParties.js +8 -5
- package/models/trace/insights/ThirdParties.js.map +1 -1
- package/models/trace/insights/Viewport.d.ts +2 -2
- package/models/trace/insights/Viewport.js +2 -1
- package/models/trace/insights/Viewport.js.map +1 -1
- package/models/trace/insights/insights-tsconfig.json +2 -1
- package/models/trace/insights/types.d.ts +25 -3
- package/models/trace/insights/types.js.map +1 -1
- package/models/trace/lantern/core/NetworkAnalyzer.d.ts +2 -2
- package/models/trace/lantern/core/NetworkAnalyzer.js +2 -2
- package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -1
- package/models/trace/lantern/graph/BaseNode.d.ts +1 -1
- package/models/trace/lantern/graph/BaseNode.js.map +1 -1
- package/models/trace/lantern/graph/CPUNode.js +1 -1
- package/models/trace/lantern/graph/CPUNode.js.map +1 -1
- package/models/trace/lantern/graph/NetworkNode.js +1 -1
- package/models/trace/lantern/graph/NetworkNode.js.map +1 -1
- package/models/trace/lantern/graph/PageDependencyGraph.d.ts +2 -2
- package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
- package/models/trace/lantern/metrics/Metric.js.map +1 -1
- package/models/trace/lantern/metrics/TotalBlockingTime.d.ts +2 -2
- package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -1
- package/models/trace/lantern/types/Lantern.d.ts +2 -2
- package/models/trace/lantern/types/Lantern.js.map +1 -1
- package/models/trace/trace-tsconfig.json +3 -3
- package/models/trace/trace.d.ts +1 -2
- package/models/trace/trace.js +1 -2
- package/models/trace/trace.js.map +1 -1
- package/models/trace/types/Configuration.d.ts +10 -0
- package/models/trace/types/Configuration.js.map +1 -1
- package/models/trace/types/Extensions.d.ts +1 -1
- package/models/trace/types/Extensions.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +87 -4
- package/models/trace/types/TraceEvents.js +20 -0
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/package.json +1 -1
- package/test/test-trace-engine.mjs +3 -2
- package/models/trace/extras/TimelineJSProfile.d.ts +0 -13
- package/models/trace/extras/TimelineJSProfile.js +0 -60
- package/models/trace/extras/TimelineJSProfile.js.map +0 -1
- package/models/trace/insights/LongCriticalNetworkTree.d.ts +0 -22
- package/models/trace/insights/LongCriticalNetworkTree.js +0 -40
- package/models/trace/insights/LongCriticalNetworkTree.js.map +0 -1
- package/models/trace/root-causes/LayoutShift.d.ts +0 -125
- package/models/trace/root-causes/LayoutShift.js +0 -519
- package/models/trace/root-causes/LayoutShift.js.map +0 -1
- package/models/trace/root-causes/RootCauses.d.ts +0 -15
- package/models/trace/root-causes/RootCauses.js +0 -12
- package/models/trace/root-causes/RootCauses.js.map +0 -1
- package/models/trace/root-causes/bundle-tsconfig.json +0 -1
- package/models/trace/root-causes/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -43
- package/models/trace/root-causes/root-causes-tsconfig.json +0 -56
- package/models/trace/root-causes/root-causes.d.ts +0 -1
- package/models/trace/root-causes/root-causes.js +0 -5
- package/models/trace/root-causes/root-causes.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchNodes.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/FetchNodes.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAGhD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,MAAM,wBAAwB,GAC1B,IAAI,GAAG,EAA0F,CAAC;AACtG,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAEiE,CAAC;AAE1G,MAAM,UAAU,oBAAoB;IAClC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IACjC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IACjC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IAChC,+BAA+B,CAAC,KAAK,EAAE,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CACzC,SAAqC,EAAE,MAAkC;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,OAAO,eAAe,CAAC;AACzB,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 SDK from '../../../core/sdk/sdk.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Types from '../types/types.js';\n\nconst domLookUpSingleNodeCache =\n new Map<Handlers.Types.ParsedTrace, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>();\nconst domLookUpBatchNodesCache = new Map<\n Handlers.Types.ParsedTrace,\n Map<Array<Protocol.DOM.BackendNodeId>, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>>();\n\nexport function clearCacheForTesting(): void {\n domLookUpSingleNodeCache.clear();\n domLookUpBatchNodesCache.clear();\n layoutShiftSourcesCache.clear();\n normalizedLayoutShiftNodesCache.clear();\n}\n\n/**\n * Looks up the DOM Node on the page for the given BackendNodeId. Uses the\n * provided ParsedTrace as the cache and will cache the result after the\n * first lookup.\n */\nexport async function domNodeForBackendNodeID(\n modelData: Handlers.Types.ParsedTrace, nodeId: Protocol.DOM.BackendNodeId): Promise<SDK.DOMModel.DOMNode|null> {\n const fromCache = domLookUpSingleNodeCache.get(modelData)?.get(nodeId);\n if (fromCache !== undefined) {\n return fromCache;\n }\n\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n const domModel = target?.model(SDK.DOMModel.DOMModel);\n if (!domModel) {\n return null;\n }\n\n const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set([nodeId]));\n const result = domNodesMap?.get(nodeId) || null;\n\n const cacheForModel =\n domLookUpSingleNodeCache.get(modelData) || new Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>();\n cacheForModel.set(nodeId, result);\n domLookUpSingleNodeCache.set(modelData, cacheForModel);\n\n return result;\n}\n\nconst nodeIdsForEventCache = new WeakMap<Types.Events.Event, Set<Protocol.DOM.BackendNodeId>>();\n/**\n * Extracts a set of NodeIds for a given event.\n * NOTE: you probably don't want to call this and instead use\n * `extractRelatedDOMNodesFromEvent`, which will fetch the nodes over CDP.\n * This method is primarily exported so we can test the logic more easily\n * without having to mock the CDP layer.\n **/\nexport function nodeIdsForEvent(\n modelData: Handlers.Types.ParsedTrace,\n event: Types.Events.Event,\n ): Set<Protocol.DOM.BackendNodeId> {\n const fromCache = nodeIdsForEventCache.get(event);\n if (fromCache) {\n return fromCache;\n }\n const foundIds = new Set<Protocol.DOM.BackendNodeId>();\n\n if (Types.Events.isLayout(event)) {\n event.args.endData?.layoutRoots.forEach(root => foundIds.add(root.nodeId));\n } else if (Types.Events.isSyntheticLayoutShift(event) && event.args.data?.impacted_nodes) {\n event.args.data.impacted_nodes.forEach(node => foundIds.add(node.node_id));\n } else if (Types.Events.isLargestContentfulPaintCandidate(event) && typeof event.args.data?.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.Events.isPaint(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.Events.isPaintImage(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.Events.isScrollLayer(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (\n Types.Events.isSyntheticAnimation(event) && typeof event.args.data.beginEvent.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.beginEvent.args.data.nodeId);\n } else if (Types.Events.isDecodeImage(event)) {\n // For a DecodeImage event, we can use the ImagePaintingHandler, which has\n // done the work to build the relationship between a DecodeImage event and\n // the corresponding PaintImage event.\n const paintImageEvent = modelData.ImagePainting.paintImageForEvent.get(event);\n if (paintImageEvent && typeof paintImageEvent.args.data.nodeId !== 'undefined') {\n foundIds.add(paintImageEvent.args.data.nodeId);\n }\n } else if (Types.Events.isDrawLazyPixelRef(event) && event.args?.LazyPixelRef) {\n const paintImageEvent = modelData.ImagePainting.paintImageByDrawLazyPixelRef.get(event.args.LazyPixelRef);\n if (paintImageEvent && typeof paintImageEvent.args.data.nodeId !== 'undefined') {\n foundIds.add(paintImageEvent.args.data.nodeId);\n }\n } else if (Types.Events.isParseMetaViewport(event) && typeof event.args?.data.node_id !== 'undefined') {\n foundIds.add(event.args.data.node_id);\n }\n nodeIdsForEventCache.set(event, foundIds);\n return foundIds;\n}\n\n/**\n * Looks up for backend node ids in different types of trace events\n * and resolves them into related DOM nodes.\n * This method should be progressively updated to support more events\n * containing node ids which we want to resolve.\n */\nexport async function extractRelatedDOMNodesFromEvent(modelData: Handlers.Types.ParsedTrace, event: Types.Events.Event):\n Promise<Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>|null> {\n const nodeIds = nodeIdsForEvent(modelData, event);\n if (nodeIds.size) {\n return domNodesForMultipleBackendNodeIds(modelData, Array.from(nodeIds));\n }\n return null;\n}\n\n/**\n * Takes a set of Protocol.DOM.BackendNodeId ids and will return a map of NodeId=>DOMNode.\n * Results are cached based on 1) the provided ParsedTrace and 2) the provided set of IDs.\n */\nexport async function domNodesForMultipleBackendNodeIds(\n modelData: Handlers.Types.ParsedTrace,\n nodeIds: Array<Protocol.DOM.BackendNodeId>): Promise<Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>> {\n const fromCache = domLookUpBatchNodesCache.get(modelData)?.get(nodeIds);\n if (fromCache) {\n return fromCache;\n }\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n const domModel = target?.model(SDK.DOMModel.DOMModel);\n if (!domModel) {\n return new Map();\n }\n\n const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set(nodeIds)) || new Map();\n\n const cacheForModel = domLookUpBatchNodesCache.get(modelData) ||\n new Map<Array<Protocol.DOM.BackendNodeId>, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>();\n cacheForModel.set(nodeIds, domNodesMap);\n domLookUpBatchNodesCache.set(modelData, cacheForModel);\n\n return domNodesMap;\n}\n\nconst layoutShiftSourcesCache =\n new Map<Handlers.Types.ParsedTrace, Map<Types.Events.LayoutShift, readonly LayoutShiftSource[]>>();\n\nconst normalizedLayoutShiftNodesCache =\n new Map<Handlers.Types.ParsedTrace, Map<Types.Events.LayoutShift, readonly Types.Events.TraceImpactedNode[]>>();\n\nexport interface LayoutShiftSource {\n previousRect: DOMRect;\n currentRect: DOMRect;\n node: SDK.DOMModel.DOMNode;\n}\n\n/**\n * Calculates and returns a list of sources for a LayoutShift.\n * Here, a source is considered as a node that moved and contributed to the\n * given LayoutShift existing and the score it was given. Each source returned\n * contains a reference to the DOM Node, and its dimensions (as a DOMRect), both\n * before and now, so we can see how this node changed and how that impacted the\n * layout shift.\n *\n * This data is cached based on the provided model data and the given layout\n * shift, so it is is safe to call multiple times with the same input.\n */\nexport async function sourcesForLayoutShift(\n modelData: Handlers.Types.ParsedTrace, event: Types.Events.LayoutShift): Promise<readonly LayoutShiftSource[]> {\n const fromCache = layoutShiftSourcesCache.get(modelData)?.get(event);\n if (fromCache) {\n return fromCache;\n }\n const impactedNodes = event.args.data?.impacted_nodes;\n if (!impactedNodes) {\n return [];\n }\n const sources: LayoutShiftSource[] = [];\n await Promise.all(impactedNodes.map(async node => {\n const domNode = await domNodeForBackendNodeID(modelData, node.node_id);\n if (domNode) {\n sources.push({\n previousRect: new DOMRect(node.old_rect[0], node.old_rect[1], node.old_rect[2], node.old_rect[3]),\n currentRect: new DOMRect(node.new_rect[0], node.new_rect[1], node.new_rect[2], node.new_rect[3]),\n node: domNode,\n });\n }\n }));\n const cacheForModel =\n layoutShiftSourcesCache.get(modelData) || new Map<Types.Events.LayoutShift, LayoutShiftSource[]>();\n cacheForModel.set(event, sources);\n layoutShiftSourcesCache.set(modelData, cacheForModel);\n return sources;\n}\n\n/**\n * Takes a LayoutShift and normalizes its node dimensions based on the device\n * pixel ratio (DPR) of the user's display.\n * This is required because the Layout Instability API is not based on CSS\n * pixels, but physical pixels. Therefore we need to map these to normalized CSS\n * pixels if we can. For example, if the user is on a device with a DPR of 2,\n * the values of the node dimensions reported by the Instability API need to be\n * divided by 2 to be accurate.\n * This function is safe to call multiple times as results are cached based on\n * the provided model data.\n * See https://crbug.com/1300309 for details.\n */\nexport async function normalizedImpactedNodesForLayoutShift(\n modelData: Handlers.Types.ParsedTrace,\n event: Types.Events.LayoutShift): Promise<readonly Types.Events.TraceImpactedNode[]> {\n const fromCache = normalizedLayoutShiftNodesCache.get(modelData)?.get(event);\n if (fromCache) {\n return fromCache;\n }\n const impactedNodes = event.args?.data?.impacted_nodes;\n if (!impactedNodes) {\n return [];\n }\n\n let viewportScale: number|null = null;\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n // Get the CSS-to-physical pixel ratio of the device the inspected\n // target is running at.\n const evaluateResult = await target?.runtimeAgent().invoke_evaluate({expression: 'window.devicePixelRatio'});\n if (evaluateResult?.result.type === 'number') {\n viewportScale = evaluateResult?.result.value as number ?? null;\n }\n\n if (!viewportScale) {\n // Bail and return the nodes as is.\n return impactedNodes;\n }\n\n const normalizedNodes: Types.Events.TraceImpactedNode[] = [];\n for (const impactedNode of impactedNodes) {\n const newNode = {...impactedNode};\n for (let i = 0; i < impactedNode.old_rect.length; i++) {\n newNode.old_rect[i] /= viewportScale;\n }\n for (let i = 0; i < impactedNode.new_rect.length; i++) {\n newNode.new_rect[i] /= viewportScale;\n }\n normalizedNodes.push(newNode);\n }\n\n const cacheForModel = normalizedLayoutShiftNodesCache.get(modelData) ||\n new Map<Types.Events.LayoutShift, readonly Types.Events.TraceImpactedNode[]>();\n cacheForModel.set(event, normalizedNodes);\n normalizedLayoutShiftNodesCache.set(modelData, cacheForModel);\n\n return normalizedNodes;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FetchNodes.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/FetchNodes.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6B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,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtD,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC;QACvC,CAAC;QACD,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,aAAa,GAAG,+BAA+B,CAAC,GAAG,CAAC,SAAS,CAAC;QAChE,IAAI,GAAG,EAAuE,CAAC;IACnF,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC1C,+BAA+B,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAE9D,OAAO,eAAe,CAAC;AACzB,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 SDK from '../../../core/sdk/sdk.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Types from '../types/types.js';\n\nconst domLookUpSingleNodeCache =\n new Map<Handlers.Types.ParsedTrace, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>();\nconst domLookUpBatchNodesCache = new Map<\n Handlers.Types.ParsedTrace,\n Map<Protocol.DOM.BackendNodeId[], Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>>();\n\nexport function clearCacheForTesting(): void {\n domLookUpSingleNodeCache.clear();\n domLookUpBatchNodesCache.clear();\n layoutShiftSourcesCache.clear();\n normalizedLayoutShiftNodesCache.clear();\n}\n\n/**\n * Looks up the DOM Node on the page for the given BackendNodeId. Uses the\n * provided ParsedTrace as the cache and will cache the result after the\n * first lookup.\n */\nexport async function domNodeForBackendNodeID(\n modelData: Handlers.Types.ParsedTrace, nodeId: Protocol.DOM.BackendNodeId): Promise<SDK.DOMModel.DOMNode|null> {\n const fromCache = domLookUpSingleNodeCache.get(modelData)?.get(nodeId);\n if (fromCache !== undefined) {\n return fromCache;\n }\n\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n const domModel = target?.model(SDK.DOMModel.DOMModel);\n if (!domModel) {\n return null;\n }\n\n const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set([nodeId]));\n const result = domNodesMap?.get(nodeId) || null;\n\n const cacheForModel =\n domLookUpSingleNodeCache.get(modelData) || new Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>();\n cacheForModel.set(nodeId, result);\n domLookUpSingleNodeCache.set(modelData, cacheForModel);\n\n return result;\n}\n\nconst nodeIdsForEventCache = new WeakMap<Types.Events.Event, Set<Protocol.DOM.BackendNodeId>>();\n/**\n * Extracts a set of NodeIds for a given event.\n * NOTE: you probably don't want to call this and instead use\n * `extractRelatedDOMNodesFromEvent`, which will fetch the nodes over CDP.\n * This method is primarily exported so we can test the logic more easily\n * without having to mock the CDP layer.\n **/\nexport function nodeIdsForEvent(\n modelData: Handlers.Types.ParsedTrace,\n event: Types.Events.Event,\n ): Set<Protocol.DOM.BackendNodeId> {\n const fromCache = nodeIdsForEventCache.get(event);\n if (fromCache) {\n return fromCache;\n }\n const foundIds = new Set<Protocol.DOM.BackendNodeId>();\n\n if (Types.Events.isLayout(event)) {\n event.args.endData?.layoutRoots.forEach(root => foundIds.add(root.nodeId));\n } else if (Types.Events.isSyntheticLayoutShift(event) && event.args.data?.impacted_nodes) {\n event.args.data.impacted_nodes.forEach(node => foundIds.add(node.node_id));\n } else if (Types.Events.isLargestContentfulPaintCandidate(event) && typeof event.args.data?.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.Events.isPaint(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.Events.isPaintImage(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.Events.isScrollLayer(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (\n Types.Events.isSyntheticAnimation(event) && typeof event.args.data.beginEvent.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.beginEvent.args.data.nodeId);\n } else if (Types.Events.isDecodeImage(event)) {\n // For a DecodeImage event, we can use the ImagePaintingHandler, which has\n // done the work to build the relationship between a DecodeImage event and\n // the corresponding PaintImage event.\n const paintImageEvent = modelData.ImagePainting.paintImageForEvent.get(event);\n if (typeof paintImageEvent?.args.data.nodeId !== 'undefined') {\n foundIds.add(paintImageEvent.args.data.nodeId);\n }\n } else if (Types.Events.isDrawLazyPixelRef(event) && event.args?.LazyPixelRef) {\n const paintImageEvent = modelData.ImagePainting.paintImageByDrawLazyPixelRef.get(event.args.LazyPixelRef);\n if (typeof paintImageEvent?.args.data.nodeId !== 'undefined') {\n foundIds.add(paintImageEvent.args.data.nodeId);\n }\n } else if (Types.Events.isParseMetaViewport(event) && typeof event.args?.data.node_id !== 'undefined') {\n foundIds.add(event.args.data.node_id);\n }\n nodeIdsForEventCache.set(event, foundIds);\n return foundIds;\n}\n\n/**\n * Looks up for backend node ids in different types of trace events\n * and resolves them into related DOM nodes.\n * This method should be progressively updated to support more events\n * containing node ids which we want to resolve.\n */\nexport async function extractRelatedDOMNodesFromEvent(modelData: Handlers.Types.ParsedTrace, event: Types.Events.Event):\n Promise<Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>|null> {\n const nodeIds = nodeIdsForEvent(modelData, event);\n if (nodeIds.size) {\n return await domNodesForMultipleBackendNodeIds(modelData, Array.from(nodeIds));\n }\n return null;\n}\n\n/**\n * Takes a set of Protocol.DOM.BackendNodeId ids and will return a map of NodeId=>DOMNode.\n * Results are cached based on 1) the provided ParsedTrace and 2) the provided set of IDs.\n */\nexport async function domNodesForMultipleBackendNodeIds(\n modelData: Handlers.Types.ParsedTrace,\n nodeIds: Protocol.DOM.BackendNodeId[]): Promise<Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>> {\n const fromCache = domLookUpBatchNodesCache.get(modelData)?.get(nodeIds);\n if (fromCache) {\n return fromCache;\n }\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n const domModel = target?.model(SDK.DOMModel.DOMModel);\n if (!domModel) {\n return new Map();\n }\n\n const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set(nodeIds)) || new Map();\n\n const cacheForModel = domLookUpBatchNodesCache.get(modelData) ||\n new Map<Protocol.DOM.BackendNodeId[], Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>();\n cacheForModel.set(nodeIds, domNodesMap);\n domLookUpBatchNodesCache.set(modelData, cacheForModel);\n\n return domNodesMap;\n}\n\nconst layoutShiftSourcesCache =\n new Map<Handlers.Types.ParsedTrace, Map<Types.Events.LayoutShift, readonly LayoutShiftSource[]>>();\n\nconst normalizedLayoutShiftNodesCache =\n new Map<Handlers.Types.ParsedTrace, Map<Types.Events.LayoutShift, readonly Types.Events.TraceImpactedNode[]>>();\n\nexport interface LayoutShiftSource {\n previousRect: DOMRect;\n currentRect: DOMRect;\n node: SDK.DOMModel.DOMNode;\n}\n\n/**\n * Calculates and returns a list of sources for a LayoutShift.\n * Here, a source is considered as a node that moved and contributed to the\n * given LayoutShift existing and the score it was given. Each source returned\n * contains a reference to the DOM Node, and its dimensions (as a DOMRect), both\n * before and now, so we can see how this node changed and how that impacted the\n * layout shift.\n *\n * This data is cached based on the provided model data and the given layout\n * shift, so it is is safe to call multiple times with the same input.\n */\nexport async function sourcesForLayoutShift(\n modelData: Handlers.Types.ParsedTrace, event: Types.Events.LayoutShift): Promise<readonly LayoutShiftSource[]> {\n const fromCache = layoutShiftSourcesCache.get(modelData)?.get(event);\n if (fromCache) {\n return fromCache;\n }\n const impactedNodes = event.args.data?.impacted_nodes;\n if (!impactedNodes) {\n return [];\n }\n const sources: LayoutShiftSource[] = [];\n await Promise.all(impactedNodes.map(async node => {\n const domNode = await domNodeForBackendNodeID(modelData, node.node_id);\n if (domNode) {\n sources.push({\n previousRect: new DOMRect(node.old_rect[0], node.old_rect[1], node.old_rect[2], node.old_rect[3]),\n currentRect: new DOMRect(node.new_rect[0], node.new_rect[1], node.new_rect[2], node.new_rect[3]),\n node: domNode,\n });\n }\n }));\n const cacheForModel =\n layoutShiftSourcesCache.get(modelData) || new Map<Types.Events.LayoutShift, LayoutShiftSource[]>();\n cacheForModel.set(event, sources);\n layoutShiftSourcesCache.set(modelData, cacheForModel);\n return sources;\n}\n\n/**\n * Takes a LayoutShift and normalizes its node dimensions based on the device\n * pixel ratio (DPR) of the user's display.\n * This is required because the Layout Instability API is not based on CSS\n * pixels, but physical pixels. Therefore we need to map these to normalized CSS\n * pixels if we can. For example, if the user is on a device with a DPR of 2,\n * the values of the node dimensions reported by the Instability API need to be\n * divided by 2 to be accurate.\n * This function is safe to call multiple times as results are cached based on\n * the provided model data.\n * See https://crbug.com/1300309 for details.\n */\nexport async function normalizedImpactedNodesForLayoutShift(\n modelData: Handlers.Types.ParsedTrace,\n event: Types.Events.LayoutShift): Promise<readonly Types.Events.TraceImpactedNode[]> {\n const fromCache = normalizedLayoutShiftNodesCache.get(modelData)?.get(event);\n if (fromCache) {\n return fromCache;\n }\n const impactedNodes = event.args?.data?.impacted_nodes;\n if (!impactedNodes) {\n return [];\n }\n\n let viewportScale: number|null = null;\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n // Get the CSS-to-physical pixel ratio of the device the inspected\n // target is running at.\n const evaluateResult = await target?.runtimeAgent().invoke_evaluate({expression: 'window.devicePixelRatio'});\n if (evaluateResult?.result.type === 'number') {\n viewportScale = evaluateResult?.result.value as number ?? null;\n }\n\n if (!viewportScale) {\n // Bail and return the nodes as is.\n return impactedNodes;\n }\n\n const normalizedNodes: Types.Events.TraceImpactedNode[] = [];\n for (const impactedNode of impactedNodes) {\n const newNode = {...impactedNode};\n for (let i = 0; i < impactedNode.old_rect.length; i++) {\n newNode.old_rect[i] /= viewportScale;\n }\n for (let i = 0; i < impactedNode.new_rect.length; i++) {\n newNode.new_rect[i] /= viewportScale;\n }\n normalizedNodes.push(newNode);\n }\n\n const cacheForModel = normalizedLayoutShiftNodesCache.get(modelData) ||\n new Map<Types.Events.LayoutShift, readonly Types.Events.TraceImpactedNode[]>();\n cacheForModel.set(event, normalizedNodes);\n normalizedLayoutShiftNodesCache.set(modelData, cacheForModel);\n\n return normalizedNodes;\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type * as Handlers from '../handlers/handlers.js';
|
|
2
|
+
type GeneratedFileSizes = {
|
|
3
|
+
errorMessage: string;
|
|
4
|
+
} | {
|
|
5
|
+
files: Record<string, number>;
|
|
6
|
+
unmappedBytes: number;
|
|
7
|
+
totalBytes: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Using a script's contents and source map, attribute every generated byte to an authored source file.
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeGeneratedFileSizes(script: Handlers.ModelHandlers.Scripts.Script): GeneratedFileSizes;
|
|
13
|
+
export declare function normalizeSource(source: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* The key is a source map `sources` entry, but normalized via `normalizeSource`.
|
|
16
|
+
*
|
|
17
|
+
* The value is an array with an entry for every script that has a source map which
|
|
18
|
+
* denotes that this source was used, along with the estimated resource size it takes
|
|
19
|
+
* up in the script.
|
|
20
|
+
*/
|
|
21
|
+
export type ScriptDuplication = Map<string, Array<{
|
|
22
|
+
scriptId: string;
|
|
23
|
+
resourceSize: number;
|
|
24
|
+
}>>;
|
|
25
|
+
/**
|
|
26
|
+
* Sorts each array within @see ScriptDuplication by resource size, and drops information
|
|
27
|
+
* on sources that are too small.
|
|
28
|
+
*/
|
|
29
|
+
export declare function normalizeDuplication(duplication: ScriptDuplication): void;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a @see ScriptDuplication for the given collection of script contents + source maps.
|
|
32
|
+
*/
|
|
33
|
+
export declare function computeScriptDuplication(scriptsData: Handlers.ModelHandlers.Scripts.ScriptsData): ScriptDuplication;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Copyright 2025 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
const RELATIVE_SIZE_THRESHOLD = 0.1;
|
|
5
|
+
const ABSOLUTE_SIZE_THRESHOLD_BYTES = 1024 * 0.5;
|
|
6
|
+
/**
|
|
7
|
+
* Using a script's contents and source map, attribute every generated byte to an authored source file.
|
|
8
|
+
*/
|
|
9
|
+
export function computeGeneratedFileSizes(script) {
|
|
10
|
+
if (!script.sourceMap) {
|
|
11
|
+
throw new Error('expected source map');
|
|
12
|
+
}
|
|
13
|
+
const map = script.sourceMap;
|
|
14
|
+
const content = script.content ?? '';
|
|
15
|
+
const contentLength = content.length;
|
|
16
|
+
const lines = content.split('\n');
|
|
17
|
+
const files = {};
|
|
18
|
+
const totalBytes = contentLength;
|
|
19
|
+
let unmappedBytes = totalBytes;
|
|
20
|
+
const lastGeneratedColumnMap = computeLastGeneratedColumnMap(script.sourceMap);
|
|
21
|
+
for (const mapping of map.mappings()) {
|
|
22
|
+
const source = mapping.sourceURL;
|
|
23
|
+
const lineNum = mapping.lineNumber;
|
|
24
|
+
const colNum = mapping.columnNumber;
|
|
25
|
+
const lastColNum = lastGeneratedColumnMap.get(mapping);
|
|
26
|
+
// Webpack sometimes emits null mappings.
|
|
27
|
+
// https://github.com/mozilla/source-map/pull/303
|
|
28
|
+
if (!source) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
// Lines and columns are zero-based indices. Visually, lines are shown as a 1-based index.
|
|
32
|
+
const line = lines[lineNum];
|
|
33
|
+
if (line === null || line === undefined) {
|
|
34
|
+
const errorMessage = `${map.url()} mapping for line out of bounds: ${lineNum + 1}`;
|
|
35
|
+
return { errorMessage };
|
|
36
|
+
}
|
|
37
|
+
if (colNum > line.length) {
|
|
38
|
+
const errorMessage = `${map.url()} mapping for column out of bounds: ${lineNum + 1}:${colNum}`;
|
|
39
|
+
return { errorMessage };
|
|
40
|
+
}
|
|
41
|
+
let mappingLength = 0;
|
|
42
|
+
if (lastColNum !== undefined) {
|
|
43
|
+
if (lastColNum > line.length) {
|
|
44
|
+
const errorMessage = `${map.url()} mapping for last column out of bounds: ${lineNum + 1}:${lastColNum}`;
|
|
45
|
+
return { errorMessage };
|
|
46
|
+
}
|
|
47
|
+
mappingLength = lastColNum - colNum;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// Add +1 to account for the newline.
|
|
51
|
+
mappingLength = line.length - colNum + 1;
|
|
52
|
+
}
|
|
53
|
+
files[source] = (files[source] || 0) + mappingLength;
|
|
54
|
+
unmappedBytes -= mappingLength;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
files,
|
|
58
|
+
unmappedBytes,
|
|
59
|
+
totalBytes,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function normalizeSource(source) {
|
|
63
|
+
// Trim trailing question mark - b/c webpack.
|
|
64
|
+
source = source.replace(/\?$/, '');
|
|
65
|
+
// Normalize paths for dependencies by only keeping everything after the last `node_modules`.
|
|
66
|
+
const lastNodeModulesIndex = source.lastIndexOf('node_modules');
|
|
67
|
+
if (lastNodeModulesIndex !== -1) {
|
|
68
|
+
source = source.substring(lastNodeModulesIndex);
|
|
69
|
+
}
|
|
70
|
+
return source;
|
|
71
|
+
}
|
|
72
|
+
function shouldIgnoreSource(source) {
|
|
73
|
+
// Ignore bundle overhead.
|
|
74
|
+
if (source.includes('webpack/bootstrap')) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
if (source.includes('(webpack)/buildin')) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
// Ignore webpack module shims, i.e. aliases of the form `module.exports = window.jQuery`
|
|
81
|
+
if (source.includes('external ')) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Sorts each array within @see ScriptDuplication by resource size, and drops information
|
|
88
|
+
* on sources that are too small.
|
|
89
|
+
*/
|
|
90
|
+
export function normalizeDuplication(duplication) {
|
|
91
|
+
for (const [key, originalSourceData] of duplication.entries()) {
|
|
92
|
+
let sourceData = originalSourceData;
|
|
93
|
+
// Sort by resource size.
|
|
94
|
+
sourceData.sort((a, b) => b.resourceSize - a.resourceSize);
|
|
95
|
+
// Remove modules smaller than a % size of largest.
|
|
96
|
+
if (sourceData.length > 1) {
|
|
97
|
+
const largestResourceSize = sourceData[0].resourceSize;
|
|
98
|
+
sourceData = sourceData.filter(data => {
|
|
99
|
+
const percentSize = data.resourceSize / largestResourceSize;
|
|
100
|
+
return percentSize >= RELATIVE_SIZE_THRESHOLD;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// Remove modules smaller than an absolute threshold.
|
|
104
|
+
sourceData = sourceData.filter(data => data.resourceSize >= ABSOLUTE_SIZE_THRESHOLD_BYTES);
|
|
105
|
+
// Delete any that now don't have multiple source data entries.
|
|
106
|
+
if (sourceData.length > 1) {
|
|
107
|
+
duplication.set(key, sourceData);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
duplication.delete(key);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function computeLastGeneratedColumnMap(map) {
|
|
115
|
+
const result = new Map();
|
|
116
|
+
const mappings = map.mappings();
|
|
117
|
+
for (let i = 0; i < mappings.length - 1; i++) {
|
|
118
|
+
const mapping = mappings[i];
|
|
119
|
+
const nextMapping = mappings[i + 1];
|
|
120
|
+
if (mapping.lineNumber === nextMapping.lineNumber) {
|
|
121
|
+
result.set(mapping, nextMapping.columnNumber);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Now, all but the last mapping on each line will have 'lastColumnNumber' set to a number.
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns a @see ScriptDuplication for the given collection of script contents + source maps.
|
|
129
|
+
*/
|
|
130
|
+
export function computeScriptDuplication(scriptsData) {
|
|
131
|
+
const sizesMap = new Map();
|
|
132
|
+
for (const script of scriptsData.scripts.values()) {
|
|
133
|
+
if (script.content && script.sourceMap) {
|
|
134
|
+
sizesMap.set(script, computeGeneratedFileSizes(script));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const sourceDatasMap = new Map();
|
|
138
|
+
// Determine size of each `sources` entry.
|
|
139
|
+
for (const [script, sizes] of sizesMap) {
|
|
140
|
+
if (!script.sourceMap) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if ('errorMessage' in sizes) {
|
|
144
|
+
console.error(sizes.errorMessage);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const sourceDataArray = [];
|
|
148
|
+
sourceDatasMap.set(script, sourceDataArray);
|
|
149
|
+
const sources = script.sourceMap.sourceURLs();
|
|
150
|
+
for (let i = 0; i < sources.length; i++) {
|
|
151
|
+
if (shouldIgnoreSource(sources[i])) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const sourceSize = sizes.files[sources[i]];
|
|
155
|
+
sourceDataArray.push({
|
|
156
|
+
source: normalizeSource(sources[i]),
|
|
157
|
+
resourceSize: sourceSize,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const moduleNameToSourceData = new Map();
|
|
162
|
+
for (const [script, sourceDataArray] of sourceDatasMap) {
|
|
163
|
+
for (const sourceData of sourceDataArray) {
|
|
164
|
+
let data = moduleNameToSourceData.get(sourceData.source);
|
|
165
|
+
if (!data) {
|
|
166
|
+
data = [];
|
|
167
|
+
moduleNameToSourceData.set(sourceData.source, data);
|
|
168
|
+
}
|
|
169
|
+
data.push({
|
|
170
|
+
scriptId: script.scriptId,
|
|
171
|
+
resourceSize: sourceData.resourceSize,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
normalizeDuplication(moduleNameToSourceData);
|
|
176
|
+
return moduleNameToSourceData;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=ScriptDuplication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptDuplication.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/ScriptDuplication.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAK7B,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,6BAA6B,GAAG,IAAI,GAAG,GAAG,CAAC;AAMjD;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAA6C;IACrF,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;IAC7B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;IACrC,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IACrC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,MAAM,UAAU,GAAG,aAAa,CAAC;IACjC,IAAI,aAAa,GAAG,UAAU,CAAC;IAE/B,MAAM,sBAAsB,GAAG,6BAA6B,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAE/E,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;QACjC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;QACnC,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;QACpC,MAAM,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QACL,CAAC;IACH,CAAC;IAED,MAAM,sBAAsB,GAAsB,IAAI,GAAG,EAAE,CAAC;IAC5D,KAAK,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,cAAc,EAAE,CAAC;QACvD,KAAK,MAAM,UAAU,IAAI,eAAe,EAAE,CAAC;YACzC,IAAI,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,IAAI,GAAG,EAAE,CAAC;gBACV,sBAAsB,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACtD,CAAC;YACD,IAAI,CAAC,IAAI,CAAC;gBACR,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,YAAY,EAAE,UAAU,CAAC,YAAY;aACtC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;IAC7C,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["// Copyright 2025 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 type * as SDK from '../../../core/sdk/sdk.js';\nimport type * as Handlers from '../handlers/handlers.js';\n\nconst RELATIVE_SIZE_THRESHOLD = 0.1;\nconst ABSOLUTE_SIZE_THRESHOLD_BYTES = 1024 * 0.5;\n\ntype GeneratedFileSizes = {\n errorMessage: string,\n}|{files: Record<string, number>, unmappedBytes: number, totalBytes: number};\n\n/**\n * Using a script's contents and source map, attribute every generated byte to an authored source file.\n */\nexport function computeGeneratedFileSizes(script: Handlers.ModelHandlers.Scripts.Script): GeneratedFileSizes {\n if (!script.sourceMap) {\n throw new Error('expected source map');\n }\n\n const map = script.sourceMap;\n const content = script.content ?? '';\n const contentLength = content.length;\n const lines = content.split('\\n');\n const files: Record<string, number> = {};\n const totalBytes = contentLength;\n let unmappedBytes = totalBytes;\n\n const lastGeneratedColumnMap = computeLastGeneratedColumnMap(script.sourceMap);\n\n for (const mapping of map.mappings()) {\n const source = mapping.sourceURL;\n const lineNum = mapping.lineNumber;\n const colNum = mapping.columnNumber;\n const lastColNum = lastGeneratedColumnMap.get(mapping);\n\n // Webpack sometimes emits null mappings.\n // https://github.com/mozilla/source-map/pull/303\n if (!source) {\n continue;\n }\n\n // Lines and columns are zero-based indices. Visually, lines are shown as a 1-based index.\n\n const line = lines[lineNum];\n if (line === null || line === undefined) {\n const errorMessage = `${map.url()} mapping for line out of bounds: ${lineNum + 1}`;\n return {errorMessage};\n }\n\n if (colNum > line.length) {\n const errorMessage = `${map.url()} mapping for column out of bounds: ${lineNum + 1}:${colNum}`;\n return {errorMessage};\n }\n\n let mappingLength = 0;\n if (lastColNum !== undefined) {\n if (lastColNum > line.length) {\n const errorMessage = `${map.url()} mapping for last column out of bounds: ${lineNum + 1}:${lastColNum}`;\n return {errorMessage};\n }\n mappingLength = lastColNum - colNum;\n } else {\n // Add +1 to account for the newline.\n mappingLength = line.length - colNum + 1;\n }\n files[source] = (files[source] || 0) + mappingLength;\n unmappedBytes -= mappingLength;\n }\n\n return {\n files,\n unmappedBytes,\n totalBytes,\n };\n}\n\ninterface SourceData {\n source: string;\n resourceSize: number;\n}\n\nexport function normalizeSource(source: string): string {\n // Trim trailing question mark - b/c webpack.\n source = source.replace(/\\?$/, '');\n\n // Normalize paths for dependencies by only keeping everything after the last `node_modules`.\n const lastNodeModulesIndex = source.lastIndexOf('node_modules');\n if (lastNodeModulesIndex !== -1) {\n source = source.substring(lastNodeModulesIndex);\n }\n\n return source;\n}\n\nfunction shouldIgnoreSource(source: string): boolean {\n // Ignore bundle overhead.\n if (source.includes('webpack/bootstrap')) {\n return true;\n }\n if (source.includes('(webpack)/buildin')) {\n return true;\n }\n\n // Ignore webpack module shims, i.e. aliases of the form `module.exports = window.jQuery`\n if (source.includes('external ')) {\n return true;\n }\n\n return false;\n}\n\n/**\n * The key is a source map `sources` entry, but normalized via `normalizeSource`.\n *\n * The value is an array with an entry for every script that has a source map which\n * denotes that this source was used, along with the estimated resource size it takes\n * up in the script.\n */\nexport type ScriptDuplication = Map<string, Array<{scriptId: string, resourceSize: number}>>;\n\n/**\n * Sorts each array within @see ScriptDuplication by resource size, and drops information\n * on sources that are too small.\n */\nexport function normalizeDuplication(duplication: ScriptDuplication): void {\n for (const [key, originalSourceData] of duplication.entries()) {\n let sourceData = originalSourceData;\n\n // Sort by resource size.\n sourceData.sort((a, b) => b.resourceSize - a.resourceSize);\n\n // Remove modules smaller than a % size of largest.\n if (sourceData.length > 1) {\n const largestResourceSize = sourceData[0].resourceSize;\n sourceData = sourceData.filter(data => {\n const percentSize = data.resourceSize / largestResourceSize;\n return percentSize >= RELATIVE_SIZE_THRESHOLD;\n });\n }\n\n // Remove modules smaller than an absolute threshold.\n sourceData = sourceData.filter(data => data.resourceSize >= ABSOLUTE_SIZE_THRESHOLD_BYTES);\n\n // Delete any that now don't have multiple source data entries.\n if (sourceData.length > 1) {\n duplication.set(key, sourceData);\n } else {\n duplication.delete(key);\n }\n }\n}\n\nfunction computeLastGeneratedColumnMap(map: SDK.SourceMap.SourceMap): Map<SDK.SourceMap.SourceMapEntry, number> {\n const result = new Map<SDK.SourceMap.SourceMapEntry, number>();\n\n const mappings = map.mappings();\n for (let i = 0; i < mappings.length - 1; i++) {\n const mapping = mappings[i];\n const nextMapping = mappings[i + 1];\n if (mapping.lineNumber === nextMapping.lineNumber) {\n result.set(mapping, nextMapping.columnNumber);\n }\n }\n\n // Now, all but the last mapping on each line will have 'lastColumnNumber' set to a number.\n return result;\n}\n\n/**\n * Returns a @see ScriptDuplication for the given collection of script contents + source maps.\n */\nexport function computeScriptDuplication(scriptsData: Handlers.ModelHandlers.Scripts.ScriptsData): ScriptDuplication {\n const sizesMap = new Map<Handlers.ModelHandlers.Scripts.Script, GeneratedFileSizes>();\n for (const script of scriptsData.scripts.values()) {\n if (script.content && script.sourceMap) {\n sizesMap.set(script, computeGeneratedFileSizes(script));\n }\n }\n\n const sourceDatasMap = new Map<Handlers.ModelHandlers.Scripts.Script, SourceData[]>();\n\n // Determine size of each `sources` entry.\n for (const [script, sizes] of sizesMap) {\n if (!script.sourceMap) {\n continue;\n }\n\n if ('errorMessage' in sizes) {\n console.error(sizes.errorMessage);\n continue;\n }\n\n const sourceDataArray: SourceData[] = [];\n sourceDatasMap.set(script, sourceDataArray);\n\n const sources = script.sourceMap.sourceURLs();\n for (let i = 0; i < sources.length; i++) {\n if (shouldIgnoreSource(sources[i])) {\n continue;\n }\n\n const sourceSize = sizes.files[sources[i]];\n sourceDataArray.push({\n source: normalizeSource(sources[i]),\n resourceSize: sourceSize,\n });\n }\n }\n\n const moduleNameToSourceData: ScriptDuplication = new Map();\n for (const [script, sourceDataArray] of sourceDatasMap) {\n for (const sourceData of sourceDataArray) {\n let data = moduleNameToSourceData.get(sourceData.source);\n if (!data) {\n data = [];\n moduleNameToSourceData.set(sourceData.source, data);\n }\n data.push({\n scriptId: script.scriptId,\n resourceSize: sourceData.resourceSize,\n });\n }\n }\n\n normalizeDuplication(moduleNameToSourceData);\n return moduleNameToSourceData;\n}\n"]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Copyright 2024 The Chromium Authors. All rights reserved.
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
|
-
import * as Platform from '../../../core/platform/platform.js';
|
|
5
|
-
import * as Helpers from '../helpers/helpers.js';
|
|
6
4
|
import * as Types from '../types/types.js';
|
|
7
5
|
export const stackTraceForEventInTrace = new Map();
|
|
8
6
|
export function clearCacheForTrace(parsedTrace) {
|
|
@@ -31,6 +29,9 @@ export function get(event, parsedTrace) {
|
|
|
31
29
|
else if (Types.Extensions.isSyntheticExtensionEntry(event)) {
|
|
32
30
|
result = getForExtensionEntry(event, parsedTrace);
|
|
33
31
|
}
|
|
32
|
+
else if (Types.Events.isUserTiming(event)) {
|
|
33
|
+
result = getForUserTiming(event, parsedTrace);
|
|
34
|
+
}
|
|
34
35
|
if (result) {
|
|
35
36
|
cacheForTrace.set(event, result);
|
|
36
37
|
}
|
|
@@ -100,53 +101,33 @@ function getForProfileCall(event, parsedTrace) {
|
|
|
100
101
|
* trace.
|
|
101
102
|
*/
|
|
102
103
|
function getForExtensionEntry(event, parsedTrace) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
const callsInThread = parsedTrace.Renderer.processes.get(event.pid)?.threads.get(event.tid)?.profileCalls;
|
|
118
|
-
if (!callsInThread) {
|
|
119
|
-
return null;
|
|
104
|
+
return getForUserTiming(event.rawSourceEvent, parsedTrace);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Finds the JS call in which the user timing API was called and returns
|
|
108
|
+
* its stack trace.
|
|
109
|
+
*/
|
|
110
|
+
function getForUserTiming(event, parsedTrace) {
|
|
111
|
+
let rawEvent = event;
|
|
112
|
+
if (Types.Events.isPerformanceMeasureBegin(event)) {
|
|
113
|
+
if (event.args.traceId === undefined) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
rawEvent = parsedTrace.UserTimings.measureTraceByTraceId.get(event.args.traceId);
|
|
120
117
|
}
|
|
121
|
-
|
|
122
|
-
return e.callFrame.functionName === eventCallPoint.functionName;
|
|
123
|
-
});
|
|
124
|
-
const lastCallBeforeEventIndex = Platform.ArrayUtilities.nearestIndexFromEnd(matchByName, profileCall => profileCall.ts <= eventCallTime);
|
|
125
|
-
const firstCallAfterEventIndex = Platform.ArrayUtilities.nearestIndexFromBeginning(matchByName, profileCall => profileCall.ts >= eventCallTime);
|
|
126
|
-
const lastCallBeforeEvent = typeof lastCallBeforeEventIndex === 'number' && matchByName.at(lastCallBeforeEventIndex);
|
|
127
|
-
const firstCallAfterEvent = typeof firstCallAfterEventIndex === 'number' && matchByName.at(firstCallAfterEventIndex);
|
|
128
|
-
let closestMatchingProfileCall;
|
|
129
|
-
if (!lastCallBeforeEvent && !firstCallAfterEvent) {
|
|
118
|
+
if (!rawEvent) {
|
|
130
119
|
return null;
|
|
131
120
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
else if (!firstCallAfterEvent) {
|
|
138
|
-
closestMatchingProfileCall = lastCallBeforeEvent;
|
|
139
|
-
}
|
|
140
|
-
else if (Helpers.Trace.eventContainsTimestamp(lastCallBeforeEvent, eventCallTime)) {
|
|
141
|
-
closestMatchingProfileCall = lastCallBeforeEvent;
|
|
142
|
-
} // pick the closest when the choice isn't clear.
|
|
143
|
-
else if (eventCallTime - lastCallBeforeEvent.ts < firstCallAfterEvent.ts - eventCallTime) {
|
|
144
|
-
closestMatchingProfileCall = lastCallBeforeEvent;
|
|
121
|
+
// Look for the nearest profile call ancestor of the event tracing
|
|
122
|
+
// the call to the API.
|
|
123
|
+
let node = parsedTrace.Renderer.entryToNode.get(rawEvent);
|
|
124
|
+
while (node && !Types.Events.isProfileCall(node.entry)) {
|
|
125
|
+
node = node.parent;
|
|
145
126
|
}
|
|
146
|
-
|
|
147
|
-
|
|
127
|
+
if (node && Types.Events.isProfileCall(node.entry)) {
|
|
128
|
+
return get(node.entry, parsedTrace);
|
|
148
129
|
}
|
|
149
|
-
return
|
|
130
|
+
return null;
|
|
150
131
|
}
|
|
151
132
|
/**
|
|
152
133
|
* Determines if a function is a native JS API (like setTimeout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackTraceForEvent.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/StackTraceForEvent.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;A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O,wBAAwB,KAAK,QAAQ,IAAI,WAAW,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC;IAErH,IAAI,0BAA6D,CAAC;IAClE,IAAI,CAAC,mBAAmB,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,iEAAiE;QACjE,0CAA0C;QAC1C,0BAA0B,GAAG,mBAAwD,CAAC;IACxF,CAAC;SAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAChC,0BAA0B,GAAG,mBAAmB,CAAC;IACnD,CAAC;SAAM,IAAI,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,EAAE,aAAa,CAAC,EAAE,CAAC;QACpF,0BAA0B,GAAG,mBAAmB,CAAC;IACnD,CAAC,CAAE,gDAAgD;SAC9C,IAAI,aAAa,GAAG,mBAAmB,CAAC,EAAE,GAAG,mBAAmB,CAAC,EAAE,GAAG,aAAa,EAAE,CAAC;QACzF,0BAA0B,GAAG,mBAAmB,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,0BAA0B,GAAG,mBAAmB,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,CAAC,0BAA0B,EAAE,WAAW,CAAC,CAAC;AACtD,CAAC;AACD;;;;;;;;GAQG;AACH,SAAS,kBAAkB,CAAC,EAAC,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAA6B;IAC/F,OAAO,UAAU,KAAK,CAAC,CAAC,IAAI,YAAY,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,QAAQ,KAAK,GAAG,CAAC;AACpF,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 Platform from '../../../core/platform/platform.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nexport const stackTraceForEventInTrace =\n new Map<Handlers.Types.ParsedTrace, Map<Types.Events.Event, Protocol.Runtime.StackTrace>>();\n\nexport function clearCacheForTrace(parsedTrace: Handlers.Types.ParsedTrace): void {\n stackTraceForEventInTrace.delete(parsedTrace);\n}\n/**\n * This util builds a stack trace that includes async calls for a given\n * event. It leverages data we collect from sampling to deduce sync\n * stacks and trace event instrumentation on the V8 debugger to stitch\n * them together.\n */\nexport function get(event: Types.Events.Event, parsedTrace: Handlers.Types.ParsedTrace): Protocol.Runtime.StackTrace|\n null {\n let cacheForTrace = stackTraceForEventInTrace.get(parsedTrace);\n if (!cacheForTrace) {\n cacheForTrace = new Map();\n stackTraceForEventInTrace.set(parsedTrace, cacheForTrace);\n }\n const resultFromCache = cacheForTrace.get(event);\n if (resultFromCache) {\n return resultFromCache;\n }\n let result: Protocol.Runtime.StackTrace|null = null;\n if (Types.Events.isProfileCall(event)) {\n result = getForProfileCall(event, parsedTrace);\n } else if (Types.Extensions.isSyntheticExtensionEntry(event)) {\n result = getForExtensionEntry(event, parsedTrace);\n }\n if (result) {\n cacheForTrace.set(event, result);\n }\n return result;\n}\n\nfunction getForProfileCall(\n event: Types.Events.SyntheticProfileCall, parsedTrace: Handlers.Types.ParsedTrace): Protocol.Runtime.StackTrace {\n // When working with a CPU profile the renderer handler won't have\n // entries in its tree.\n const entryToNode =\n parsedTrace.Renderer.entryToNode.size > 0 ? parsedTrace.Renderer.entryToNode : parsedTrace.Samples.entryToNode;\n const topStackTrace: Protocol.Runtime.StackTrace = {callFrames: []};\n let stackTrace: Protocol.Runtime.StackTrace = topStackTrace;\n let currentEntry = event;\n let node: Helpers.TreeHelpers.TraceEntryNode|null|undefined = entryToNode.get(event);\n const traceCache =\n stackTraceForEventInTrace.get(parsedTrace) || new Map<Types.Events.Event, Protocol.Runtime.StackTrace>();\n stackTraceForEventInTrace.set(parsedTrace, traceCache);\n // Move up this node's ancestor tree appending frames to its\n // stack trace.\n while (node) {\n if (!Types.Events.isProfileCall(node.entry)) {\n node = node.parent;\n continue;\n }\n\n currentEntry = node.entry;\n // First check if this entry was processed before.\n const stackTraceFromCache = traceCache.get(node.entry);\n if (stackTraceFromCache) {\n stackTrace.callFrames.push(...stackTraceFromCache.callFrames.filter(callFrame => !isNativeJSFunction(callFrame)));\n stackTrace.parent = stackTraceFromCache.parent;\n // Only set the description to the cache value if we didn't\n // compute it in the previous iteration, since the async stack\n // trace descriptions / taskNames is only extracted when jumping\n // to the async parent, and that might not have happened when\n // the cached value was computed (e.g. the cached value\n // computation started at some point inside the parent stack\n // trace).\n stackTrace.description = stackTrace.description || stackTraceFromCache.description;\n break;\n }\n\n if (!isNativeJSFunction(currentEntry.callFrame)) {\n stackTrace.callFrames.push(currentEntry.callFrame);\n }\n const maybeAsyncParentEvent = parsedTrace.AsyncJSCalls.asyncCallToScheduler.get(currentEntry);\n const maybeAsyncParentNode = maybeAsyncParentEvent && entryToNode.get(maybeAsyncParentEvent.scheduler);\n if (maybeAsyncParentNode) {\n // The Protocol.Runtime.StackTrace type is recursive, so we\n // move one level deeper in it as we walk up the ancestor tree.\n stackTrace.parent = {callFrames: []};\n stackTrace = stackTrace.parent;\n // Note: this description effectively corresponds to the name\n // of the task that scheduled the stack trace we are jumping\n // FROM, so it would make sense that it was set to that stack\n // trace instead of the one we are jumping TO. However, the\n // JS presentation utils we use to present async stack traces\n // assume the description is added to the stack trace that\n // scheduled the async task, so we build the data that way.\n stackTrace.description = maybeAsyncParentEvent.taskName;\n node = maybeAsyncParentNode;\n continue;\n }\n node = node.parent;\n }\n return topStackTrace;\n}\n\n/**\n * Finds the JS call in which an extension entry was injected (the\n * code location that called the extension API), and returns its stack\n * trace.\n */\nfunction getForExtensionEntry(event: Types.Extensions.SyntheticExtensionEntry, parsedTrace: Handlers.Types.ParsedTrace):\n Protocol.Runtime.StackTrace|null {\n const eventCallPoint = Helpers.Trace.getZeroIndexedStackTraceForEvent(event)?.[0];\n if (!eventCallPoint) {\n return null;\n }\n const eventCallTime = Types.Events.isPerformanceMeasureBegin(event.rawSourceEvent) ?\n event.rawSourceEvent.args.callTime :\n Types.Events.isPerformanceMark(event.rawSourceEvent) ?\n event.rawSourceEvent.args.data?.callTime :\n // event added with console.timeStamp: take the original event's\n // ts.\n event.rawSourceEvent.ts;\n if (eventCallTime === undefined) {\n return null;\n }\n const callsInThread = parsedTrace.Renderer.processes.get(event.pid)?.threads.get(event.tid)?.profileCalls;\n if (!callsInThread) {\n return null;\n }\n const matchByName = callsInThread.filter(e => {\n return e.callFrame.functionName === eventCallPoint.functionName;\n });\n\n const lastCallBeforeEventIndex =\n Platform.ArrayUtilities.nearestIndexFromEnd(matchByName, profileCall => profileCall.ts <= eventCallTime);\n const firstCallAfterEventIndex =\n Platform.ArrayUtilities.nearestIndexFromBeginning(matchByName, profileCall => profileCall.ts >= eventCallTime);\n const lastCallBeforeEvent = typeof lastCallBeforeEventIndex === 'number' && matchByName.at(lastCallBeforeEventIndex);\n const firstCallAfterEvent = typeof firstCallAfterEventIndex === 'number' && matchByName.at(firstCallAfterEventIndex);\n\n let closestMatchingProfileCall: Types.Events.SyntheticProfileCall;\n if (!lastCallBeforeEvent && !firstCallAfterEvent) {\n return null;\n }\n if (!lastCallBeforeEvent) {\n // Per the check above firstCallAfterEvent is guaranteed to exist\n // but ts is unaware, so we cast the type.\n closestMatchingProfileCall = firstCallAfterEvent as Types.Events.SyntheticProfileCall;\n } else if (!firstCallAfterEvent) {\n closestMatchingProfileCall = lastCallBeforeEvent;\n } else if (Helpers.Trace.eventContainsTimestamp(lastCallBeforeEvent, eventCallTime)) {\n closestMatchingProfileCall = lastCallBeforeEvent;\n } // pick the closest when the choice isn't clear.\n else if (eventCallTime - lastCallBeforeEvent.ts < firstCallAfterEvent.ts - eventCallTime) {\n closestMatchingProfileCall = lastCallBeforeEvent;\n } else {\n closestMatchingProfileCall = firstCallAfterEvent;\n }\n return get(closestMatchingProfileCall, parsedTrace);\n}\n/**\n * Determines if a function is a native JS API (like setTimeout,\n * requestAnimationFrame, consoleTask.run. etc.). This is useful to\n * discard stack frames corresponding to the JS scheduler function\n * itself, since it's already being used as title of async stack traces\n * taken from the async `taskName`. This is also consistent with the\n * behaviour of the stack trace in the sources\n * panel.\n */\nfunction isNativeJSFunction({columnNumber, lineNumber, url, scriptId}: Protocol.Runtime.CallFrame): boolean {\n return lineNumber === -1 && columnNumber === -1 && url === '' && scriptId === '0';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StackTraceForEvent.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/StackTraceForEvent.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAK7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,MAAM,CAAC,MAAM,yBAAyB,GAClC,IAAI,GAAG,EAAoF,CAAC;AAEhG,MAAM,UAAU,kBAAkB,CAAC,WAAuC;IACxE,yBAAyB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,KAAyB,EAAE,WAAuC;IAEpF,IAAI,aAAa,GAAG,yBAAyB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC/D,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,yBAAyB,CAAC,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,eAAe,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,IAAI,MAAM,GAAqC,IAAI,CAAC;IACpD,IAAI,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,GAAG,iBAAiB,CAAC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CAAC,EAAE,CAAC;QACnD,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AACD;;;;;;;;GAQG;AACH,SAAS,kBAAkB,CAAC,EAAC,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAA6B;IAC/F,OAAO,UAAU,KAAK,CAAC,CAAC,IAAI,YAAY,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,QAAQ,KAAK,GAAG,CAAC;AACpF,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 type * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport type * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nexport const stackTraceForEventInTrace =\n new Map<Handlers.Types.ParsedTrace, Map<Types.Events.Event, Protocol.Runtime.StackTrace>>();\n\nexport function clearCacheForTrace(parsedTrace: Handlers.Types.ParsedTrace): void {\n stackTraceForEventInTrace.delete(parsedTrace);\n}\n/**\n * This util builds a stack trace that includes async calls for a given\n * event. It leverages data we collect from sampling to deduce sync\n * stacks and trace event instrumentation on the V8 debugger to stitch\n * them together.\n */\nexport function get(event: Types.Events.Event, parsedTrace: Handlers.Types.ParsedTrace): Protocol.Runtime.StackTrace|\n null {\n let cacheForTrace = stackTraceForEventInTrace.get(parsedTrace);\n if (!cacheForTrace) {\n cacheForTrace = new Map();\n stackTraceForEventInTrace.set(parsedTrace, cacheForTrace);\n }\n const resultFromCache = cacheForTrace.get(event);\n if (resultFromCache) {\n return resultFromCache;\n }\n let result: Protocol.Runtime.StackTrace|null = null;\n if (Types.Events.isProfileCall(event)) {\n result = getForProfileCall(event, parsedTrace);\n } else if (Types.Extensions.isSyntheticExtensionEntry(event)) {\n result = getForExtensionEntry(event, parsedTrace);\n } else if (Types.Events.isUserTiming(event)) {\n result = getForUserTiming(event, parsedTrace);\n }\n if (result) {\n cacheForTrace.set(event, result);\n }\n return result;\n}\n\nfunction getForProfileCall(\n event: Types.Events.SyntheticProfileCall, parsedTrace: Handlers.Types.ParsedTrace): Protocol.Runtime.StackTrace {\n // When working with a CPU profile the renderer handler won't have\n // entries in its tree.\n const entryToNode =\n parsedTrace.Renderer.entryToNode.size > 0 ? parsedTrace.Renderer.entryToNode : parsedTrace.Samples.entryToNode;\n const topStackTrace: Protocol.Runtime.StackTrace = {callFrames: []};\n let stackTrace: Protocol.Runtime.StackTrace = topStackTrace;\n let currentEntry = event;\n let node: Helpers.TreeHelpers.TraceEntryNode|null|undefined = entryToNode.get(event);\n const traceCache =\n stackTraceForEventInTrace.get(parsedTrace) || new Map<Types.Events.Event, Protocol.Runtime.StackTrace>();\n stackTraceForEventInTrace.set(parsedTrace, traceCache);\n // Move up this node's ancestor tree appending frames to its\n // stack trace.\n while (node) {\n if (!Types.Events.isProfileCall(node.entry)) {\n node = node.parent;\n continue;\n }\n\n currentEntry = node.entry;\n // First check if this entry was processed before.\n const stackTraceFromCache = traceCache.get(node.entry);\n if (stackTraceFromCache) {\n stackTrace.callFrames.push(...stackTraceFromCache.callFrames.filter(callFrame => !isNativeJSFunction(callFrame)));\n stackTrace.parent = stackTraceFromCache.parent;\n // Only set the description to the cache value if we didn't\n // compute it in the previous iteration, since the async stack\n // trace descriptions / taskNames is only extracted when jumping\n // to the async parent, and that might not have happened when\n // the cached value was computed (e.g. the cached value\n // computation started at some point inside the parent stack\n // trace).\n stackTrace.description = stackTrace.description || stackTraceFromCache.description;\n break;\n }\n\n if (!isNativeJSFunction(currentEntry.callFrame)) {\n stackTrace.callFrames.push(currentEntry.callFrame);\n }\n const maybeAsyncParentEvent = parsedTrace.AsyncJSCalls.asyncCallToScheduler.get(currentEntry);\n const maybeAsyncParentNode = maybeAsyncParentEvent && entryToNode.get(maybeAsyncParentEvent.scheduler);\n if (maybeAsyncParentNode) {\n // The Protocol.Runtime.StackTrace type is recursive, so we\n // move one level deeper in it as we walk up the ancestor tree.\n stackTrace.parent = {callFrames: []};\n stackTrace = stackTrace.parent;\n // Note: this description effectively corresponds to the name\n // of the task that scheduled the stack trace we are jumping\n // FROM, so it would make sense that it was set to that stack\n // trace instead of the one we are jumping TO. However, the\n // JS presentation utils we use to present async stack traces\n // assume the description is added to the stack trace that\n // scheduled the async task, so we build the data that way.\n stackTrace.description = maybeAsyncParentEvent.taskName;\n node = maybeAsyncParentNode;\n continue;\n }\n node = node.parent;\n }\n return topStackTrace;\n}\n\n/**\n * Finds the JS call in which an extension entry was injected (the\n * code location that called the extension API), and returns its stack\n * trace.\n */\nfunction getForExtensionEntry(event: Types.Extensions.SyntheticExtensionEntry, parsedTrace: Handlers.Types.ParsedTrace):\n Protocol.Runtime.StackTrace|null {\n return getForUserTiming(event.rawSourceEvent, parsedTrace);\n}\n\n/**\n * Finds the JS call in which the user timing API was called and returns\n * its stack trace.\n */\nfunction getForUserTiming(\n event: Types.Events.UserTiming|Types.Events.ConsoleTimeStamp,\n parsedTrace: Handlers.Types.ParsedTrace): Protocol.Runtime.StackTrace|null {\n let rawEvent: Types.Events.Event|undefined = event;\n if (Types.Events.isPerformanceMeasureBegin(event)) {\n if (event.args.traceId === undefined) {\n return null;\n }\n rawEvent = parsedTrace.UserTimings.measureTraceByTraceId.get(event.args.traceId);\n }\n if (!rawEvent) {\n return null;\n }\n // Look for the nearest profile call ancestor of the event tracing\n // the call to the API.\n let node: Helpers.TreeHelpers.TraceEntryNode|undefined|null = parsedTrace.Renderer.entryToNode.get(rawEvent);\n while (node && !Types.Events.isProfileCall(node.entry)) {\n node = node.parent;\n }\n if (node && Types.Events.isProfileCall(node.entry)) {\n return get(node.entry, parsedTrace);\n }\n return null;\n}\n/**\n * Determines if a function is a native JS API (like setTimeout,\n * requestAnimationFrame, consoleTask.run. etc.). This is useful to\n * discard stack frames corresponding to the JS scheduler function\n * itself, since it's already being used as title of async stack traces\n * taken from the async `taskName`. This is also consistent with the\n * behaviour of the stack trace in the sources\n * panel.\n */\nfunction isNativeJSFunction({columnNumber, lineNumber, url, scriptId}: Protocol.Runtime.CallFrame): boolean {\n return lineNumber === -1 && columnNumber === -1 && url === '' && scriptId === '0';\n}\n"]}
|
|
@@ -34,6 +34,7 @@ function getOrMakeSummaryByURL(thirdPartySummary, url) {
|
|
|
34
34
|
thirdPartySummary.byUrl.set(url, summary);
|
|
35
35
|
return summary;
|
|
36
36
|
}
|
|
37
|
+
// TODO: Remove and use the the BottomUpRootNode defined in ThirdPartyTreeView instead.
|
|
37
38
|
function collectMainThreadActivity(thirdPartySummary, parsedTrace, bounds) {
|
|
38
39
|
for (const process of parsedTrace.Renderer.processes.values()) {
|
|
39
40
|
if (!process.isOnMainFrame) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThirdParties.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/ThirdParties.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,aAAa,MAAM,yDAAyD,CAAC;AACzF,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAiB3C,SAAS,wBAAwB,CAC7B,iBAAoC,EAAE,KAAyB,EAAE,GAAW;IAC9E,MAAM,MAAM,GAAG,aAAa,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC;QACrD,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IAC5E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,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AC;IACnD,MAAM,SAAS,GAAG,wBAAwB,CAAC,SAAS,EAAE,qBAAqB,EAAE,sBAAsB,CAAC,CAAC;IAErG,OAAO,EAAC,SAAS,EAAE,aAAa,EAAE,qBAAqB,EAAC,CAAC;AAC3D,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 ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nexport type Entity = typeof ThirdPartyWeb.ThirdPartyWeb.entities[number];\n\nexport interface Summary {\n transferSize: number;\n mainThreadTime: Types.Timing.Micro;\n}\n\nexport interface ThirdPartySummary {\n byEntity: Map<Entity, Summary>;\n byUrl: Map<string, Summary>;\n urlsByEntity: Map<Entity, Set<string>>;\n eventsByEntity: Map<Entity, Types.Events.Event[]>;\n madeUpEntityCache: Map<string, Entity>;\n}\n\nfunction getOrMakeSummaryByEntity(\n thirdPartySummary: ThirdPartySummary, event: Types.Events.Event, url: string): Summary|null {\n const entity = ThirdPartyWeb.ThirdPartyWeb.getEntity(url) ??\n Handlers.Helpers.makeUpEntity(thirdPartySummary.madeUpEntityCache, url);\n if (!entity) {\n return null;\n }\n\n const urls = thirdPartySummary.urlsByEntity.get(entity) ?? new Set();\n urls.add(url);\n thirdPartySummary.urlsByEntity.set(entity, urls);\n\n const events = thirdPartySummary.eventsByEntity.get(entity) ?? [];\n events.push(event);\n thirdPartySummary.eventsByEntity.set(entity, events);\n\n let summary = thirdPartySummary.byEntity.get(entity);\n if (summary) {\n return summary;\n }\n\n summary = {transferSize: 0, mainThreadTime: Types.Timing.Micro(0)};\n thirdPartySummary.byEntity.set(entity, summary);\n return summary;\n}\n\nfunction getOrMakeSummaryByURL(thirdPartySummary: ThirdPartySummary, url: string): Summary|null {\n let summary = thirdPartySummary.byUrl.get(url);\n if (summary) {\n return summary;\n }\n\n summary = {transferSize: 0, mainThreadTime: Types.Timing.Micro(0)};\n thirdPartySummary.byUrl.set(url, summary);\n return summary;\n}\n\nfunction collectMainThreadActivity(\n thirdPartySummary: ThirdPartySummary, parsedTrace: Handlers.Types.ParsedTrace,\n bounds: Types.Timing.TraceWindowMicro): void {\n for (const process of parsedTrace.Renderer.processes.values()) {\n if (!process.isOnMainFrame) {\n continue;\n }\n\n for (const thread of process.threads.values()) {\n if (thread.name === 'CrRendererMain') {\n if (!thread.tree) {\n break;\n }\n\n for (const event of thread.entries) {\n if (!Helpers.Timing.eventIsInBounds(event, bounds)) {\n continue;\n }\n\n const node = parsedTrace.Renderer.entryToNode.get(event);\n if (!node || !node.selfTime) {\n continue;\n }\n\n const url = Handlers.Helpers.getNonResolvedURL(event, parsedTrace as Handlers.Types.ParsedTrace);\n if (!url) {\n continue;\n }\n\n let summary = getOrMakeSummaryByEntity(thirdPartySummary, event, url);\n if (summary) {\n summary.mainThreadTime = (summary.mainThreadTime + node.selfTime) as Types.Timing.Micro;\n }\n\n summary = getOrMakeSummaryByURL(thirdPartySummary, url);\n if (summary) {\n summary.mainThreadTime = (summary.mainThreadTime + node.selfTime) as Types.Timing.Micro;\n }\n }\n }\n }\n }\n}\n\nfunction collectNetworkActivity(\n thirdPartySummary: ThirdPartySummary, requests: Types.Events.SyntheticNetworkRequest[]): void {\n for (const request of requests) {\n const url = request.args.data.url;\n\n let summary = getOrMakeSummaryByEntity(thirdPartySummary, request, url);\n if (summary) {\n summary.transferSize += request.args.data.encodedDataLength;\n }\n\n summary = getOrMakeSummaryByURL(thirdPartySummary, url);\n if (summary) {\n summary.transferSize += request.args.data.encodedDataLength;\n }\n }\n}\n\n/**\n * @param networkRequests Won't be filtered by trace bounds, so callers should ensure it is filtered.\n */\nexport function summarizeThirdParties(\n parsedTrace: Handlers.Types.ParsedTrace, traceBounds: Types.Timing.TraceWindowMicro,\n networkRequests: Types.Events.SyntheticNetworkRequest[]): ThirdPartySummary {\n const thirdPartySummary: ThirdPartySummary = {\n byEntity: new Map(),\n byUrl: new Map(),\n urlsByEntity: new Map(),\n eventsByEntity: new Map(),\n madeUpEntityCache: new Map(),\n };\n\n collectMainThreadActivity(thirdPartySummary, parsedTrace, traceBounds);\n collectNetworkActivity(thirdPartySummary, networkRequests);\n\n return thirdPartySummary;\n}\n\nfunction getSummaryMapWithMapping(\n events: Types.Events.Event[], entityByEvent: Map<Types.Events.Event, Handlers.Helpers.Entity>,\n eventsByEntity: Map<Handlers.Helpers.Entity, Types.Events.Event[]>): ThirdPartySummary {\n const byEvent = new Map<Types.Events.Event, Summary>();\n const byEntity = new Map<Handlers.Helpers.Entity, Summary>();\n const defaultSummary: Summary = {transferSize: 0, mainThreadTime: Types.Timing.Micro(0)};\n\n for (const event of events) {\n const urlSummary = byEvent.get(event) || {...defaultSummary};\n if (Types.Events.isSyntheticNetworkRequest(event)) {\n urlSummary.transferSize += event.args.data.encodedDataLength;\n }\n byEvent.set(event, urlSummary);\n }\n\n // Map each request's stat to a particular entity.\n for (const [request, requestSummary] of byEvent.entries()) {\n const entity = entityByEvent.get(request);\n if (!entity) {\n byEvent.delete(request);\n continue;\n }\n\n const entitySummary = byEntity.get(entity) || {...defaultSummary};\n entitySummary.transferSize += requestSummary.transferSize;\n byEntity.set(entity, entitySummary);\n }\n\n return {byEntity, eventsByEntity, madeUpEntityCache: new Map(), byUrl: new Map(), urlsByEntity: new Map()};\n}\n\n// TODO(crbug.com/352244718): Remove or refactor to use summarizeThirdParties/collectMainThreadActivity/etc.\n/**\n * Note: unlike summarizeThirdParties, this does not calculate mainThreadTime. The reason is that it is not\n * needed for its one use case, and when dragging the trace bounds it takes a long time to calculate.\n * If it is ever needed, we need to make getSelfTimeByUrl (see deleted code/blame) much faster (cache + bucket?).\n */\nexport function getSummariesAndEntitiesWithMapping(\n parsedTrace: Handlers.Types.ParsedTrace, traceBounds: Types.Timing.TraceWindowMicro,\n entityMapping: Handlers.Helpers.EntityMappings): {\n summaries: ThirdPartySummary,\n entityByEvent: Map<Types.Events.Event, Handlers.Helpers.Entity>,\n} {\n const entityByEvent = new Map(entityMapping.entityByEvent);\n const eventsByEntity = new Map(entityMapping.eventsByEntity);\n\n // Consider events only in bounds.\n const entityByEventArr = Array.from(entityByEvent.entries());\n const filteredEntries = entityByEventArr.filter(([event]) => {\n return Helpers.Timing.eventIsInBounds(event, traceBounds);\n });\n const entityByEventFiltered = new Map(filteredEntries);\n\n // Consider events only in bounds.\n const eventsByEntityArr = Array.from(eventsByEntity.entries());\n const filtered = eventsByEntityArr.filter(([, events]) => {\n events.map(event => {\n return Helpers.Timing.eventIsInBounds(event, traceBounds);\n });\n return events.length > 0;\n });\n const eventsByEntityFiltered = new Map(filtered);\n\n const allEvents = Array.from(entityByEvent.keys());\n const summaries = getSummaryMapWithMapping(allEvents, entityByEventFiltered, eventsByEntityFiltered);\n\n return {summaries, entityByEvent: entityByEventFiltered};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ThirdParties.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/ThirdParties.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,aAAa,MAAM,yDAAyD,CAAC;AACzF,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAiB3C,SAAS,wBAAwB,CAC7B,iBAAoC,EAAE,KAAyB,EAAE,GAAW;IAC9E,MAAM,MAAM,GAAG,aAAa,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC;QACrD,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IAC5E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAA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C;IAEjD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,wBAAwB,CAAC,SAAS,EAAE,qBAAqB,EAAE,sBAAsB,CAAC,CAAC;IAErG,OAAO,EAAC,SAAS,EAAE,aAAa,EAAE,qBAAqB,EAAC,CAAC;AAC3D,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 ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nexport type Entity = typeof ThirdPartyWeb.ThirdPartyWeb.entities[number];\n\nexport interface Summary {\n transferSize: number;\n mainThreadTime: Types.Timing.Micro;\n}\n\nexport interface ThirdPartySummary {\n byEntity: Map<Entity, Summary>;\n byUrl: Map<string, Summary>;\n urlsByEntity: Map<Entity, Set<string>>;\n eventsByEntity: Map<Entity, Types.Events.Event[]>;\n madeUpEntityCache: Map<string, Entity>;\n}\n\nfunction getOrMakeSummaryByEntity(\n thirdPartySummary: ThirdPartySummary, event: Types.Events.Event, url: string): Summary|null {\n const entity = ThirdPartyWeb.ThirdPartyWeb.getEntity(url) ??\n Handlers.Helpers.makeUpEntity(thirdPartySummary.madeUpEntityCache, url);\n if (!entity) {\n return null;\n }\n\n const urls = thirdPartySummary.urlsByEntity.get(entity) ?? new Set();\n urls.add(url);\n thirdPartySummary.urlsByEntity.set(entity, urls);\n\n const events = thirdPartySummary.eventsByEntity.get(entity) ?? [];\n events.push(event);\n thirdPartySummary.eventsByEntity.set(entity, events);\n\n let summary = thirdPartySummary.byEntity.get(entity);\n if (summary) {\n return summary;\n }\n\n summary = {transferSize: 0, mainThreadTime: Types.Timing.Micro(0)};\n thirdPartySummary.byEntity.set(entity, summary);\n return summary;\n}\n\nfunction getOrMakeSummaryByURL(thirdPartySummary: ThirdPartySummary, url: string): Summary|null {\n let summary = thirdPartySummary.byUrl.get(url);\n if (summary) {\n return summary;\n }\n\n summary = {transferSize: 0, mainThreadTime: Types.Timing.Micro(0)};\n thirdPartySummary.byUrl.set(url, summary);\n return summary;\n}\n\n// TODO: Remove and use the the BottomUpRootNode defined in ThirdPartyTreeView instead.\nfunction collectMainThreadActivity(\n thirdPartySummary: ThirdPartySummary, parsedTrace: Handlers.Types.ParsedTrace,\n bounds: Types.Timing.TraceWindowMicro): void {\n for (const process of parsedTrace.Renderer.processes.values()) {\n if (!process.isOnMainFrame) {\n continue;\n }\n\n for (const thread of process.threads.values()) {\n if (thread.name === 'CrRendererMain') {\n if (!thread.tree) {\n break;\n }\n\n for (const event of thread.entries) {\n if (!Helpers.Timing.eventIsInBounds(event, bounds)) {\n continue;\n }\n\n const node = parsedTrace.Renderer.entryToNode.get(event);\n if (!node || !node.selfTime) {\n continue;\n }\n\n const url = Handlers.Helpers.getNonResolvedURL(event, parsedTrace);\n if (!url) {\n continue;\n }\n\n let summary = getOrMakeSummaryByEntity(thirdPartySummary, event, url);\n if (summary) {\n summary.mainThreadTime = (summary.mainThreadTime + node.selfTime) as Types.Timing.Micro;\n }\n\n summary = getOrMakeSummaryByURL(thirdPartySummary, url);\n if (summary) {\n summary.mainThreadTime = (summary.mainThreadTime + node.selfTime) as Types.Timing.Micro;\n }\n }\n }\n }\n }\n}\n\nfunction collectNetworkActivity(\n thirdPartySummary: ThirdPartySummary, requests: Types.Events.SyntheticNetworkRequest[]): void {\n for (const request of requests) {\n const url = request.args.data.url;\n\n let summary = getOrMakeSummaryByEntity(thirdPartySummary, request, url);\n if (summary) {\n summary.transferSize += request.args.data.encodedDataLength;\n }\n\n summary = getOrMakeSummaryByURL(thirdPartySummary, url);\n if (summary) {\n summary.transferSize += request.args.data.encodedDataLength;\n }\n }\n}\n\n/**\n * @param networkRequests Won't be filtered by trace bounds, so callers should ensure it is filtered.\n */\nexport function summarizeThirdParties(\n parsedTrace: Handlers.Types.ParsedTrace, traceBounds: Types.Timing.TraceWindowMicro,\n networkRequests: Types.Events.SyntheticNetworkRequest[]): ThirdPartySummary {\n const thirdPartySummary: ThirdPartySummary = {\n byEntity: new Map(),\n byUrl: new Map(),\n urlsByEntity: new Map(),\n eventsByEntity: new Map(),\n madeUpEntityCache: new Map(),\n };\n\n collectMainThreadActivity(thirdPartySummary, parsedTrace, traceBounds);\n collectNetworkActivity(thirdPartySummary, networkRequests);\n\n return thirdPartySummary;\n}\n\nfunction getSummaryMapWithMapping(\n events: Types.Events.Event[], entityByEvent: Map<Types.Events.Event, Handlers.Helpers.Entity>,\n eventsByEntity: Map<Handlers.Helpers.Entity, Types.Events.Event[]>): ThirdPartySummary {\n const byEvent = new Map<Types.Events.Event, Summary>();\n const byEntity = new Map<Handlers.Helpers.Entity, Summary>();\n const defaultSummary: Summary = {transferSize: 0, mainThreadTime: Types.Timing.Micro(0)};\n\n for (const event of events) {\n const urlSummary = byEvent.get(event) || {...defaultSummary};\n if (Types.Events.isSyntheticNetworkRequest(event)) {\n urlSummary.transferSize += event.args.data.encodedDataLength;\n }\n byEvent.set(event, urlSummary);\n }\n\n // Map each request's stat to a particular entity.\n for (const [request, requestSummary] of byEvent.entries()) {\n const entity = entityByEvent.get(request);\n if (!entity) {\n byEvent.delete(request);\n continue;\n }\n\n const entitySummary = byEntity.get(entity) || {...defaultSummary};\n entitySummary.transferSize += requestSummary.transferSize;\n byEntity.set(entity, entitySummary);\n }\n\n return {byEntity, eventsByEntity, madeUpEntityCache: new Map(), byUrl: new Map(), urlsByEntity: new Map()};\n}\n\n// TODO(crbug.com/352244718): Remove or refactor to use summarizeThirdParties/collectMainThreadActivity/etc.\n/**\n * Note: unlike summarizeThirdParties, this does not calculate mainThreadTime. The reason is that it is not\n * needed for its one use case, and when dragging the trace bounds it takes a long time to calculate.\n * If it is ever needed, we need to make getSelfTimeByUrl (see deleted code/blame) much faster (cache + bucket?).\n */\nexport function getSummariesAndEntitiesWithMapping(\n parsedTrace: Handlers.Types.ParsedTrace, traceBounds: Types.Timing.TraceWindowMicro,\n entityMapping: Handlers.Helpers.EntityMappings): {\n summaries: ThirdPartySummary,\n entityByEvent: Map<Types.Events.Event, Handlers.Helpers.Entity>,\n} {\n const entityByEvent = new Map(entityMapping.entityByEvent);\n const eventsByEntity = new Map(entityMapping.eventsByEntity);\n\n // Consider events only in bounds.\n const entityByEventArr = Array.from(entityByEvent.entries());\n const filteredEntries = entityByEventArr.filter(([event]) => {\n return Helpers.Timing.eventIsInBounds(event, traceBounds);\n });\n const entityByEventFiltered = new Map(filteredEntries);\n\n // Consider events only in bounds.\n const eventsByEntityArr = Array.from(eventsByEntity.entries());\n const filtered = eventsByEntityArr.filter(([, events]) => {\n events.map(event => {\n return Helpers.Timing.eventIsInBounds(event, traceBounds);\n });\n return events.length > 0;\n });\n const eventsByEntityFiltered = new Map(filtered);\n\n const allEvents = Array.from(entityByEvent.keys());\n const summaries = getSummaryMapWithMapping(allEvents, entityByEventFiltered, eventsByEntityFiltered);\n\n return {summaries, entityByEvent: entityByEventFiltered};\n}\n"]}
|
|
@@ -4,6 +4,7 @@ import type { TraceFilter } from './TraceFilter.js';
|
|
|
4
4
|
export declare class Node {
|
|
5
5
|
totalTime: number;
|
|
6
6
|
selfTime: number;
|
|
7
|
+
transferSize: number;
|
|
7
8
|
id: string | symbol;
|
|
8
9
|
/** The first trace event encountered that necessitated the creation of this tree node. */
|
|
9
10
|
event: Types.Events.Event;
|
|
@@ -68,12 +69,14 @@ export declare class BottomUpRootNode extends Node {
|
|
|
68
69
|
readonly endTime: Types.Timing.Milli;
|
|
69
70
|
private eventGroupIdCallback;
|
|
70
71
|
totalTime: number;
|
|
71
|
-
|
|
72
|
+
private calculateTransferSize?;
|
|
73
|
+
constructor(events: Types.Events.Event[], { textFilter, filters, startTime, endTime, eventGroupIdCallback, calculateTransferSize, }: {
|
|
72
74
|
textFilter: TraceFilter;
|
|
73
75
|
filters: readonly TraceFilter[];
|
|
74
76
|
startTime: Types.Timing.Milli;
|
|
75
77
|
endTime: Types.Timing.Milli;
|
|
76
78
|
eventGroupIdCallback?: ((arg0: Types.Events.Event) => string) | null;
|
|
79
|
+
calculateTransferSize?: boolean;
|
|
77
80
|
});
|
|
78
81
|
hasChildren(): boolean;
|
|
79
82
|
filterChildren(children: ChildrenCache): ChildrenCache;
|
|
@@ -86,7 +89,7 @@ export declare class GroupNode extends Node {
|
|
|
86
89
|
isGroupNodeInternal: boolean;
|
|
87
90
|
events: Types.Events.Event[];
|
|
88
91
|
constructor(id: string, parent: BottomUpRootNode | TopDownRootNode, events: Types.Events.Event[]);
|
|
89
|
-
addChild(child: BottomUpNode, selfTime: number, totalTime: number): void;
|
|
92
|
+
addChild(child: BottomUpNode, selfTime: number, totalTime: number, transferSize: number): void;
|
|
90
93
|
hasChildren(): boolean;
|
|
91
94
|
children(): ChildrenCache;
|
|
92
95
|
}
|