@paulirish/trace_engine 0.0.61 → 0.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tmp/tsbuildinfo/analyze-trace.d.mts.map +1 -1
- package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
- package/analyze-inspector-issues.mjs +1 -1
- package/analyze-trace.mjs +1 -2
- package/core/platform/ArrayUtilities.d.ts +2 -0
- package/core/platform/ArrayUtilities.js +11 -1
- package/core/platform/ArrayUtilities.js.map +1 -1
- package/core/platform/HostRuntime.d.ts +4 -0
- package/core/platform/HostRuntime.js +25 -0
- package/core/platform/HostRuntime.js.map +1 -0
- package/core/platform/KeyboardUtilities.d.ts +6 -2
- package/core/platform/KeyboardUtilities.js.map +1 -1
- package/core/platform/StringUtilities.d.ts +2 -0
- package/core/platform/StringUtilities.js +64 -13
- package/core/platform/StringUtilities.js.map +1 -1
- package/core/platform/api/HostRuntime.d.ts +36 -0
- package/core/platform/api/HostRuntime.js +5 -0
- package/core/platform/api/HostRuntime.js.map +1 -0
- package/core/platform/api/api-tsconfig.json +43 -0
- package/core/platform/api/api.d.ts +2 -0
- package/core/platform/api/api.js +6 -0
- package/core/platform/api/api.js.map +1 -0
- package/core/platform/api/api_node_typecheck-tsconfig.json +48 -0
- package/core/platform/api/bundle-tsconfig.json +1 -0
- package/core/platform/api/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
- package/core/platform/browser/HostRuntime.d.ts +2 -0
- package/core/platform/browser/HostRuntime.js +64 -0
- package/core/platform/browser/HostRuntime.js.map +1 -0
- package/core/platform/browser/browser-tsconfig.json +48 -0
- package/core/platform/browser/browser.d.ts +2 -0
- package/core/platform/browser/browser.js +6 -0
- package/core/platform/browser/browser.js.map +1 -0
- package/core/platform/browser/bundle-tsconfig.json +1 -0
- package/core/platform/browser/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
- package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/core/platform/node/HostRuntime.d.ts +2 -0
- package/core/platform/node/HostRuntime.js +73 -0
- package/core/platform/node/HostRuntime.js.map +1 -0
- package/core/platform/node/bundle-tsconfig.json +1 -0
- package/core/platform/node/devtools_entrypoint-bundle-typescript-tsconfig.json +48 -0
- package/core/platform/node/node-tsconfig.json +52 -0
- package/core/platform/node/node.d.ts +2 -0
- package/core/platform/node/node.js +6 -0
- package/core/platform/node/node.js.map +1 -0
- package/core/platform/platform-tsconfig.json +17 -5
- package/core/platform/platform.d.ts +2 -2
- package/core/platform/platform.js +2 -2
- package/core/platform/platform.js.map +1 -1
- package/core/platform/platform_node_typecheck-tsconfig.json +74 -0
- package/generated/protocol.d.ts +1507 -583
- package/locales/af.json +74 -38
- package/locales/am.json +73 -37
- package/locales/ar.json +72 -36
- package/locales/as.json +74 -38
- package/locales/az.json +73 -37
- package/locales/be.json +72 -36
- package/locales/bg.json +72 -36
- package/locales/bn.json +74 -38
- package/locales/bs.json +72 -36
- package/locales/ca.json +72 -36
- package/locales/cs.json +72 -36
- package/locales/cy.json +73 -37
- package/locales/da.json +74 -38
- package/locales/de.json +72 -36
- package/locales/el.json +73 -37
- package/locales/en-GB.json +74 -38
- package/locales/en-US.json +86 -17
- package/locales/en-XL.json +86 -17
- package/locales/es-419.json +72 -36
- package/locales/es.json +73 -37
- package/locales/et.json +74 -38
- package/locales/eu.json +72 -36
- package/locales/fa.json +73 -37
- package/locales/fi.json +72 -36
- package/locales/fil.json +74 -38
- package/locales/fr-CA.json +72 -36
- package/locales/fr.json +162 -126
- package/locales/gl.json +73 -37
- package/locales/gu.json +73 -37
- package/locales/he.json +74 -38
- package/locales/hi.json +73 -37
- package/locales/hr.json +72 -36
- package/locales/hu.json +73 -37
- package/locales/hy.json +73 -37
- package/locales/id.json +74 -38
- package/locales/is.json +73 -37
- package/locales/it.json +72 -36
- package/locales/ja.json +72 -36
- package/locales/ka.json +73 -37
- package/locales/kk.json +72 -36
- package/locales/km.json +73 -37
- package/locales/kn.json +72 -36
- package/locales/ko.json +72 -36
- package/locales/ky.json +72 -36
- package/locales/lo.json +72 -36
- package/locales/lt.json +72 -36
- package/locales/lv.json +72 -36
- package/locales/mk.json +75 -39
- package/locales/ml.json +72 -36
- package/locales/mn.json +73 -37
- package/locales/mr.json +74 -38
- package/locales/ms.json +72 -36
- package/locales/my.json +72 -36
- package/locales/ne.json +73 -37
- package/locales/nl.json +73 -37
- package/locales/no.json +72 -36
- package/locales/or.json +72 -36
- package/locales/pa.json +72 -36
- package/locales/pl.json +72 -36
- package/locales/pt-PT.json +72 -36
- package/locales/pt.json +74 -38
- package/locales/ro.json +72 -36
- package/locales/ru.json +72 -36
- package/locales/si.json +72 -36
- package/locales/sk.json +72 -36
- package/locales/sl.json +72 -36
- package/locales/sq.json +72 -36
- package/locales/sr-Latn.json +73 -37
- package/locales/sr.json +73 -37
- package/locales/sv.json +75 -39
- package/locales/sw.json +74 -38
- package/locales/ta.json +73 -37
- package/locales/te.json +72 -36
- package/locales/th.json +73 -37
- package/locales/tr.json +72 -36
- package/locales/uk.json +72 -36
- package/locales/ur.json +72 -36
- package/locales/uz.json +73 -37
- package/locales/vi.json +74 -38
- package/locales/zh-HK.json +72 -36
- package/locales/zh-TW.json +74 -38
- package/locales/zh.json +75 -39
- package/locales/zu.json +73 -37
- package/models/cpu_profile/CPUProfileDataModel.d.ts +9 -0
- package/models/cpu_profile/CPUProfileDataModel.js +9 -7
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
- package/models/cpu_profile/ProfileTreeModel.d.ts +3 -2
- package/models/cpu_profile/ProfileTreeModel.js +6 -7
- package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
- package/models/cpu_profile/cpu_profile-tsconfig.json +4 -3
- package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/EntityMapper.d.ts +1 -0
- package/models/trace/EntityMapper.js +10 -0
- package/models/trace/EntityMapper.js.map +1 -1
- package/models/trace/EventsSerializer.js +10 -2
- package/models/trace/EventsSerializer.js.map +1 -1
- package/models/trace/LanternComputationData.d.ts +1 -1
- package/models/trace/LanternComputationData.js +3 -8
- package/models/trace/LanternComputationData.js.map +1 -1
- package/models/trace/ModelImpl.d.ts +1 -0
- package/models/trace/ModelImpl.js +9 -6
- package/models/trace/ModelImpl.js.map +1 -1
- package/models/trace/Processor.js +23 -23
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/Styles.js +13 -5
- package/models/trace/Styles.js.map +1 -1
- package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/extras/Initiators.d.ts +12 -0
- package/models/trace/extras/Initiators.js +47 -0
- package/models/trace/extras/Initiators.js.map +1 -0
- package/models/trace/extras/TraceTree.js +13 -5
- package/models/trace/extras/TraceTree.js.map +1 -1
- package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/extras/extras-tsconfig.json +11 -3
- package/models/trace/extras/extras.d.ts +0 -1
- package/models/trace/extras/extras.js +0 -1
- package/models/trace/extras/extras.js.map +1 -1
- package/models/trace/handlers/LargestImagePaintHandler.js +2 -2
- package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.js +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
- package/models/trace/handlers/MetaHandler.d.ts +12 -1
- package/models/trace/handlers/MetaHandler.js +10 -1
- package/models/trace/handlers/MetaHandler.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.d.ts +8 -1
- package/models/trace/handlers/NetworkRequestsHandler.js +22 -4
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/PageLoadMetricsHandler.d.ts +13 -3
- package/models/trace/handlers/PageLoadMetricsHandler.js +71 -27
- package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
- package/models/trace/handlers/SamplesHandler.js +59 -6
- package/models/trace/handlers/SamplesHandler.js.map +1 -1
- package/models/trace/handlers/ScriptsHandler.js +24 -0
- package/models/trace/handlers/ScriptsHandler.js.map +1 -1
- package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/handlers/handlers-tsconfig.json +13 -3
- package/models/trace/helpers/Network.js +1 -1
- package/models/trace/helpers/Network.js.map +1 -1
- package/models/trace/helpers/SamplesIntegrator.js +1 -8
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
- package/models/trace/helpers/Timing.d.ts +1 -1
- package/models/trace/helpers/Timing.js +9 -2
- package/models/trace/helpers/Timing.js.map +1 -1
- package/models/trace/helpers/Trace.d.ts +1 -0
- package/models/trace/helpers/Trace.js +12 -5
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/helpers/helpers-tsconfig.json +7 -3
- package/models/trace/insights/CharacterSet.d.ts +49 -0
- package/models/trace/insights/CharacterSet.js +132 -0
- package/models/trace/insights/CharacterSet.js.map +1 -0
- package/models/trace/insights/Common.d.ts +2 -2
- package/models/trace/insights/Common.js +1 -6
- package/models/trace/insights/Common.js.map +1 -1
- package/models/trace/insights/ForcedReflow.d.ts +1 -1
- package/models/trace/insights/ForcedReflow.js +1 -1
- package/models/trace/insights/ForcedReflow.js.map +1 -1
- package/models/trace/insights/LCPBreakdown.d.ts +1 -1
- package/models/trace/insights/LCPBreakdown.js +2 -2
- package/models/trace/insights/LCPBreakdown.js.map +1 -1
- package/models/trace/insights/LCPDiscovery.d.ts +7 -3
- package/models/trace/insights/LCPDiscovery.js +16 -10
- package/models/trace/insights/LCPDiscovery.js.map +1 -1
- package/models/trace/insights/Models.d.ts +1 -0
- package/models/trace/insights/Models.js +1 -0
- package/models/trace/insights/Models.js.map +1 -1
- package/models/trace/insights/NetworkDependencyTree.js +4 -3
- package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
- package/models/trace/insights/RenderBlocking.d.ts +2 -2
- package/models/trace/insights/RenderBlocking.js +6 -6
- package/models/trace/insights/RenderBlocking.js.map +1 -1
- package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/insights/insights-tsconfig.json +26 -3
- package/models/trace/insights/types.d.ts +15 -5
- package/models/trace/insights/types.js +1 -0
- package/models/trace/insights/types.js.map +1 -1
- package/models/trace/lantern/core/core-tsconfig.json +4 -3
- package/models/trace/lantern/core/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/graph/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/graph/graph-tsconfig.json +4 -3
- package/models/trace/lantern/lantern-tsconfig.json +4 -3
- package/models/trace/lantern/metrics/FirstContentfulPaint.js +6 -6
- package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +1 -1
- package/models/trace/lantern/metrics/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/metrics/metrics-tsconfig.json +4 -3
- package/models/trace/lantern/simulation/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/simulation/simulation-tsconfig.json +4 -3
- package/models/trace/lantern/types/Lantern.d.ts +7 -7
- package/models/trace/lantern/types/Lantern.js.map +1 -1
- package/models/trace/lantern/types/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/lantern/types/types-tsconfig.json +4 -3
- package/models/trace/trace-tsconfig.json +7 -3
- package/models/trace/types/Configuration.d.ts +1 -4
- package/models/trace/types/Configuration.js +0 -1
- package/models/trace/types/Configuration.js.map +1 -1
- package/models/trace/types/File.d.ts +8 -0
- package/models/trace/types/File.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +97 -15
- package/models/trace/types/TraceEvents.js +44 -11
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +4 -3
- package/models/trace/types/types-tsconfig.json +10 -3
- package/package.json +1 -1
- package/test/test-trace-engine.mjs +8 -9
- package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts +0 -4
- package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts.map +0 -1
- package/core/platform/DOMUtilities.d.ts +0 -16
- package/core/platform/DOMUtilities.js +0 -123
- package/core/platform/DOMUtilities.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SamplesHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/SamplesHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,IAAI,iBAAiB,GAAG,IAAI,GAAG,EAAmE,CAAC;AACnG,IAAI,WAAW,GAAG,IAAI,GAAG,EAA0D,CAAC;AAEpF,2DAA2D;AAC3D,6DAA6D;AAC7D,sEAAsE;AACtE,uEAAuE;AACvE,sEAAsE;AACtE,mDAAmD;AACnD,uEAAuE;AACvE,uEAAuE;AACvE,+BAA+B;AAC/B,IAAI,gBAAgB,GAAG,IAAI,GAAG,EAAyE,CAAC;AAExG,SAAS,mBAAmB,CAAC,YAA8C;IACzE,KAAK,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,gBAAgB,EAAE,CAAC;QACrD,KAAK,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAAC,IAAI,QAAQ,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC;YAC3C,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,IAAI,QAAQ,KAAK,SAAS,EAAE,CA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;AAqCD;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAwB,EAAE,KAAwC;IAC3G,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtE,MAAM,IAAI,GAAG,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,IAAI,EAAE,YAAY,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC;AACtC,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nlet profilesInProcess = new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, ProfileData>>();\nlet entryToNode = new Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>();\n\n// The profile head, containing its metadata like its start\n// time, comes in a \"Profile\" event. The sample data comes in\n// \"ProfileChunk\" events. We match these ProfileChunks with their head\n// using process and profile ids. However, in order to integrate sample\n// data with trace data, we need the thread id that owns each profile.\n// This thread id is extracted from the head event.\n// For this reason, we have a preprocessed data structure, where events\n// are matched by profile id, which we then finish processing to export\n// events matched by thread id.\nlet preprocessedData = new Map<Types.Events.ProcessID, Map<Types.Events.ProfileID, PreprocessedData>>();\n\nfunction parseCPUProfileData(parseOptions: Types.Configuration.ParseOptions): void {\n for (const [processId, profiles] of preprocessedData) {\n for (const [profileId, preProcessedData] of profiles) {\n const threadId = preProcessedData.threadId;\n if (!preProcessedData.rawProfile.nodes.length || threadId === undefined) {\n continue;\n }\n const indexStack: number[] = [];\n\n const profileModel = new CPUProfile.CPUProfileDataModel.CPUProfileDataModel(preProcessedData.rawProfile);\n const profileTree = Helpers.TreeHelpers.makeEmptyTraceEntryTree();\n profileTree.maxDepth = profileModel.maxDepth;\n\n const finalizedData: ProfileData = {\n rawProfile: preProcessedData.rawProfile,\n parsedProfile: profileModel,\n profileCalls: [],\n profileTree,\n profileId,\n };\n const dataByThread = Platform.MapUtilities.getWithDefault(profilesInProcess, processId, () => new Map());\n dataByThread.set(threadId, finalizedData);\n\n // Only need to build pure JS ProfileCalls if we're parsing a CPU Profile, otherwise SamplesIntegrator does the work.\n if (parseOptions.isCPUProfile) {\n buildProfileCallsForCPUProfile();\n }\n\n function buildProfileCallsForCPUProfile(): void {\n profileModel.forEachFrame(openFrameCallback, closeFrameCallback);\n\n function openFrameCallback(\n depth: number, node: CPUProfile.ProfileTreeModel.ProfileNode, sampleIndex: number,\n timeStampMilliseconds: number): void {\n if (threadId === undefined) {\n return;\n }\n const ts = Helpers.Timing.milliToMicro(Types.Timing.Milli(timeStampMilliseconds));\n const nodeId = node.id as Helpers.TreeHelpers.TraceEntryNodeId;\n\n const profileCall = Helpers.Trace.makeProfileCall(node, profileId, sampleIndex, ts, processId, threadId);\n finalizedData.profileCalls.push(profileCall);\n indexStack.push(finalizedData.profileCalls.length - 1);\n const traceEntryNode = Helpers.TreeHelpers.makeEmptyTraceEntryNode(profileCall, nodeId);\n entryToNode.set(profileCall, traceEntryNode);\n traceEntryNode.depth = depth;\n if (indexStack.length === 1) {\n // First call in the stack is a root call.\n finalizedData.profileTree?.roots.add(traceEntryNode);\n }\n }\n function closeFrameCallback(\n _depth: number, _node: CPUProfile.ProfileTreeModel.ProfileNode, _sampleIndex: number,\n _timeStampMillis: number, durMs: number, selfTimeMs: number): void {\n const profileCallIndex = indexStack.pop();\n const profileCall = profileCallIndex !== undefined && finalizedData.profileCalls[profileCallIndex];\n if (!profileCall) {\n return;\n }\n const {callFrame, ts, pid, tid} = profileCall;\n const traceEntryNode = entryToNode.get(profileCall);\n if (callFrame === undefined || ts === undefined || pid === undefined || profileId === undefined ||\n tid === undefined || traceEntryNode === undefined) {\n return;\n }\n const dur = Helpers.Timing.milliToMicro(Types.Timing.Milli(durMs));\n const selfTime = Helpers.Timing.milliToMicro(Types.Timing.Milli(selfTimeMs));\n profileCall.dur = dur;\n traceEntryNode.selfTime = selfTime;\n\n const parentIndex = indexStack.at(-1);\n const parent = parentIndex !== undefined && finalizedData.profileCalls.at(parentIndex);\n const parentNode = parent && entryToNode.get(parent);\n if (!parentNode) {\n return;\n }\n traceEntryNode.parent = parentNode;\n parentNode.children.push(traceEntryNode);\n }\n }\n }\n }\n}\n\nexport function reset(): void {\n preprocessedData = new Map();\n profilesInProcess = new Map();\n entryToNode = new Map();\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n /**\n * A fake trace event created to support CDP.Profiler.Profiles in the\n * trace engine.\n */\n if (Types.Events.isSyntheticCpuProfile(event)) {\n // At the moment we are attaching to a single node target so we\n // should only get a single CPU profile. The values of the process\n // id and thread id are not really important, so we use the data\n // in the fake event. Should multi-thread CPU profiling be supported\n // we could use these fields in the event to pass thread info.\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n profileData.rawProfile = event.args.data.cpuProfile;\n profileData.threadId = event.tid;\n return;\n }\n\n if (Types.Events.isProfile(event)) {\n // Do not use event.args.data.startTime as it is in CLOCK_MONOTONIC domain,\n // but use profileEvent.ts which has been translated to Perfetto's clock\n // domain. Also convert from ms to us.\n // Note: events are collected on a different thread than what's sampled.\n // The correct process and thread ids are specified by the profile.\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n profileData.rawProfile.startTime = event.ts;\n profileData.threadId = event.tid;\n return;\n }\n if (Types.Events.isProfileChunk(event)) {\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n const cdpProfile = profileData.rawProfile;\n const nodesAndSamples: Types.Events.PartialProfile = event.args?.data?.cpuProfile || {samples: []};\n const samples = nodesAndSamples?.samples || [];\n const traceIds = event.args?.data?.cpuProfile?.trace_ids;\n for (const n of nodesAndSamples?.nodes || []) {\n const lineNumber = typeof n.callFrame.lineNumber === 'undefined' ? -1 : n.callFrame.lineNumber;\n const columnNumber = typeof n.callFrame.columnNumber === 'undefined' ? -1 : n.callFrame.columnNumber;\n\n const scriptId = String(n.callFrame.scriptId) as Protocol.Runtime.ScriptId;\n const url = n.callFrame.url || '';\n const node = {\n ...n,\n callFrame: {\n ...n.callFrame,\n url,\n lineNumber,\n columnNumber,\n scriptId,\n },\n };\n cdpProfile.nodes.push(node);\n }\n\n const timeDeltas = event.args.data?.timeDeltas || [];\n const lines = event.args.data?.lines || Array(samples.length).fill(0);\n cdpProfile.samples?.push(...samples);\n cdpProfile.timeDeltas?.push(...timeDeltas);\n cdpProfile.lines?.push(...lines);\n\n if (traceIds) {\n cdpProfile.traceIds ??= {};\n for (const key in traceIds) {\n cdpProfile.traceIds[key] = traceIds[key];\n }\n }\n\n if (cdpProfile.samples && cdpProfile.timeDeltas && cdpProfile.samples.length !== cdpProfile.timeDeltas.length) {\n console.error('Failed to parse CPU profile.');\n return;\n }\n if (!cdpProfile.endTime && cdpProfile.timeDeltas) {\n const timeDeltas: number[] = cdpProfile.timeDeltas;\n cdpProfile.endTime = timeDeltas.reduce((x, y) => x + y, cdpProfile.startTime);\n }\n return;\n }\n}\n\nexport async function finalize(parseOptions: Types.Configuration.ParseOptions = {}): Promise<void> {\n parseCPUProfileData(parseOptions);\n}\n\nexport function data(): SamplesHandlerData {\n return {\n profilesInProcess,\n entryToNode,\n };\n}\n\nfunction getOrCreatePreProcessedData(\n processId: Types.Events.ProcessID, profileId: Types.Events.ProfileID): PreprocessedData {\n const profileById = Platform.MapUtilities.getWithDefault(preprocessedData, processId, () => new Map());\n return Platform.MapUtilities.getWithDefault<Types.Events.ProfileID, PreprocessedData>(\n profileById, profileId, () => ({\n rawProfile: {\n startTime: 0,\n endTime: 0,\n nodes: [],\n samples: [],\n timeDeltas: [],\n lines: [],\n },\n profileId,\n }));\n}\n\nexport interface SamplesHandlerData {\n profilesInProcess: typeof profilesInProcess;\n entryToNode: typeof entryToNode;\n}\n\nexport interface ProfileData {\n profileId: Types.Events.ProfileID;\n rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;\n parsedProfile: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Contains the calls built from the CPU profile samples.\n * Note: This doesn't contain real trace events coming from the\n * browser, only calls synthetically typed as trace events for\n * compatibility, as such it only makes sense to use them in pure CPU\n * profiles.\n *\n * If you need the profile calls from a CPU profile obtained from a\n * web trace, use the data exported by the RendererHandler instead.\n */\n profileCalls: Types.Events.SyntheticProfileCall[];\n /**\n * Contains the call tree built from the CPU profile samples.\n * Similar to the profileCalls field, this tree does not contain nor\n * take into account trace events, as such it only makes sense to use\n * them in pure CPU profiles.\n */\n profileTree?: Helpers.TreeHelpers.TraceEntryTree;\n}\n\ninterface PreprocessedData {\n rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;\n profileId: Types.Events.ProfileID;\n threadId?: Types.Events.ThreadID;\n}\n\n/**\n * Returns the name of a function for a given synthetic profile call.\n * We first look to find the ProfileNode representing this call, and use its\n * function name. This is preferred (and should always exist) because if we\n * resolve sourcemaps, we will update this name. If that name is not present,\n * we fall back to the function name that was in the callframe that we got\n * when parsing the profile's trace data.\n */\nexport function getProfileCallFunctionName(data: SamplesHandlerData, entry: Types.Events.SyntheticProfileCall): string {\n const profile = data.profilesInProcess.get(entry.pid)?.get(entry.tid);\n const node = profile?.parsedProfile.nodeById(entry.nodeId);\n if (node?.functionName) {\n return node.functionName;\n }\n return entry.callFrame.functionName;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SamplesHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/SamplesHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KA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,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;SACZ;QACD,SAAS;KACV,CAAC,CAAC,CAAC;AAClC,CAAC;AAsCD;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAwB,EAAE,KAAwC;IAC3G,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtE,MAAM,IAAI,GAAG,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,IAAI,EAAE,YAAY,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC;AACtC,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nlet profilesInProcess = new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, ProfileData>>();\nlet entryToNode = new Map<Types.Events.Event, Helpers.TreeHelpers.TraceEntryNode>();\n\n// The profile head, containing its metadata like its start\n// time, comes in a \"Profile\" event. The sample data comes in\n// \"ProfileChunk\" events. We match these ProfileChunks with their head\n// using process and profile ids. However, in order to integrate sample\n// data with trace data, we need the thread id that owns each profile.\n// This thread id is extracted from the head event.\n// For this reason, we have a preprocessed data structure, where events\n// are matched by profile id, which we then finish processing to export\n// events matched by thread id.\nlet preprocessedData = new Map<Types.Events.ProcessID, Map<Types.Events.ProfileID, PreprocessedData>>();\n\n/**\n * Profile source selection priority when multiple profiles exist for the same thread.\n *\n * Profile sources and their typical scenarios:\n * - 'Internal': Browser-initiated profiling performance panel traces.\n * This is the profiling mechanism when users click \"Record\" in the Devtools UI.\n * - 'Inspector': User-initiated via console.profile()/profileEnd() calls.\n * Represents explicit developer intent to profile specific code.\n * - 'SelfProfiling': Page-initiated via JS Self-Profiling API.\n * Lower signal vs the two above; treated as fallback.\n *\n * Selection strategy:\n * - CPU Profile mode: Prefer 'Inspector' (explicit user request).\n * - Performance trace: Prefer 'Internal' (integrated timeline context), then 'Inspector'.\n * - Sources not in the priority list (including 'SelfProfiling') act as fallbacks.\n * When no priority source matches, the first candidate profile is selected.\n */\nconst PROFILE_SOURCES_BY_PRIORITY = {\n cpuProfile: ['Inspector'] as Types.Events.ProfileSource[],\n performanceTrace: ['Internal', 'Inspector'] as Types.Events.ProfileSource[],\n};\n\nfunction parseCPUProfileData(parseOptions: Types.Configuration.ParseOptions): void {\n const priorityList =\n parseOptions.isCPUProfile ? PROFILE_SOURCES_BY_PRIORITY.cpuProfile : PROFILE_SOURCES_BY_PRIORITY.performanceTrace;\n\n for (const [processId, profiles] of preprocessedData) {\n const profilesByThread =\n new Map<Types.Events.ThreadID, Array<{id: Types.Events.ProfileID, data: PreprocessedData}>>();\n for (const [profileId, preProcessedData] of profiles) {\n const threadId = preProcessedData.threadId;\n if (threadId === undefined) {\n continue;\n }\n const listForThread = Platform.MapUtilities.getWithDefault(profilesByThread, threadId, () => []);\n listForThread.push({id: profileId, data: preProcessedData});\n }\n\n for (const [threadId, candidates] of profilesByThread) {\n if (!candidates.length) {\n continue;\n }\n let chosen = candidates[0];\n for (const source of priorityList) {\n const match = candidates.find(p => p.data.source === source);\n if (match) {\n chosen = match;\n break;\n }\n }\n const chosenData = chosen.data;\n if (!chosenData.rawProfile.nodes.length) {\n continue;\n }\n const indexStack: number[] = [];\n\n const profileModel = new CPUProfile.CPUProfileDataModel.CPUProfileDataModel(chosenData.rawProfile);\n const profileTree = Helpers.TreeHelpers.makeEmptyTraceEntryTree();\n profileTree.maxDepth = profileModel.maxDepth;\n\n const selectedProfileId = chosen.id;\n const finalizedData: ProfileData = {\n rawProfile: chosenData.rawProfile,\n parsedProfile: profileModel,\n profileCalls: [],\n profileTree,\n profileId: selectedProfileId,\n };\n const dataByThread = Platform.MapUtilities.getWithDefault(profilesInProcess, processId, () => new Map());\n dataByThread.set(threadId, finalizedData);\n\n // Only need to build pure JS ProfileCalls if we're parsing a CPU Profile, otherwise SamplesIntegrator does the work.\n if (parseOptions.isCPUProfile) {\n buildProfileCallsForCPUProfile();\n }\n\n function buildProfileCallsForCPUProfile(): void {\n profileModel.forEachFrame(openFrameCallback, closeFrameCallback);\n\n function openFrameCallback(\n depth: number, node: CPUProfile.ProfileTreeModel.ProfileNode, sampleIndex: number,\n timeStampMilliseconds: number): void {\n if (threadId === undefined) {\n return;\n }\n const ts = Helpers.Timing.milliToMicro(Types.Timing.Milli(timeStampMilliseconds));\n const nodeId = node.id as Helpers.TreeHelpers.TraceEntryNodeId;\n\n const profileCall =\n Helpers.Trace.makeProfileCall(node, selectedProfileId, sampleIndex, ts, processId, threadId);\n finalizedData.profileCalls.push(profileCall);\n indexStack.push(finalizedData.profileCalls.length - 1);\n const traceEntryNode = Helpers.TreeHelpers.makeEmptyTraceEntryNode(profileCall, nodeId);\n entryToNode.set(profileCall, traceEntryNode);\n traceEntryNode.depth = depth;\n if (indexStack.length === 1) {\n // First call in the stack is a root call.\n finalizedData.profileTree?.roots.add(traceEntryNode);\n }\n }\n function closeFrameCallback(\n _depth: number, _node: CPUProfile.ProfileTreeModel.ProfileNode, _sampleIndex: number,\n _timeStampMillis: number, durMs: number, selfTimeMs: number): void {\n const profileCallIndex = indexStack.pop();\n const profileCall = profileCallIndex !== undefined && finalizedData.profileCalls[profileCallIndex];\n if (!profileCall) {\n return;\n }\n const {callFrame, ts, pid, tid} = profileCall;\n const traceEntryNode = entryToNode.get(profileCall);\n if (callFrame === undefined || ts === undefined || pid === undefined || selectedProfileId === undefined ||\n tid === undefined || traceEntryNode === undefined) {\n return;\n }\n const dur = Helpers.Timing.milliToMicro(Types.Timing.Milli(durMs));\n const selfTime = Helpers.Timing.milliToMicro(Types.Timing.Milli(selfTimeMs));\n profileCall.dur = dur;\n traceEntryNode.selfTime = selfTime;\n\n const parentIndex = indexStack.at(-1);\n const parent = parentIndex !== undefined && finalizedData.profileCalls.at(parentIndex);\n const parentNode = parent && entryToNode.get(parent);\n if (!parentNode) {\n return;\n }\n traceEntryNode.parent = parentNode;\n parentNode.children.push(traceEntryNode);\n }\n }\n }\n }\n}\n\nexport function reset(): void {\n preprocessedData = new Map();\n profilesInProcess = new Map();\n entryToNode = new Map();\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n /**\n * A fake trace event created to support CDP.Profiler.Profiles in the\n * trace engine.\n */\n if (Types.Events.isSyntheticCpuProfile(event)) {\n // At the moment we are attaching to a single node target so we\n // should only get a single CPU profile. The values of the process\n // id and thread id are not really important, so we use the data\n // in the fake event. Should multi-thread CPU profiling be supported\n // we could use these fields in the event to pass thread info.\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n profileData.rawProfile = event.args.data.cpuProfile;\n profileData.threadId = event.tid;\n return;\n }\n\n if (Types.Events.isProfile(event)) {\n // Do not use event.args.data.startTime as it is in CLOCK_MONOTONIC domain,\n // but use profileEvent.ts which has been translated to Perfetto's clock\n // domain. Also convert from ms to us.\n // Note: events are collected on a different thread than what's sampled.\n // The correct process and thread ids are specified by the profile.\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n profileData.rawProfile.startTime = event.ts;\n profileData.threadId = event.tid;\n assignProfileSourceIfKnown(profileData, event.args?.data?.source);\n return;\n }\n if (Types.Events.isProfileChunk(event)) {\n const profileData = getOrCreatePreProcessedData(event.pid, event.id);\n const cdpProfile = profileData.rawProfile;\n const nodesAndSamples: Types.Events.PartialProfile = event.args?.data?.cpuProfile || {samples: []};\n const samples = nodesAndSamples?.samples || [];\n const traceIds = event.args?.data?.cpuProfile?.trace_ids;\n for (const n of nodesAndSamples?.nodes || []) {\n const lineNumber = typeof n.callFrame.lineNumber === 'undefined' ? -1 : n.callFrame.lineNumber;\n const columnNumber = typeof n.callFrame.columnNumber === 'undefined' ? -1 : n.callFrame.columnNumber;\n\n const scriptId = String(n.callFrame.scriptId) as Protocol.Runtime.ScriptId;\n const url = n.callFrame.url || '';\n const node = {\n ...n,\n callFrame: {\n ...n.callFrame,\n url,\n lineNumber,\n columnNumber,\n scriptId,\n },\n };\n cdpProfile.nodes.push(node);\n }\n\n const timeDeltas = event.args.data?.timeDeltas || [];\n const lines = event.args.data?.lines || Array(samples.length).fill(0);\n const columns = event.args.data?.columns || Array(samples.length).fill(0);\n cdpProfile.samples?.push(...samples);\n cdpProfile.timeDeltas?.push(...timeDeltas);\n cdpProfile.lines?.push(...lines);\n cdpProfile.columns?.push(...columns);\n\n if (traceIds) {\n cdpProfile.traceIds ??= {};\n for (const key in traceIds) {\n cdpProfile.traceIds[key] = traceIds[key];\n }\n }\n\n if (cdpProfile.samples && cdpProfile.timeDeltas && cdpProfile.samples.length !== cdpProfile.timeDeltas.length) {\n console.error('Failed to parse CPU profile.');\n return;\n }\n if (!cdpProfile.endTime && cdpProfile.timeDeltas) {\n const timeDeltas: number[] = cdpProfile.timeDeltas;\n cdpProfile.endTime = timeDeltas.reduce((x, y) => x + y, cdpProfile.startTime);\n }\n assignProfileSourceIfKnown(profileData, event.args?.data?.source);\n return;\n }\n}\n\nexport async function finalize(parseOptions: Types.Configuration.ParseOptions = {}): Promise<void> {\n parseCPUProfileData(parseOptions);\n}\n\nfunction assignProfileSourceIfKnown(profileData: PreprocessedData, source: unknown): void {\n if (Types.Events.VALID_PROFILE_SOURCES.includes(source as Types.Events.ProfileSource)) {\n profileData.source = source as Types.Events.ProfileSource;\n }\n}\n\nexport function data(): SamplesHandlerData {\n return {\n profilesInProcess,\n entryToNode,\n };\n}\n\nfunction getOrCreatePreProcessedData(\n processId: Types.Events.ProcessID, profileId: Types.Events.ProfileID): PreprocessedData {\n const profileById = Platform.MapUtilities.getWithDefault(preprocessedData, processId, () => new Map());\n return Platform.MapUtilities.getWithDefault<Types.Events.ProfileID, PreprocessedData>(\n profileById, profileId, () => ({\n rawProfile: {\n startTime: 0,\n endTime: 0,\n nodes: [],\n samples: [],\n timeDeltas: [],\n lines: [],\n columns: [],\n },\n profileId,\n }));\n}\n\nexport interface SamplesHandlerData {\n profilesInProcess: typeof profilesInProcess;\n entryToNode: typeof entryToNode;\n}\n\nexport interface ProfileData {\n profileId: Types.Events.ProfileID;\n rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;\n parsedProfile: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Contains the calls built from the CPU profile samples.\n * Note: This doesn't contain real trace events coming from the\n * browser, only calls synthetically typed as trace events for\n * compatibility, as such it only makes sense to use them in pure CPU\n * profiles.\n *\n * If you need the profile calls from a CPU profile obtained from a\n * web trace, use the data exported by the RendererHandler instead.\n */\n profileCalls: Types.Events.SyntheticProfileCall[];\n /**\n * Contains the call tree built from the CPU profile samples.\n * Similar to the profileCalls field, this tree does not contain nor\n * take into account trace events, as such it only makes sense to use\n * them in pure CPU profiles.\n */\n profileTree?: Helpers.TreeHelpers.TraceEntryTree;\n}\n\ninterface PreprocessedData {\n rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;\n profileId: Types.Events.ProfileID;\n threadId?: Types.Events.ThreadID;\n source?: Types.Events.ProfileSource;\n}\n\n/**\n * Returns the name of a function for a given synthetic profile call.\n * We first look to find the ProfileNode representing this call, and use its\n * function name. This is preferred (and should always exist) because if we\n * resolve sourcemaps, we will update this name. If that name is not present,\n * we fall back to the function name that was in the callframe that we got\n * when parsing the profile's trace data.\n */\nexport function getProfileCallFunctionName(data: SamplesHandlerData, entry: Types.Events.SyntheticProfileCall): string {\n const profile = data.profilesInProcess.get(entry.pid)?.get(entry.tid);\n const node = profile?.parsedProfile.nodeById(entry.nodeId);\n if (node?.functionName) {\n return node.functionName;\n }\n return entry.callFrame.functionName;\n}\n"]}
|
|
@@ -16,11 +16,13 @@ function completeURL(base, url) {
|
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
let scriptById = new Map();
|
|
19
|
+
let frameIdByIsolate = new Map();
|
|
19
20
|
export function deps() {
|
|
20
21
|
return ['Meta', 'NetworkRequests'];
|
|
21
22
|
}
|
|
22
23
|
export function reset() {
|
|
23
24
|
scriptById = new Map();
|
|
25
|
+
frameIdByIsolate = new Map();
|
|
24
26
|
}
|
|
25
27
|
export function handleEvent(event) {
|
|
26
28
|
const getOrMakeScript = (isolate, scriptIdAsNumber) => {
|
|
@@ -38,6 +40,9 @@ export function handleEvent(event) {
|
|
|
38
40
|
if (Types.Events.isRundownScript(event)) {
|
|
39
41
|
const { isolate, scriptId, url, sourceUrl, sourceMapUrl, sourceMapUrlElided } = event.args.data;
|
|
40
42
|
const script = getOrMakeScript(isolate, scriptId);
|
|
43
|
+
if (!script.frame) {
|
|
44
|
+
script.frame = frameIdByIsolate.get(String(isolate)) ?? '';
|
|
45
|
+
}
|
|
41
46
|
script.url = url;
|
|
42
47
|
script.ts = event.ts;
|
|
43
48
|
if (sourceUrl) {
|
|
@@ -68,6 +73,25 @@ export function handleEvent(event) {
|
|
|
68
73
|
script.content = (script.content ?? '') + sourceText;
|
|
69
74
|
return;
|
|
70
75
|
}
|
|
76
|
+
// Setup frameIdByIsolate, which is used only in the case that we are missing
|
|
77
|
+
// rundown events for a script. We won't get a frame association from the rundown
|
|
78
|
+
// events if the recording started only after the script was first compiled. In
|
|
79
|
+
// that scenario, derive the frame via the isolate / FunctionCall events.
|
|
80
|
+
// TODO: ideally, we put the frame on ScriptCatchup event. So much easier. This approach has some
|
|
81
|
+
// issues.
|
|
82
|
+
if (Types.Events.isFunctionCall(event) && event.args.data?.isolate && event.args.data.frame) {
|
|
83
|
+
const { isolate, frame } = event.args.data;
|
|
84
|
+
const existingValue = frameIdByIsolate.get(isolate);
|
|
85
|
+
if (existingValue !== frame) {
|
|
86
|
+
frameIdByIsolate.set(isolate, frame);
|
|
87
|
+
// Update the scripts we discovered but without knowing their frame.
|
|
88
|
+
for (const script of scriptById.values()) {
|
|
89
|
+
if (!script.frame && script.isolate === isolate) {
|
|
90
|
+
script.frame = frame;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
71
95
|
}
|
|
72
96
|
function findFrame(meta, frameId) {
|
|
73
97
|
for (const frames of meta.frameByProcessId?.values()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/ScriptsHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAG/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAuB,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAC,IAAI,IAAI,0BAA0B,EAAC,MAAM,6BAA6B,CAAC;AAG/E,SAAS,WAAW,CAAC,IAAY,EAAE,GAAW;IAC5C,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACrH,OAAO,GAAsC,CAAC;IAChD,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAuC,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,OAAO,IAAI,CAAC;AACd,CAAC;AAiCD,IAAI,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE3C,MAAM,UAAU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Y,EAAE,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QACrC,CAAC;QAED,MAAM,MAAM,GAA+C;YACzD,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,MAAM,CAAC,GAAsC;YACxD,SAAS,EAAE,SAA4C;YACvD,YAAY,EAAE,YAAY,IAAI,EAAqC;YACnE,KAAK,EAAE,MAAM,CAAC,KAA8B;YAC5C,kBAAkB,EAAE,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC;SAC5D,CAAC;QACF,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAChE,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YAC9B,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport type * as SDK from '../../../core/sdk/sdk.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport * as Types from '../types/types.js';\n\nimport {data as metaHandlerData, type MetaHandlerData} from './MetaHandler.js';\nimport {data as networkRequestsHandlerData} from './NetworkRequestsHandler.js';\nimport type {FinalizeOptions, HandlerName} from './types.js';\n\nfunction completeURL(base: string, url: string): Platform.DevToolsPath.UrlString|null {\n if (url.startsWith('data:') || url.startsWith('blob:') || url.startsWith('javascript:') || url.startsWith('mailto:')) {\n return url as Platform.DevToolsPath.UrlString;\n }\n\n try {\n return new URL(url, base).href as Platform.DevToolsPath.UrlString;\n } catch {}\n\n return null;\n}\n\nexport interface ScriptsData {\n /** Note: this is only populated when the \"Enhanced Traces\" feature is enabled. */\n scripts: Script[];\n}\n\nexport interface Script {\n isolate: string;\n scriptId: Protocol.Runtime.ScriptId;\n frame: string;\n ts: Types.Timing.Micro;\n inline: boolean;\n url?: string;\n sourceUrl?: string;\n content?: string;\n /**\n * Note: this is the literal text given as the sourceMappingURL value. It has not been resolved relative to the script url.\n * Since M138, data urls are never set here.\n */\n sourceMapUrl?: string;\n /** If true, the source map url was a data URL, so it got removed from the trace event. */\n sourceMapUrlElided?: boolean;\n sourceMap?: SDK.SourceMap.SourceMap;\n request?: Types.Events.SyntheticNetworkRequest;\n /** Lazily generated - use getScriptGeneratedSizes to access. */\n sizes?: GeneratedFileSizes;\n}\n\ntype GeneratedFileSizes = {\n errorMessage: string,\n}|{files: Record<string, number>, unmappedBytes: number, totalBytes: number};\n\nlet scriptById = new Map<string, Script>();\n\nexport function deps(): HandlerName[] {\n return ['Meta', 'NetworkRequests'];\n}\n\nexport function reset(): void {\n scriptById = new Map();\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n const getOrMakeScript = (isolate: string|number, scriptIdAsNumber: number): Script => {\n const scriptId = String(scriptIdAsNumber) as Protocol.Runtime.ScriptId;\n const key = `${isolate}.${scriptId}`;\n return Platform.MapUtilities.getWithDefault(\n scriptById, key, () => ({isolate, scriptId, frame: '', ts: event.ts} as Script));\n };\n\n if (Types.Events.isRundownScriptCompiled(event) && event.args.data) {\n const {isolate, scriptId, frame} = event.args.data;\n const script = getOrMakeScript(isolate, scriptId);\n script.frame = frame;\n script.ts = event.ts;\n\n return;\n }\n\n if (Types.Events.isRundownScript(event)) {\n const {isolate, scriptId, url, sourceUrl, sourceMapUrl, sourceMapUrlElided} = event.args.data;\n const script = getOrMakeScript(isolate, scriptId);\n script.url = url;\n script.ts = event.ts;\n if (sourceUrl) {\n script.sourceUrl = sourceUrl;\n }\n\n // Older traces may have data source map urls. Those can be very large, so a change\n // was made to elide them from the trace.\n // If elided, a fresh trace will fetch the source map from the Script model\n // (see TimelinePanel getExistingSourceMap). If not fresh, the source map is resolved\n // instead in this handler via `findCachedRawSourceMap`.\n if (sourceMapUrlElided) {\n script.sourceMapUrlElided = true;\n } else if (sourceMapUrl) {\n script.sourceMapUrl = sourceMapUrl;\n }\n return;\n }\n\n if (Types.Events.isRundownScriptSource(event)) {\n const {isolate, scriptId, sourceText} = event.args.data;\n const script = getOrMakeScript(isolate, scriptId);\n script.content = sourceText;\n return;\n }\n\n if (Types.Events.isRundownScriptSourceLarge(event)) {\n const {isolate, scriptId, sourceText} = event.args.data;\n const script = getOrMakeScript(isolate, scriptId);\n script.content = (script.content ?? '') + sourceText;\n return;\n }\n}\n\nfunction findFrame(meta: MetaHandlerData, frameId: string): Types.Events.TraceFrame|null {\n for (const frames of meta.frameByProcessId?.values()) {\n const frame = frames.get(frameId);\n if (frame) {\n return frame;\n }\n }\n\n return null;\n}\n\nfunction findNetworkRequest(networkRequests: Types.Events.SyntheticNetworkRequest[], script: Script):\n Types.Events.SyntheticNetworkRequest|null {\n if (!script.url) {\n return null;\n }\n\n return networkRequests.find(request => request.args.data.url === script.url) ?? null;\n}\n\nfunction computeMappingEndColumns(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 a value in this map.\n return result;\n}\n\n/**\n * Using a script's contents and source map, attribute every generated byte to an authored source file.\n */\nfunction computeGeneratedFileSizes(script: 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 mappingEndCols = computeMappingEndColumns(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 = mappingEndCols.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\nexport function getScriptGeneratedSizes(script: Script): GeneratedFileSizes|null {\n if (script.sourceMap && !script.sizes) {\n script.sizes = computeGeneratedFileSizes(script);\n }\n\n return script.sizes ?? null;\n}\n\nfunction findCachedRawSourceMap(script: Script, options: Types.Configuration.ParseOptions): SDK.SourceMap.SourceMapV3|\n undefined {\n if (options.isFreshRecording || !options.metadata?.sourceMaps) {\n // Exit if this is not a loaded trace w/ source maps in the metadata.\n return;\n }\n\n // For elided data url source maps, search the metadata source maps by script url.\n if (script.sourceMapUrlElided) {\n if (!script.url) {\n return;\n }\n\n const cachedSourceMap = options.metadata.sourceMaps.find(m => m.url === script.url);\n if (cachedSourceMap) {\n return cachedSourceMap.sourceMap;\n }\n\n return;\n }\n\n if (!script.sourceMapUrl) {\n return;\n }\n\n // Otherwise, search by source map url.\n // Note: early enhanced traces may have this field set for data urls. Ignore those,\n // as they were never stored in metadata sourcemap.\n const isDataUrl = script.sourceMapUrl.startsWith('data:');\n if (!isDataUrl) {\n const cachedSourceMap = options.metadata.sourceMaps.find(m => m.sourceMapUrl === script.sourceMapUrl);\n if (cachedSourceMap) {\n return cachedSourceMap.sourceMap;\n }\n }\n\n return;\n}\n\nexport async function finalize(options: FinalizeOptions): Promise<void> {\n const meta = metaHandlerData();\n const networkRequests = [...networkRequestsHandlerData().byId.values()];\n\n const documentUrls = new Set<string>();\n for (const frames of meta.frameByProcessId.values()) {\n for (const frame of frames.values()) {\n documentUrls.add(frame.url);\n }\n }\n\n for (const script of scriptById.values()) {\n script.request = findNetworkRequest(networkRequests, script) ?? undefined;\n script.inline = !!script.url && documentUrls.has(script.url);\n }\n\n if (!options.resolveSourceMap) {\n return;\n }\n\n const promises = [];\n for (const script of scriptById.values()) {\n // No frame or url means the script came from somewhere we don't care about.\n // Note: scripts from inline <SCRIPT> elements use the url of the HTML document,\n // so aren't ignored.\n if (!script.frame || !script.url || (!script.sourceMapUrl && !script.sourceMapUrlElided)) {\n continue;\n }\n\n const frameUrl = findFrame(meta, script.frame)?.url as Platform.DevToolsPath.UrlString | undefined;\n if (!frameUrl) {\n continue;\n }\n\n // If there is a `sourceURL` magic comment, resolve the compiledUrl against the frame url.\n // example: `// #sourceURL=foo.js` for target frame https://www.example.com/home -> https://www.example.com/home/foo.js\n let sourceUrl = script.url;\n if (script.sourceUrl) {\n sourceUrl = completeURL(frameUrl, script.sourceUrl) ?? script.sourceUrl;\n }\n\n let sourceMapUrl;\n if (script.sourceMapUrl) {\n // Resolve the source map url. The value given by v8 may be relative, so resolve it here.\n // This process should match the one in `SourceMapManager.attachSourceMap`.\n sourceMapUrl =\n completeURL(sourceUrl as Platform.DevToolsPath.UrlString, script.sourceMapUrl);\n if (!sourceMapUrl) {\n continue;\n }\n\n script.sourceMapUrl = sourceMapUrl;\n }\n\n const params: Types.Configuration.ResolveSourceMapParams = {\n scriptId: script.scriptId,\n scriptUrl: script.url as Platform.DevToolsPath.UrlString,\n sourceUrl: sourceUrl as Platform.DevToolsPath.UrlString,\n sourceMapUrl: sourceMapUrl ?? '' as Platform.DevToolsPath.UrlString,\n frame: script.frame as Protocol.Page.FrameId,\n cachedRawSourceMap: findCachedRawSourceMap(script, options),\n };\n const promise = options.resolveSourceMap(params).then(sourceMap => {\n if (sourceMap) {\n script.sourceMap = sourceMap;\n }\n });\n promises.push(promise.catch(e => {\n console.error('Uncaught error when resolving source map', params, e);\n }));\n }\n await Promise.all(promises);\n}\n\nexport function data(): ScriptsData {\n return {\n scripts: [...scriptById.values()],\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ScriptsHandler.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/handlers/ScriptsHandler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAG/D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,IAAI,IAAI,eAAe,EAAuB,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAC,IAAI,IAAI,0BAA0B,EAAC,MAAM,6BAA6B,CAAC;AAG/E,SAAS,WAAW,CAAC,IAAY,EAAE,GAAW;IAC5C,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC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,EAAE,CAAC;YACxB,yFAAyF;YACzF,2EAA2E;YAC3E,YAAY;gBACR,WAAW,CAAC,SAA4C,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YACnF,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QACrC,CAAC;QAED,MAAM,MAAM,GAA+C;YACzD,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,MAAM,CAAC,GAAsC;YACxD,SAAS,EAAE,SAA4C;YACvD,YAAY,EAAE,YAAY,IAAI,EAAqC;YACnE,KAAK,EAAE,MAAM,CAAC,KAA8B;YAC5C,kBAAkB,EAAE,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC;SAC5D,CAAC;QACF,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAChE,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YAC9B,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../../core/platform/platform.js';\nimport type * as SDK from '../../../core/sdk/sdk.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport * as Types from '../types/types.js';\n\nimport {data as metaHandlerData, type MetaHandlerData} from './MetaHandler.js';\nimport {data as networkRequestsHandlerData} from './NetworkRequestsHandler.js';\nimport type {FinalizeOptions, HandlerName} from './types.js';\n\nfunction completeURL(base: string, url: string): Platform.DevToolsPath.UrlString|null {\n if (url.startsWith('data:') || url.startsWith('blob:') || url.startsWith('javascript:') || url.startsWith('mailto:')) {\n return url as Platform.DevToolsPath.UrlString;\n }\n\n try {\n return new URL(url, base).href as Platform.DevToolsPath.UrlString;\n } catch {}\n\n return null;\n}\n\nexport interface ScriptsData {\n /** Note: this is only populated when the \"Enhanced Traces\" feature is enabled. */\n scripts: Script[];\n}\n\nexport interface Script {\n isolate: string;\n scriptId: Protocol.Runtime.ScriptId;\n frame: string;\n ts: Types.Timing.Micro;\n inline: boolean;\n url?: string;\n sourceUrl?: string;\n content?: string;\n /**\n * Note: this is the literal text given as the sourceMappingURL value. It has not been resolved relative to the script url.\n * Since M138, data urls are never set here.\n */\n sourceMapUrl?: string;\n /** If true, the source map url was a data URL, so it got removed from the trace event. */\n sourceMapUrlElided?: boolean;\n sourceMap?: SDK.SourceMap.SourceMap;\n request?: Types.Events.SyntheticNetworkRequest;\n /** Lazily generated - use getScriptGeneratedSizes to access. */\n sizes?: GeneratedFileSizes;\n}\n\ntype GeneratedFileSizes = {\n errorMessage: string,\n}|{files: Record<string, number>, unmappedBytes: number, totalBytes: number};\n\nlet scriptById = new Map<string, Script>();\nlet frameIdByIsolate = new Map<string, string>();\n\nexport function deps(): HandlerName[] {\n return ['Meta', 'NetworkRequests'];\n}\n\nexport function reset(): void {\n scriptById = new Map();\n frameIdByIsolate = new Map();\n}\n\nexport function handleEvent(event: Types.Events.Event): void {\n const getOrMakeScript = (isolate: string|number, scriptIdAsNumber: number): Script => {\n const scriptId = String(scriptIdAsNumber) as Protocol.Runtime.ScriptId;\n const key = `${isolate}.${scriptId}`;\n return Platform.MapUtilities.getWithDefault(\n scriptById, key, () => ({isolate, scriptId, frame: '', ts: event.ts} as Script));\n };\n\n if (Types.Events.isRundownScriptCompiled(event) && event.args.data) {\n const {isolate, scriptId, frame} = event.args.data;\n const script = getOrMakeScript(isolate, scriptId);\n script.frame = frame;\n script.ts = event.ts;\n\n return;\n }\n\n if (Types.Events.isRundownScript(event)) {\n const {isolate, scriptId, url, sourceUrl, sourceMapUrl, sourceMapUrlElided} = event.args.data;\n const script = getOrMakeScript(isolate, scriptId);\n if (!script.frame) {\n script.frame = frameIdByIsolate.get(String(isolate)) ?? '';\n }\n script.url = url;\n script.ts = event.ts;\n if (sourceUrl) {\n script.sourceUrl = sourceUrl;\n }\n\n // Older traces may have data source map urls. Those can be very large, so a change\n // was made to elide them from the trace.\n // If elided, a fresh trace will fetch the source map from the Script model\n // (see TimelinePanel getExistingSourceMap). If not fresh, the source map is resolved\n // instead in this handler via `findCachedRawSourceMap`.\n if (sourceMapUrlElided) {\n script.sourceMapUrlElided = true;\n } else if (sourceMapUrl) {\n script.sourceMapUrl = sourceMapUrl;\n }\n return;\n }\n\n if (Types.Events.isRundownScriptSource(event)) {\n const {isolate, scriptId, sourceText} = event.args.data;\n const script = getOrMakeScript(isolate, scriptId);\n script.content = sourceText;\n return;\n }\n\n if (Types.Events.isRundownScriptSourceLarge(event)) {\n const {isolate, scriptId, sourceText} = event.args.data;\n const script = getOrMakeScript(isolate, scriptId);\n script.content = (script.content ?? '') + sourceText;\n return;\n }\n\n // Setup frameIdByIsolate, which is used only in the case that we are missing\n // rundown events for a script. We won't get a frame association from the rundown\n // events if the recording started only after the script was first compiled. In\n // that scenario, derive the frame via the isolate / FunctionCall events.\n // TODO: ideally, we put the frame on ScriptCatchup event. So much easier. This approach has some\n // issues.\n if (Types.Events.isFunctionCall(event) && event.args.data?.isolate && event.args.data.frame) {\n const {isolate, frame} = event.args.data;\n const existingValue = frameIdByIsolate.get(isolate);\n if (existingValue !== frame) {\n frameIdByIsolate.set(isolate, frame);\n\n // Update the scripts we discovered but without knowing their frame.\n for (const script of scriptById.values()) {\n if (!script.frame && script.isolate === isolate) {\n script.frame = frame;\n }\n }\n }\n }\n}\n\nfunction findFrame(meta: MetaHandlerData, frameId: string): Types.Events.TraceFrame|null {\n for (const frames of meta.frameByProcessId?.values()) {\n const frame = frames.get(frameId);\n if (frame) {\n return frame;\n }\n }\n\n return null;\n}\n\nfunction findNetworkRequest(networkRequests: Types.Events.SyntheticNetworkRequest[], script: Script):\n Types.Events.SyntheticNetworkRequest|null {\n if (!script.url) {\n return null;\n }\n\n return networkRequests.find(request => request.args.data.url === script.url) ?? null;\n}\n\nfunction computeMappingEndColumns(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 a value in this map.\n return result;\n}\n\n/**\n * Using a script's contents and source map, attribute every generated byte to an authored source file.\n */\nfunction computeGeneratedFileSizes(script: 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 mappingEndCols = computeMappingEndColumns(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 = mappingEndCols.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\nexport function getScriptGeneratedSizes(script: Script): GeneratedFileSizes|null {\n if (script.sourceMap && !script.sizes) {\n script.sizes = computeGeneratedFileSizes(script);\n }\n\n return script.sizes ?? null;\n}\n\nfunction findCachedRawSourceMap(script: Script, options: Types.Configuration.ParseOptions): SDK.SourceMap.SourceMapV3|\n undefined {\n if (options.isFreshRecording || !options.metadata?.sourceMaps) {\n // Exit if this is not a loaded trace w/ source maps in the metadata.\n return;\n }\n\n // For elided data url source maps, search the metadata source maps by script url.\n if (script.sourceMapUrlElided) {\n if (!script.url) {\n return;\n }\n\n const cachedSourceMap = options.metadata.sourceMaps.find(m => m.url === script.url);\n if (cachedSourceMap) {\n return cachedSourceMap.sourceMap;\n }\n\n return;\n }\n\n if (!script.sourceMapUrl) {\n return;\n }\n\n // Otherwise, search by source map url.\n // Note: early enhanced traces may have this field set for data urls. Ignore those,\n // as they were never stored in metadata sourcemap.\n const isDataUrl = script.sourceMapUrl.startsWith('data:');\n if (!isDataUrl) {\n const cachedSourceMap = options.metadata.sourceMaps.find(m => m.sourceMapUrl === script.sourceMapUrl);\n if (cachedSourceMap) {\n return cachedSourceMap.sourceMap;\n }\n }\n\n return;\n}\n\nexport async function finalize(options: FinalizeOptions): Promise<void> {\n const meta = metaHandlerData();\n const networkRequests = [...networkRequestsHandlerData().byId.values()];\n\n const documentUrls = new Set<string>();\n for (const frames of meta.frameByProcessId.values()) {\n for (const frame of frames.values()) {\n documentUrls.add(frame.url);\n }\n }\n\n for (const script of scriptById.values()) {\n script.request = findNetworkRequest(networkRequests, script) ?? undefined;\n script.inline = !!script.url && documentUrls.has(script.url);\n }\n\n if (!options.resolveSourceMap) {\n return;\n }\n\n const promises = [];\n for (const script of scriptById.values()) {\n // No frame or url means the script came from somewhere we don't care about.\n // Note: scripts from inline <SCRIPT> elements use the url of the HTML document,\n // so aren't ignored.\n if (!script.frame || !script.url || (!script.sourceMapUrl && !script.sourceMapUrlElided)) {\n continue;\n }\n\n const frameUrl = findFrame(meta, script.frame)?.url as Platform.DevToolsPath.UrlString | undefined;\n if (!frameUrl) {\n continue;\n }\n\n // If there is a `sourceURL` magic comment, resolve the compiledUrl against the frame url.\n // example: `// #sourceURL=foo.js` for target frame https://www.example.com/home -> https://www.example.com/home/foo.js\n let sourceUrl = script.url;\n if (script.sourceUrl) {\n sourceUrl = completeURL(frameUrl, script.sourceUrl) ?? script.sourceUrl;\n }\n\n let sourceMapUrl;\n if (script.sourceMapUrl) {\n // Resolve the source map url. The value given by v8 may be relative, so resolve it here.\n // This process should match the one in `SourceMapManager.attachSourceMap`.\n sourceMapUrl =\n completeURL(sourceUrl as Platform.DevToolsPath.UrlString, script.sourceMapUrl);\n if (!sourceMapUrl) {\n continue;\n }\n\n script.sourceMapUrl = sourceMapUrl;\n }\n\n const params: Types.Configuration.ResolveSourceMapParams = {\n scriptId: script.scriptId,\n scriptUrl: script.url as Platform.DevToolsPath.UrlString,\n sourceUrl: sourceUrl as Platform.DevToolsPath.UrlString,\n sourceMapUrl: sourceMapUrl ?? '' as Platform.DevToolsPath.UrlString,\n frame: script.frame as Protocol.Page.FrameId,\n cachedRawSourceMap: findCachedRawSourceMap(script, options),\n };\n const promise = options.resolveSourceMap(params).then(sourceMap => {\n if (sourceMap) {\n script.sourceMap = sourceMap;\n }\n });\n promises.push(promise.catch(e => {\n console.error('Uncaught error when resolving source map', params, e);\n }));\n }\n await Promise.all(promises);\n}\n\nexport function data(): ScriptsData {\n return {\n scripts: [...scriptById.values()],\n };\n}\n"]}
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "devtools_entrypoint-bundle-typescript-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"inlineSources": true,
|
|
10
10
|
"lib": [
|
|
11
|
+
"dom",
|
|
12
|
+
"dom.iterable",
|
|
11
13
|
"ES2023",
|
|
12
14
|
"ES2024.Promise",
|
|
13
15
|
"ESNext.Iterator",
|
|
14
16
|
"ESNext.Collection",
|
|
15
|
-
"ESNext.Array"
|
|
16
|
-
"dom",
|
|
17
|
-
"dom.iterable"
|
|
17
|
+
"ESNext.Array"
|
|
18
18
|
],
|
|
19
19
|
"module": "esnext",
|
|
20
20
|
"noEmitOnError": true,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"target": "ES2023",
|
|
32
32
|
"tsBuildInfoFile": "handlers-tsconfig.json.tsbuildinfo",
|
|
33
33
|
"typeRoots": [],
|
|
34
|
+
"types": [],
|
|
34
35
|
"useUnknownInCatchVariables": false
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
@@ -73,12 +74,21 @@
|
|
|
73
74
|
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
|
|
74
75
|
],
|
|
75
76
|
"references": [
|
|
77
|
+
{
|
|
78
|
+
"path": "../../../core/common/bundle-tsconfig.json"
|
|
79
|
+
},
|
|
76
80
|
{
|
|
77
81
|
"path": "../../../core/platform/bundle-tsconfig.json"
|
|
78
82
|
},
|
|
83
|
+
{
|
|
84
|
+
"path": "../../../core/sdk/bundle-tsconfig.json"
|
|
85
|
+
},
|
|
79
86
|
{
|
|
80
87
|
"path": "../../../generated/generated-tsconfig.json"
|
|
81
88
|
},
|
|
89
|
+
{
|
|
90
|
+
"path": "../../../generated/protocol-tsconfig.json"
|
|
91
|
+
},
|
|
82
92
|
{
|
|
83
93
|
"path": "../../../third_party/third-party-web/bundle-tsconfig.json"
|
|
84
94
|
},
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// browser.
|
|
7
7
|
// 3. Therefore, from a developer's point of view, there is nothing more they
|
|
8
8
|
// can do if they've put `async` on, and within the context of Insights, we
|
|
9
|
-
// shouldn't report an async script as render
|
|
9
|
+
// shouldn't report an async script as render-blocking.
|
|
10
10
|
// In the future we may want to consider suggesting the use of `defer` over
|
|
11
11
|
// `async`, as it doesn't have this concern, but for now we'll allow `async`
|
|
12
12
|
// and not report it as an issue.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Network.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Network.ts"],"names":[],"mappings":"AAMA,6DAA6D;AAC7D,oCAAoC;AACpC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,cAAc;AACd,6EAA6E;AAC7E,8EAA8E;AAC9E,0DAA0D;AAC1D,2EAA2E;AAC3E,4EAA4E;AAC5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AC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\nimport * as Protocol from '../../../generated/protocol.js';\nimport type {RenderBlocking, SyntheticNetworkRequest} from '../types/TraceEvents.js';\n\n// Important: we purposefully treat `potentially_blocking` as\n// non-render-blocking here because:\n// 1. An async script can run on the main thread at any point, including before\n// the page is loaded\n// 2. An async script will never block the parsing and rendering process of the\n// browser.\n// 3. Therefore, from a developer's point of view, there is nothing more they\n// can do if they've put `async` on, and within the context of Insights, we\n// shouldn't report an async script as render
|
|
1
|
+
{"version":3,"file":"Network.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Network.ts"],"names":[],"mappings":"AAMA,6DAA6D;AAC7D,oCAAoC;AACpC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,cAAc;AACd,6EAA6E;AAC7E,8EAA8E;AAC9E,0DAA0D;AAC1D,2EAA2E;AAC3E,4EAA4E;AAC5E,iCAAiC;AACjC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAiB;IACzD,cAAc;IACd,mCAAmC;IACnC,sBAAsB;CACvB,CAAC,CAAC;AAEH,MAAM,UAAU,4CAA4C,CAAC,KAA8B;IACzF,OAAO,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAoC;;;;CAI1E,CAAC,CAAC;AAEH,MAAM,UAAU,qCAAqC,CAAC,KAA8B;IAClF,OAAO,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAWD,MAAM,CAAC,MAAM,sBAAsB,GA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C;gBACvC,MAAM;YACR,KAAK,UAAU;gBACb,mBAAmB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;gBACvC,MAAM;YACR,KAAK,iBAAiB;gBACpB,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;gBAC9C,MAAM;YACR,KAAK,SAAS;gBACZ,mBAAmB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;gBACtC,MAAM;YACR;gBACE,4BAA4B;gBAC5B,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,MAAM,wBAAwB,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CAAC,KAA8B;IAC/E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;QACvD,sEAAsE;QACtE,6DAA6D;QAC7D,8FAA8F;QAC9F,OAAO,wBAAwB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\nimport * as Protocol from '../../../generated/protocol.js';\nimport type {RenderBlocking, SyntheticNetworkRequest} from '../types/TraceEvents.js';\n\n// Important: we purposefully treat `potentially_blocking` as\n// non-render-blocking here because:\n// 1. An async script can run on the main thread at any point, including before\n// the page is loaded\n// 2. An async script will never block the parsing and rendering process of the\n// browser.\n// 3. Therefore, from a developer's point of view, there is nothing more they\n// can do if they've put `async` on, and within the context of Insights, we\n// shouldn't report an async script as render-blocking.\n// In the future we may want to consider suggesting the use of `defer` over\n// `async`, as it doesn't have this concern, but for now we'll allow `async`\n// and not report it as an issue.\nconst NON_RENDER_BLOCKING_VALUES = new Set<RenderBlocking>([\n 'non_blocking',\n 'dynamically_injected_non_blocking',\n 'potentially_blocking',\n]);\n\nexport function isSyntheticNetworkRequestEventRenderBlocking(event: SyntheticNetworkRequest): boolean {\n return !NON_RENDER_BLOCKING_VALUES.has(event.args.data.renderBlocking);\n}\n\nconst HIGH_NETWORK_PRIORITIES = new Set<Protocol.Network.ResourcePriority>([\n Protocol.Network.ResourcePriority.VeryHigh,\n Protocol.Network.ResourcePriority.High,\n Protocol.Network.ResourcePriority.Medium,\n]);\n\nexport function isSyntheticNetworkRequestHighPriority(event: SyntheticNetworkRequest): boolean {\n return HIGH_NETWORK_PRIORITIES.has(event.args.data.priority);\n}\n\nexport interface CacheControl {\n 'max-age'?: number;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'must-revalidate'?: boolean;\n // eslint-disable-next-line @stylistic/quote-props\n 'private'?: boolean;\n}\n\nexport const CACHEABLE_STATUS_CODES = new Set([200, 203, 206]);\n\n/** @type {Set<LH.Crdp.Network.ResourceType>} */\nexport const STATIC_RESOURCE_TYPES = new Set([\n Protocol.Network.ResourceType.Font,\n Protocol.Network.ResourceType.Image,\n Protocol.Network.ResourceType.Media,\n Protocol.Network.ResourceType.Script,\n Protocol.Network.ResourceType.Stylesheet,\n]);\n\nexport const NON_NETWORK_SCHEMES = [\n 'blob', // @see https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL\n 'data', // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\n 'intent', // @see https://developer.chrome.com/docs/multidevice/android/intents/\n 'file', // @see https://en.wikipedia.org/wiki/File_URI_scheme\n 'filesystem', // @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystem\n 'chrome-extension',\n];\n\n/**\n * Parses Cache-Control directives based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control\n * eg. 'no-cache, no-store, max-age=0, no-transform, private' will return\n * {no-cache: true, no-store: true, max-age: 0, no-transform: true, private: true}\n */\nexport function parseCacheControl(header: string|null): CacheControl|null {\n if (!header) {\n return null;\n }\n\n const directives = header.split(',').map(directive => directive.trim());\n const cacheControlOptions: CacheControl = {};\n\n for (const directive of directives) {\n const [key, value] = directive.split('=').map(part => part.trim());\n\n switch (key) {\n case 'max-age': {\n const maxAge = parseInt(value, 10);\n if (!isNaN(maxAge)) {\n cacheControlOptions['max-age'] = maxAge;\n }\n break;\n }\n case 'no-cache':\n cacheControlOptions['no-cache'] = true;\n break;\n case 'no-store':\n cacheControlOptions['no-store'] = true;\n break;\n case 'must-revalidate':\n cacheControlOptions['must-revalidate'] = true;\n break;\n case 'private':\n cacheControlOptions['private'] = true;\n break;\n default:\n // Ignore unknown directives\n break;\n }\n }\n\n return cacheControlOptions;\n}\n\nconst SECURE_LOCALHOST_DOMAINS = ['localhost', '127.0.0.1'];\n\n/**\n * Is the host localhost-enough to satisfy the \"secure context\" definition\n * https://github.com/GoogleChrome/lighthouse/pull/11766#discussion_r582340683\n */\nexport function isSyntheticNetworkRequestLocalhost(event: SyntheticNetworkRequest): boolean {\n try {\n const hostname = new URL(event.args.data.url).hostname;\n // Any hostname terminating in `.localhost` is considered to be local.\n // https://w3c.github.io/webappsec-secure-contexts/#localhost\n // This method doesn't consider IPs that resolve to loopback, IPv6 or other loopback edgecases\n return SECURE_LOCALHOST_DOMAINS.includes(hostname) || hostname.endsWith('.localhost');\n } catch {\n return false;\n }\n}\n"]}
|
|
@@ -438,20 +438,13 @@ export class SamplesIntegrator {
|
|
|
438
438
|
if (showAllEvents) {
|
|
439
439
|
return;
|
|
440
440
|
}
|
|
441
|
-
let previousNativeFrameName = null;
|
|
442
441
|
let j = 0;
|
|
443
442
|
for (let i = 0; i < stack.length; ++i) {
|
|
444
443
|
const frame = stack[i].callFrame;
|
|
445
444
|
const nativeRuntimeFrame = _a.isNativeRuntimeFrame(frame);
|
|
446
|
-
if (nativeRuntimeFrame
|
|
447
|
-
!_a.showNativeName(frame.functionName, engineConfig.includeRuntimeCallStats)) {
|
|
445
|
+
if (nativeRuntimeFrame) {
|
|
448
446
|
continue;
|
|
449
447
|
}
|
|
450
|
-
const nativeFrameName = nativeRuntimeFrame ? _a.nativeGroup(frame.functionName) : null;
|
|
451
|
-
if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
previousNativeFrameName = nativeFrameName;
|
|
455
448
|
stack[j++] = stack[i];
|
|
456
449
|
}
|
|
457
450
|
stack.length = j;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACH,wBAAwB,GAAwC,EAAE,CAAC;IACnE;;;;;;OAMG;IACH,eAAe,GAAwC,EAAE,CAAC;IAC1D;;OAEG;IACH,UAAU,CAAyB;IACnC;;OAEG;IACH,SAAS,CAAwB;IACjC;;;;;;;OAOG;IACH,mBAAmB,GAAa,EAAE,CAAC;IACnC;;;;;OAKG;IACH,iBAAiB,GAAG,KAAK,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAqD;IAClE;;;;;;;;OAQG;IACH,UAAU,GAAG,IAAI,GAAG,EAA8E,CAAC;IAEnG,aAAa,CAAoC;IACjD,UAAU,CAAyB;IAEnC;;;OAGG;IACH,cAAc,GAAqC,EA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C,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;QAClF,MAAM,OAAO,GAAG,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QACnD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;;AAED,WAAiB,iBAAiB;IAChC,IAAY,YAGX;IAHD,WAAY,YAAY;QACtB,mCAAmB,CAAA;QACnB,+BAAe,CAAA;IACjB,CAAC,EAHW,YAAY,GAAZ,8BAAY,KAAZ,8BAAY,QAGvB;AACH,CAAC,EALgB,iBAAiB,KAAjB,iBAAiB,QAKjC","sourcesContent":["// Copyright 2023 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {milliToMicro} from './Timing.js';\nimport {extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficient (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of running the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.Events.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.Events.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.Events.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.Events.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is useful in\n * cases where we can be missing the start of JS invocation events if\n * we start tracing half-way through.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.Events.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n #profileId: Types.Events.ProfileID;\n\n /**\n * Keeps track of the individual samples from the CPU Profile.\n * Only used with Debug Mode experiment enabled.\n */\n jsSampleEvents: Types.Events.SyntheticJSSample[] = [];\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, profileId: Types.Events.ProfileID,\n pid: Types.Events.ProcessID, tid: Types.Events.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.defaults();\n this.#profileId = profileId;\n }\n\n buildProfileCalls(traceEvents: Types.Events.Event[]): Types.Events.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n sortTraceEventsInPlace(this.jsSampleEvents);\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.Events.Event): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.Events.SyntheticProfileCall, parent?: Types.Events.Event): void {\n if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.Events.Event): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.Events.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n if (!samples) {\n return [];\n }\n const calls: Types.Events.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));\n if (!node) {\n continue;\n }\n const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);\n calls.push(call);\n\n if (this.#engineConfig.debugMode) {\n const traceId = this.#profileModel.traceIds?.[i];\n this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));\n }\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n /**\n * Given a synthetic profile call, returns an array of profile calls\n * representing the stack trace that profile call belongs to based on\n * its nodeId. The input profile call will be at the top of the\n * returned stack (last position), meaning that any other frames that\n * were effectively above it are omitted.\n * @param profileCall\n * @param overrideTimeStamp a custom timestamp to use for the returned\n * profile calls. If not defined, the timestamp of the input\n * profileCall is used instead. This param is useful for example when\n * creating the profile calls for a sample with a trace id, since the\n * timestamp of the corresponding trace event should be used instead\n * of the sample's.\n */\n\n #makeProfileCallsForStack(profileCall: Types.Events.SyntheticProfileCall, overrideTimeStamp?: Types.Timing.Micro):\n Types.Events.SyntheticProfileCall[] {\n let node = this.#profileModel.nodeById(profileCall.nodeId);\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const callFrames = new Array<Types.Events.SyntheticProfileCall>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = callFrames.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection call frame on top of the stack.\n callFrames[i--] = profileCall;\n }\n\n // Many of these ProfileCalls will be GC'd later when we estimate the frame\n // durations\n while (node) {\n callFrames[i--] = makeProfileCall(\n node, profileCall.profileId, profileCall.sampleIndex, overrideTimeStamp ?? profileCall.ts, this.#processId,\n this.#threadId);\n node = node.parent;\n }\n return callFrames;\n }\n\n #getStackForSampleTraceId(traceId: number, timestamp: Types.Timing.Micro): Types.Events.SyntheticProfileCall[]|null {\n const nodeId = this.#profileModel.traceIds?.[traceId];\n const node = nodeId && this.#profileModel.nodeById(nodeId);\n const maybeCallForTraceId =\n node && makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);\n if (!maybeCallForTraceId) {\n return null;\n }\n if (this.#engineConfig.debugMode) {\n this.jsSampleEvents.push(this.#makeJSSampleEvent(maybeCallForTraceId, timestamp, traceId));\n }\n return this.#makeProfileCallsForStack(maybeCallForTraceId);\n }\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.Events.Event): void {\n let stackTrace = this.#currentJSStack;\n if (Types.Events.isProfileCall(event)) {\n stackTrace = this.#makeProfileCallsForStack(event);\n }\n const traceId = extractSampleTraceId(event);\n const maybeCallForTraceId = traceId && this.#getStackForSampleTraceId(traceId, event.ts);\n if (maybeCallForTraceId) {\n stackTrace = maybeCallForTraceId;\n }\n\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n this.#truncateJSStack(i, event.ts);\n\n for (; i < stackTrace.length; ++i) {\n const call = stackTrace[i];\n if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id ||\n call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.Micro): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n #makeJSSampleEvent(call: Types.Events.SyntheticProfileCall, timestamp: Types.Timing.Micro, traceId?: number):\n Types.Events.SyntheticJSSample {\n const JSSampleEvent: Types.Events.SyntheticJSSample = {\n name: Types.Events.Name.JS_SAMPLE,\n cat: 'devtools.timeline',\n args: {\n data: {traceId, stackTrace: this.#makeProfileCallsForStack(call).map(e => e.callFrame)},\n },\n ph: Types.Events.Phase.INSTANT,\n ts: timestamp,\n dur: Types.Timing.Micro(0),\n pid: this.#processId,\n tid: this.#threadId,\n };\n return JSSampleEvent;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): SamplesIntegrator.NativeGroups|null {\n if (nativeName.startsWith('Parse')) {\n return SamplesIntegrator.NativeGroups.PARSE;\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return SamplesIntegrator.NativeGroups.COMPILE;\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames(stack: Types.Events.SyntheticProfileCall[], engineConfig: Types.Configuration.Configuration):\n void {\n const showAllEvents = engineConfig.showAllEvents;\n if (showAllEvents) {\n return;\n }\n let previousNativeFrameName: string|null = null;\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame &&\n !SamplesIntegrator.showNativeName(frame.functionName, engineConfig.includeRuntimeCallStats)) {\n continue;\n }\n const nativeFrameName = nativeRuntimeFrame ? SamplesIntegrator.nativeGroup(frame.functionName) : null;\n if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {\n continue;\n }\n previousNativeFrameName = nativeFrameName;\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n\n static createFakeTraceFromCpuProfile(profile: Protocol.Profiler.Profile, tid: Types.Events.ThreadID):\n Types.File.TraceFile {\n if (!profile) {\n return {traceEvents: [], metadata: {}};\n }\n // The |Name.CPU_PROFILE| will let MetaHandler to set |traceIsGeneric| to false\n // The start time and duration is important here because we'll use them to determine the traceBounds\n // We use the start and end time of the profile (which is longer than all samples), so the Performance\n // panel won't truncate this time period.\n const cpuProfileEvent: Types.Events.SyntheticCpuProfile = {\n cat: 'disabled-by-default-devtools.timeline',\n name: Types.Events.Name.CPU_PROFILE,\n ph: Types.Events.Phase.COMPLETE,\n pid: Types.Events.ProcessID(1),\n tid,\n ts: Types.Timing.Micro(profile.startTime),\n dur: Types.Timing.Micro(profile.endTime - profile.startTime),\n args: {data: {cpuProfile: profile}},\n // Create an arbitrary profile id.\n id: '0x1' as Types.Events.ProfileID,\n };\n\n return {\n traceEvents: [cpuProfileEvent],\n metadata: {\n dataOrigin: Types.File.DataOrigin.CPU_PROFILE,\n }\n };\n }\n\n static extractCpuProfileFromFakeTrace(traceEvents: readonly Types.Events.Event[]): Protocol.Profiler.Profile {\n const profileEvent = traceEvents.find(e => Types.Events.isSyntheticCpuProfile(e));\n const profile = profileEvent?.args.data.cpuProfile;\n if (!profile) {\n throw new Error('Missing cpuProfile data');\n }\n return profile;\n }\n}\n\nexport namespace SamplesIntegrator {\n export enum NativeGroups {\n COMPILE = 'Compile',\n PARSE = 'Parse',\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACH,wBAAwB,GAAwC,EAAE,CAAC;IACnE;;;;;;OAMG;IACH,eAAe,GAAwC,EAAE,CAAC;IAC1D;;OAEG;IACH,UAAU,CAAyB;IACnC;;OAEG;IACH,SAAS,CAAwB;IACjC;;;;;;;OAOG;IACH,mBAAmB,GAAa,EAAE,CAAC;IACnC;;;;;OAKG;IACH,iBAAiB,GAAG,KAAK,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAqD;IAClE;;;;;;;;OAQG;IACH,UAAU,GAAG,IAAI,GAAG,EAA8E,CAAC;IAEnG,aAAa,CAAoC;IACjD,UAAU,CAAyB;IAEnC;;;OAGG;IACH,cAAc,GAAqC,EAAE,CAAC;IAEtD,YACI,YAAgE,EAAE,SAAiC,EACnG,GAA2B,EAAE,GAA0B,EAAE,aAAiD;QAC5G,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,KAAK,CAAC,aAAa,CAA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AAS,CAAC,CAAC,CAAC;YAC9B,GAAG;YACH,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACzC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;YAC5D,IAAI,EAAE,EAAC,IAAI,EAAE,EAAC,UAAU,EAAE,OAAO,EAAC,EAAC;YACnC,kCAAkC;YAClC,EAAE,EAAE,KAA+B;SACpC,CAAC;QAEF,OAAO;YACL,WAAW,EAAE,CAAC,eAAe,CAAC;YAC9B,QAAQ,EAAE;gBACR,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW;aAC9C;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,8BAA8B,CAAC,WAA0C;QAC9E,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;QAClF,MAAM,OAAO,GAAG,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QACnD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;;AAED,WAAiB,iBAAiB;IAChC,IAAY,YAGX;IAHD,WAAY,YAAY;QACtB,mCAAmB,CAAA;QACnB,+BAAe,CAAA;IACjB,CAAC,EAHW,YAAY,GAAZ,8BAAY,KAAZ,8BAAY,QAGvB;AACH,CAAC,EALgB,iBAAiB,KAAjB,iBAAiB,QAKjC","sourcesContent":["// Copyright 2023 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {milliToMicro} from './Timing.js';\nimport {extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficient (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of running the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.Events.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.Events.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.Events.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.Events.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is useful in\n * cases where we can be missing the start of JS invocation events if\n * we start tracing half-way through.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.Events.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n #profileId: Types.Events.ProfileID;\n\n /**\n * Keeps track of the individual samples from the CPU Profile.\n * Only used with Debug Mode experiment enabled.\n */\n jsSampleEvents: Types.Events.SyntheticJSSample[] = [];\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, profileId: Types.Events.ProfileID,\n pid: Types.Events.ProcessID, tid: Types.Events.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.defaults();\n this.#profileId = profileId;\n }\n\n buildProfileCalls(traceEvents: Types.Events.Event[]): Types.Events.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n sortTraceEventsInPlace(this.jsSampleEvents);\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.Events.Event): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.Events.SyntheticProfileCall, parent?: Types.Events.Event): void {\n if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.Events.Event): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.Events.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n if (!samples) {\n return [];\n }\n const calls: Types.Events.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));\n if (!node) {\n continue;\n }\n const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);\n calls.push(call);\n\n if (this.#engineConfig.debugMode) {\n const traceId = this.#profileModel.traceIds?.[i];\n this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));\n }\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n /**\n * Given a synthetic profile call, returns an array of profile calls\n * representing the stack trace that profile call belongs to based on\n * its nodeId. The input profile call will be at the top of the\n * returned stack (last position), meaning that any other frames that\n * were effectively above it are omitted.\n * @param profileCall\n * @param overrideTimeStamp a custom timestamp to use for the returned\n * profile calls. If not defined, the timestamp of the input\n * profileCall is used instead. This param is useful for example when\n * creating the profile calls for a sample with a trace id, since the\n * timestamp of the corresponding trace event should be used instead\n * of the sample's.\n */\n\n #makeProfileCallsForStack(profileCall: Types.Events.SyntheticProfileCall, overrideTimeStamp?: Types.Timing.Micro):\n Types.Events.SyntheticProfileCall[] {\n let node = this.#profileModel.nodeById(profileCall.nodeId);\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const callFrames = new Array<Types.Events.SyntheticProfileCall>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = callFrames.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection call frame on top of the stack.\n callFrames[i--] = profileCall;\n }\n\n // Many of these ProfileCalls will be GC'd later when we estimate the frame\n // durations\n while (node) {\n callFrames[i--] = makeProfileCall(\n node, profileCall.profileId, profileCall.sampleIndex, overrideTimeStamp ?? profileCall.ts, this.#processId,\n this.#threadId);\n node = node.parent;\n }\n return callFrames;\n }\n\n #getStackForSampleTraceId(traceId: number, timestamp: Types.Timing.Micro): Types.Events.SyntheticProfileCall[]|null {\n const nodeId = this.#profileModel.traceIds?.[traceId];\n const node = nodeId && this.#profileModel.nodeById(nodeId);\n const maybeCallForTraceId =\n node && makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);\n if (!maybeCallForTraceId) {\n return null;\n }\n if (this.#engineConfig.debugMode) {\n this.jsSampleEvents.push(this.#makeJSSampleEvent(maybeCallForTraceId, timestamp, traceId));\n }\n return this.#makeProfileCallsForStack(maybeCallForTraceId);\n }\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.Events.Event): void {\n let stackTrace = this.#currentJSStack;\n if (Types.Events.isProfileCall(event)) {\n stackTrace = this.#makeProfileCallsForStack(event);\n }\n const traceId = extractSampleTraceId(event);\n const maybeCallForTraceId = traceId && this.#getStackForSampleTraceId(traceId, event.ts);\n if (maybeCallForTraceId) {\n stackTrace = maybeCallForTraceId;\n }\n\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n this.#truncateJSStack(i, event.ts);\n\n for (; i < stackTrace.length; ++i) {\n const call = stackTrace[i];\n if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id ||\n call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.Micro): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n #makeJSSampleEvent(call: Types.Events.SyntheticProfileCall, timestamp: Types.Timing.Micro, traceId?: number):\n Types.Events.SyntheticJSSample {\n const JSSampleEvent: Types.Events.SyntheticJSSample = {\n name: Types.Events.Name.JS_SAMPLE,\n cat: 'devtools.timeline',\n args: {\n data: {traceId, stackTrace: this.#makeProfileCallsForStack(call).map(e => e.callFrame)},\n },\n ph: Types.Events.Phase.INSTANT,\n ts: timestamp,\n dur: Types.Timing.Micro(0),\n pid: this.#processId,\n tid: this.#threadId,\n };\n return JSSampleEvent;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): SamplesIntegrator.NativeGroups|null {\n if (nativeName.startsWith('Parse')) {\n return SamplesIntegrator.NativeGroups.PARSE;\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return SamplesIntegrator.NativeGroups.COMPILE;\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames(stack: Types.Events.SyntheticProfileCall[], engineConfig: Types.Configuration.Configuration):\n void {\n const showAllEvents = engineConfig.showAllEvents;\n if (showAllEvents) {\n return;\n }\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame) {\n continue;\n }\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n\n static createFakeTraceFromCpuProfile(profile: Protocol.Profiler.Profile, tid: Types.Events.ThreadID):\n Types.File.TraceFile {\n if (!profile) {\n return {traceEvents: [], metadata: {}};\n }\n // The |Name.CPU_PROFILE| will let MetaHandler to set |traceIsGeneric| to false\n // The start time and duration is important here because we'll use them to determine the traceBounds\n // We use the start and end time of the profile (which is longer than all samples), so the Performance\n // panel won't truncate this time period.\n const cpuProfileEvent: Types.Events.SyntheticCpuProfile = {\n cat: 'disabled-by-default-devtools.timeline',\n name: Types.Events.Name.CPU_PROFILE,\n ph: Types.Events.Phase.COMPLETE,\n pid: Types.Events.ProcessID(1),\n tid,\n ts: Types.Timing.Micro(profile.startTime),\n dur: Types.Timing.Micro(profile.endTime - profile.startTime),\n args: {data: {cpuProfile: profile}},\n // Create an arbitrary profile id.\n id: '0x1' as Types.Events.ProfileID,\n };\n\n return {\n traceEvents: [cpuProfileEvent],\n metadata: {\n dataOrigin: Types.File.DataOrigin.CPU_PROFILE,\n }\n };\n }\n\n static extractCpuProfileFromFakeTrace(traceEvents: readonly Types.Events.Event[]): Protocol.Profiler.Profile {\n const profileEvent = traceEvents.find(e => Types.Events.isSyntheticCpuProfile(e));\n const profile = profileEvent?.args.data.cpuProfile;\n if (!profile) {\n throw new Error('Missing cpuProfile data');\n }\n return profile;\n }\n}\n\nexport namespace SamplesIntegrator {\n export enum NativeGroups {\n COMPILE = 'Compile',\n PARSE = 'Parse',\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ export declare const secondsToMilli: (value: Types.Timing.Seconds) => Types.Timi
|
|
|
4
4
|
export declare const secondsToMicro: (value: Types.Timing.Seconds) => Types.Timing.Micro;
|
|
5
5
|
export declare const microToMilli: (value: Types.Timing.Micro) => Types.Timing.Milli;
|
|
6
6
|
export declare const microToSeconds: (value: Types.Timing.Micro) => Types.Timing.Seconds;
|
|
7
|
-
export declare function timeStampForEventAdjustedByClosestNavigation(event: Types.Events.Event, traceBounds: Types.Timing.TraceWindowMicro, navigationsByNavigationId: Map<string, Types.Events.NavigationStart>, navigationsByFrameId: Map<string, Types.Events.NavigationStart[]>): Types.Timing.Micro;
|
|
7
|
+
export declare function timeStampForEventAdjustedByClosestNavigation(event: Types.Events.Event, traceBounds: Types.Timing.TraceWindowMicro, navigationsByNavigationId: Map<string, Types.Events.NavigationStart>, softNavigationsById: Map<number, Types.Events.SoftNavigationStart>, navigationsByFrameId: Map<string, Types.Events.NavigationStart[]>): Types.Timing.Micro;
|
|
8
8
|
/**
|
|
9
9
|
* Expands the trace window by a provided percentage or, if it the expanded window is smaller than 1 millisecond, expands it to 1 millisecond.
|
|
10
10
|
* If the expanded window is outside of the max trace window, cut the overflowing bound to the max trace window bound.
|