@paulirish/trace_engine 0.0.67-beta.2 → 0.0.67
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-inspector-issues.d.mts +13 -0
- package/.tmp/tsbuildinfo/analyze-inspector-issues.d.mts.map +1 -0
- package/.tmp/tsbuildinfo/analyze-trace.d.mts +17 -0
- package/.tmp/tsbuildinfo/analyze-trace.d.mts.map +1 -0
- package/.tmp/tsbuildinfo/test/test-trace-engine.d.mts +2 -0
- package/.tmp/tsbuildinfo/test/test-trace-engine.d.mts.map +1 -0
- package/.tmp/tsbuildinfo/third_party/third-party-web/third-party-web.d.ts +3 -0
- package/.tmp/tsbuildinfo/third_party/third-party-web/third-party-web.d.ts.map +1 -0
- package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -0
- package/README.md +22 -62
- package/analyze-inspector-issues.mjs +60 -0
- package/analyze-trace.mjs +144 -6
- package/core/common/ParsedURL.js +512 -0
- package/core/common/ParsedURL.js.map +1 -0
- package/core/common/common.d.ts +8 -33
- package/core/common/common.js +2 -0
- package/core/host/host.d.ts +1 -13
- package/core/host/host.js +1 -0
- package/core/i18n/i18n.d.ts +20 -8
- package/core/i18n/i18n.js +15 -0
- package/core/platform/ArrayUtilities.js +224 -0
- package/core/platform/ArrayUtilities.js.map +1 -0
- package/core/platform/Brand.js +5 -0
- package/core/platform/Brand.js.map +1 -0
- package/core/platform/Constructor.js +5 -0
- package/core/platform/Constructor.js.map +1 -0
- package/core/platform/DateUtilities.js +14 -0
- package/core/platform/DateUtilities.js.map +1 -0
- package/core/platform/DevToolsPath.js +28 -0
- package/core/platform/DevToolsPath.js.map +1 -0
- package/core/platform/HostRuntime.js +8 -0
- package/core/platform/HostRuntime.js.map +1 -0
- package/core/platform/KeyboardUtilities.js +34 -0
- package/core/platform/KeyboardUtilities.js.map +1 -0
- package/core/platform/MapUtilities.js +80 -0
- package/core/platform/MapUtilities.js.map +1 -0
- package/core/platform/MimeType.js +157 -0
- package/core/platform/MimeType.js.map +1 -0
- package/core/platform/NumberUtilities.js +73 -0
- package/core/platform/NumberUtilities.js.map +1 -0
- package/core/platform/Size.js +36 -0
- package/core/platform/Size.js.map +1 -0
- package/core/platform/StringUtilities.js +731 -0
- package/core/platform/StringUtilities.js.map +1 -0
- package/core/platform/Timing.js +10 -0
- package/core/platform/Timing.js.map +1 -0
- package/core/platform/TypedArrayUtilities.js +158 -0
- package/core/platform/TypedArrayUtilities.js.map +1 -0
- package/core/platform/TypescriptUtilities.js +17 -0
- package/core/platform/TypescriptUtilities.js.map +1 -0
- package/core/platform/UIString.d.ts +5 -2
- package/core/platform/UIString.js +5 -0
- package/core/platform/UIString.js.map +1 -0
- package/core/platform/UserVisibleError.d.ts +1 -12
- package/core/platform/UserVisibleError.js +23 -0
- package/core/platform/UserVisibleError.js.map +1 -0
- package/core/platform/api/HostRuntime.d.ts +1 -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 +58 -0
- package/core/platform/api/api-tsconfig.ref.json +26 -0
- package/core/platform/api/api.js +6 -0
- package/core/platform/api/api.js.map +1 -0
- package/core/platform/bundle-tsconfig.json +59 -0
- package/core/platform/bundle-tsconfig.ref.json +27 -0
- package/core/platform/foundation_unittests-tsconfig.json +73 -0
- package/core/platform/foundation_unittests-tsconfig.ref.json +40 -0
- package/core/platform/foundation_unittests_node_typecheck-tsconfig.json +69 -0
- package/core/platform/platform-tsconfig.json +81 -0
- package/core/platform/platform-tsconfig.ref.json +49 -0
- package/core/platform/platform.js +28 -0
- package/core/platform/platform.js.map +1 -0
- package/core/platform/platform_node_typecheck-tsconfig.json +78 -0
- package/core/platform/platform_node_typecheck.stamp +0 -0
- package/core/root/root.d.ts +1 -4
- package/core/root/root.js +1 -0
- package/core/sdk/sdk.d.ts +27 -97
- package/core/sdk/sdk.js +1 -0
- package/generated/protocol.js +3304 -0
- package/locales/af.json +86 -92
- package/locales/am.json +350 -356
- package/locales/ar.json +351 -357
- package/locales/as.json +349 -355
- package/locales/az.json +340 -346
- package/locales/be.json +350 -356
- package/locales/bg.json +350 -356
- package/locales/bn.json +350 -356
- package/locales/bs.json +243 -249
- package/locales/ca.json +279 -285
- package/locales/cs.json +335 -341
- package/locales/cy.json +114 -120
- package/locales/da.json +199 -205
- package/locales/de.json +219 -225
- package/locales/el.json +335 -341
- package/locales/en-GB.json +8 -14
- package/locales/en-US.json +249 -252
- package/locales/en-XL.json +1055 -0
- package/locales/es-419.json +275 -281
- package/locales/es.json +276 -282
- package/locales/et.json +231 -237
- package/locales/eu.json +119 -125
- package/locales/fa.json +350 -356
- package/locales/fi.json +280 -286
- package/locales/fil.json +1 -7
- package/locales/fr-CA.json +307 -313
- package/locales/fr.json +304 -310
- package/locales/gl.json +259 -265
- package/locales/gu.json +351 -357
- package/locales/he.json +351 -357
- package/locales/hi.json +335 -341
- package/locales/hr.json +234 -240
- package/locales/hu.json +341 -347
- package/locales/hy.json +350 -356
- package/locales/id.json +2 -8
- package/locales/is.json +302 -308
- package/locales/it.json +136 -142
- package/locales/ja.json +350 -356
- package/locales/ka.json +351 -357
- package/locales/kk.json +351 -357
- package/locales/km.json +350 -356
- package/locales/kn.json +351 -357
- package/locales/ko.json +350 -356
- package/locales/ky.json +349 -355
- package/locales/lo.json +351 -357
- package/locales/lt.json +319 -325
- package/locales/lv.json +316 -322
- package/locales/mk.json +351 -357
- package/locales/ml.json +350 -356
- package/locales/mn.json +350 -356
- package/locales/mr.json +350 -356
- package/locales/ms.json +2 -8
- package/locales/my.json +349 -355
- package/locales/ne.json +335 -341
- package/locales/nl.json +61 -67
- package/locales/no.json +169 -175
- package/locales/or.json +350 -356
- package/locales/pa.json +350 -356
- package/locales/pl.json +306 -312
- package/locales/pt-PT.json +271 -277
- package/locales/pt.json +265 -271
- package/locales/ro.json +305 -311
- package/locales/ru.json +350 -356
- package/locales/si.json +351 -357
- package/locales/sk.json +332 -338
- package/locales/sl.json +214 -220
- package/locales/sq.json +315 -321
- package/locales/sr-Latn.json +252 -258
- package/locales/sr.json +351 -357
- package/locales/sv.json +275 -281
- package/locales/sw.json +2 -8
- package/locales/ta.json +351 -357
- package/locales/te.json +349 -355
- package/locales/th.json +351 -357
- package/locales/tr.json +325 -331
- package/locales/uk.json +350 -356
- package/locales/ur.json +351 -357
- package/locales/uz.json +159 -165
- package/locales/vi.json +351 -357
- package/locales/zh-HK.json +351 -357
- package/locales/zh-TW.json +350 -356
- package/locales/zh.json +350 -356
- package/locales/zu.json +2 -8
- package/models/cpu_profile/CPUProfileDataModel.js +517 -0
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -0
- package/models/cpu_profile/ProfileTreeModel.js +90 -0
- package/models/cpu_profile/ProfileTreeModel.js.map +1 -0
- package/models/cpu_profile/bundle-tsconfig.json +59 -0
- package/models/cpu_profile/bundle-tsconfig.ref.json +27 -0
- package/models/cpu_profile/cpu_profile-tsconfig.json +63 -0
- package/models/cpu_profile/cpu_profile-tsconfig.ref.json +31 -0
- package/models/cpu_profile/cpu_profile.js +7 -0
- package/models/cpu_profile/cpu_profile.js.map +1 -0
- package/models/cpu_profile/cpu_profile_node_typecheck-tsconfig.json +60 -0
- package/models/cpu_profile/cpu_profile_node_typecheck.stamp +0 -0
- package/models/cpu_profile/foundation_unittests-tsconfig.json +63 -0
- package/models/cpu_profile/foundation_unittests-tsconfig.ref.json +30 -0
- package/models/cpu_profile/foundation_unittests_node_typecheck-tsconfig.json +59 -0
- package/models/crux-manager/crux-manager.d.ts +3 -1
- package/models/crux-manager/crux-manager.js +1 -0
- package/models/trace/EntityMapper.js +133 -0
- package/models/trace/EntityMapper.js.map +1 -0
- package/models/trace/EventsSerializer.d.ts +1 -0
- package/models/trace/EventsSerializer.js +118 -0
- package/models/trace/EventsSerializer.js.map +1 -0
- package/models/trace/LanternComputationData.js +368 -0
- package/models/trace/LanternComputationData.js.map +1 -0
- package/models/trace/ModelImpl.js +181 -0
- package/models/trace/ModelImpl.js.map +1 -0
- package/models/trace/Name.js +115 -0
- package/models/trace/Name.js.map +1 -0
- package/models/trace/Processor.js +616 -0
- package/models/trace/Processor.js.map +1 -0
- package/models/trace/Styles.d.ts +2 -2
- package/models/trace/Styles.js +836 -0
- package/models/trace/Styles.js.map +1 -0
- package/models/trace/bundle-tsconfig.json +77 -0
- package/models/trace/bundle-tsconfig.ref.json +45 -0
- package/models/trace/extras/FilmStrip.js +45 -0
- package/models/trace/extras/FilmStrip.js.map +1 -0
- package/models/trace/extras/Initiators.js +47 -0
- package/models/trace/extras/Initiators.js.map +1 -0
- package/models/trace/extras/MainThreadActivity.js +77 -0
- package/models/trace/extras/MainThreadActivity.js.map +1 -0
- package/models/trace/extras/ScriptDuplication.js +163 -0
- package/models/trace/extras/ScriptDuplication.js.map +1 -0
- package/models/trace/extras/StackTraceForEvent.js +192 -0
- package/models/trace/extras/StackTraceForEvent.js.map +1 -0
- package/models/trace/extras/ThirdParties.js +119 -0
- package/models/trace/extras/ThirdParties.js.map +1 -0
- package/models/trace/extras/TraceFilter.js +51 -0
- package/models/trace/extras/TraceFilter.js.map +1 -0
- package/models/trace/extras/TraceTree.js +652 -0
- package/models/trace/extras/TraceTree.js.map +1 -0
- package/models/trace/extras/bundle-tsconfig.json +59 -0
- package/models/trace/extras/bundle-tsconfig.ref.json +27 -0
- package/models/trace/extras/extras-tsconfig.json +81 -0
- package/models/trace/extras/extras-tsconfig.ref.json +49 -0
- package/models/trace/extras/extras.js +12 -0
- package/models/trace/extras/extras.js.map +1 -0
- package/models/trace/extras/extras_node_typecheck-tsconfig.json +78 -0
- package/models/trace/extras/extras_node_typecheck.stamp +0 -0
- package/models/trace/extras/foundation_unittests-tsconfig.json +91 -0
- package/models/trace/extras/foundation_unittests-tsconfig.ref.json +58 -0
- package/models/trace/extras/foundation_unittests_node_typecheck-tsconfig.json +87 -0
- package/models/trace/foundation_unittests-tsconfig.json +70 -0
- package/models/trace/foundation_unittests-tsconfig.ref.json +37 -0
- package/models/trace/foundation_unittests_node_typecheck-tsconfig.json +66 -0
- package/models/trace/handlers/AnimationFramesHandler.js +110 -0
- package/models/trace/handlers/AnimationFramesHandler.js.map +1 -0
- package/models/trace/handlers/AnimationHandler.js +27 -0
- package/models/trace/handlers/AnimationHandler.js.map +1 -0
- package/models/trace/handlers/AsyncJSCallsHandler.js +188 -0
- package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -0
- package/models/trace/handlers/DOMStatsHandler.js +22 -0
- package/models/trace/handlers/DOMStatsHandler.js.map +1 -0
- package/models/trace/handlers/ExtensionTraceDataHandler.js +264 -0
- package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -0
- package/models/trace/handlers/FlowsHandler.js +149 -0
- package/models/trace/handlers/FlowsHandler.js.map +1 -0
- package/models/trace/handlers/FramesHandler.js +491 -0
- package/models/trace/handlers/FramesHandler.js.map +1 -0
- package/models/trace/handlers/GPUHandler.js +36 -0
- package/models/trace/handlers/GPUHandler.js.map +1 -0
- package/models/trace/handlers/ImagePaintingHandler.js +148 -0
- package/models/trace/handlers/ImagePaintingHandler.js.map +1 -0
- package/models/trace/handlers/InitiatorsHandler.js +181 -0
- package/models/trace/handlers/InitiatorsHandler.js.map +1 -0
- package/models/trace/handlers/InvalidationsHandler.js +125 -0
- package/models/trace/handlers/InvalidationsHandler.js.map +1 -0
- package/models/trace/handlers/LargestImagePaintHandler.js +86 -0
- package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -0
- package/models/trace/handlers/LargestTextPaintHandler.js +28 -0
- package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -0
- package/models/trace/handlers/LayerTreeHandler.js +104 -0
- package/models/trace/handlers/LayerTreeHandler.js.map +1 -0
- package/models/trace/handlers/LayoutShiftsHandler.js +453 -0
- package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -0
- package/models/trace/handlers/MemoryHandler.js +22 -0
- package/models/trace/handlers/MemoryHandler.js.map +1 -0
- package/models/trace/handlers/MetaHandler.js +442 -0
- package/models/trace/handlers/MetaHandler.js.map +1 -0
- package/models/trace/handlers/ModelHandlers.js +33 -0
- package/models/trace/handlers/ModelHandlers.js.map +1 -0
- package/models/trace/handlers/NetworkRequestsHandler.js +578 -0
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -0
- package/models/trace/handlers/PageFramesHandler.js +43 -0
- package/models/trace/handlers/PageFramesHandler.js.map +1 -0
- package/models/trace/handlers/PageLoadMetricsHandler.js +463 -0
- package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -0
- package/models/trace/handlers/RendererHandler.js +346 -0
- package/models/trace/handlers/RendererHandler.js.map +1 -0
- package/models/trace/handlers/SamplesHandler.js +261 -0
- package/models/trace/handlers/SamplesHandler.js.map +1 -0
- package/models/trace/handlers/ScreenshotsHandler.js +56 -0
- package/models/trace/handlers/ScreenshotsHandler.js.map +1 -0
- package/models/trace/handlers/ScriptsHandler.js +277 -0
- package/models/trace/handlers/ScriptsHandler.js.map +1 -0
- package/models/trace/handlers/SelectorStatsHandler.js +72 -0
- package/models/trace/handlers/SelectorStatsHandler.js.map +1 -0
- package/models/trace/handlers/Threads.js +108 -0
- package/models/trace/handlers/Threads.js.map +1 -0
- package/models/trace/handlers/UserInteractionsHandler.js +319 -0
- package/models/trace/handlers/UserInteractionsHandler.js.map +1 -0
- package/models/trace/handlers/UserTimingsHandler.js +194 -0
- package/models/trace/handlers/UserTimingsHandler.js.map +1 -0
- package/models/trace/handlers/WarningsHandler.js +135 -0
- package/models/trace/handlers/WarningsHandler.js.map +1 -0
- package/models/trace/handlers/WorkersHandler.js +34 -0
- package/models/trace/handlers/WorkersHandler.js.map +1 -0
- package/models/trace/handlers/bundle-tsconfig.json +59 -0
- package/models/trace/handlers/bundle-tsconfig.ref.json +27 -0
- package/models/trace/handlers/foundation_unittests-tsconfig.json +102 -0
- package/models/trace/handlers/foundation_unittests-tsconfig.ref.json +69 -0
- package/models/trace/handlers/foundation_unittests_node_typecheck-tsconfig.json +98 -0
- package/models/trace/handlers/handlers-tsconfig.json +112 -0
- package/models/trace/handlers/handlers-tsconfig.ref.json +80 -0
- package/models/trace/handlers/handlers.js +8 -0
- package/models/trace/handlers/handlers.js.map +1 -0
- package/models/trace/handlers/handlers_node_typecheck-tsconfig.json +109 -0
- package/models/trace/handlers/handlers_node_typecheck.stamp +0 -0
- package/models/trace/handlers/helpers.js +167 -0
- package/models/trace/handlers/helpers.js.map +1 -0
- package/models/trace/handlers/types.js +2 -0
- package/models/trace/handlers/types.js.map +1 -0
- package/models/trace/helpers/Extensions.js +42 -0
- package/models/trace/helpers/Extensions.js.map +1 -0
- package/models/trace/helpers/Network.js +103 -0
- package/models/trace/helpers/Network.js.map +1 -0
- package/models/trace/helpers/SamplesIntegrator.js +527 -0
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -0
- package/models/trace/helpers/SyntheticEvents.js +96 -0
- package/models/trace/helpers/SyntheticEvents.js.map +1 -0
- package/models/trace/helpers/Timing.js +200 -0
- package/models/trace/helpers/Timing.js.map +1 -0
- package/models/trace/helpers/Trace.js +844 -0
- package/models/trace/helpers/Trace.js.map +1 -0
- package/models/trace/helpers/TreeHelpers.js +255 -0
- package/models/trace/helpers/TreeHelpers.js.map +1 -0
- package/models/trace/helpers/bundle-tsconfig.json +59 -0
- package/models/trace/helpers/bundle-tsconfig.ref.json +27 -0
- package/models/trace/helpers/foundation_unittests-tsconfig.json +73 -0
- package/models/trace/helpers/foundation_unittests-tsconfig.ref.json +40 -0
- package/models/trace/helpers/foundation_unittests_node_typecheck-tsconfig.json +69 -0
- package/models/trace/helpers/helpers-tsconfig.json +77 -0
- package/models/trace/helpers/helpers-tsconfig.ref.json +45 -0
- package/models/trace/helpers/helpers.js +11 -0
- package/models/trace/helpers/helpers.js.map +1 -0
- package/models/trace/helpers/helpers_node_typecheck-tsconfig.json +74 -0
- package/models/trace/helpers/helpers_node_typecheck.stamp +0 -0
- package/models/trace/insights/CLSCulprits.d.ts +14 -14
- package/models/trace/insights/CLSCulprits.js +519 -0
- package/models/trace/insights/CLSCulprits.js.map +1 -0
- package/models/trace/insights/Cache.d.ts +6 -6
- package/models/trace/insights/Cache.js +210 -0
- package/models/trace/insights/Cache.js.map +1 -0
- package/models/trace/insights/CharacterSet.d.ts +8 -8
- package/models/trace/insights/CharacterSet.js +132 -0
- package/models/trace/insights/CharacterSet.js.map +1 -0
- package/models/trace/insights/Common.js +367 -0
- package/models/trace/insights/Common.js.map +1 -0
- package/models/trace/insights/DOMSize.d.ts +13 -13
- package/models/trace/insights/DOMSize.js +182 -0
- package/models/trace/insights/DOMSize.js.map +1 -0
- package/models/trace/insights/DocumentLatency.d.ts +11 -11
- package/models/trace/insights/DocumentLatency.js +259 -0
- package/models/trace/insights/DocumentLatency.js.map +1 -0
- package/models/trace/insights/DuplicatedJavaScript.d.ts +5 -5
- package/models/trace/insights/DuplicatedJavaScript.js +110 -0
- package/models/trace/insights/DuplicatedJavaScript.js.map +1 -0
- package/models/trace/insights/FontDisplay.d.ts +5 -5
- package/models/trace/insights/FontDisplay.js +93 -0
- package/models/trace/insights/FontDisplay.js.map +1 -0
- package/models/trace/insights/ForcedReflow.d.ts +7 -7
- package/models/trace/insights/ForcedReflow.js +162 -0
- package/models/trace/insights/ForcedReflow.js.map +1 -0
- package/models/trace/insights/INPBreakdown.d.ts +8 -8
- package/models/trace/insights/INPBreakdown.js +130 -0
- package/models/trace/insights/INPBreakdown.js.map +1 -0
- package/models/trace/insights/ImageDelivery.d.ts +12 -12
- package/models/trace/insights/ImageDelivery.js +264 -0
- package/models/trace/insights/ImageDelivery.js.map +1 -0
- package/models/trace/insights/LCPBreakdown.d.ts +11 -11
- package/models/trace/insights/LCPBreakdown.js +200 -0
- package/models/trace/insights/LCPBreakdown.js.map +1 -0
- package/models/trace/insights/LCPDiscovery.d.ts +10 -10
- package/models/trace/insights/LCPDiscovery.js +190 -0
- package/models/trace/insights/LCPDiscovery.js.map +1 -0
- package/models/trace/insights/LegacyJavaScript.d.ts +5 -5
- package/models/trace/insights/LegacyJavaScript.js +99 -0
- package/models/trace/insights/LegacyJavaScript.js.map +1 -0
- package/models/trace/insights/Models.js +23 -0
- package/models/trace/insights/Models.js.map +1 -0
- package/models/trace/insights/ModernHTTP.d.ts +5 -5
- package/models/trace/insights/ModernHTTP.js +205 -0
- package/models/trace/insights/ModernHTTP.js.map +1 -0
- package/models/trace/insights/NetworkDependencyTree.d.ts +19 -19
- package/models/trace/insights/NetworkDependencyTree.js +551 -0
- package/models/trace/insights/NetworkDependencyTree.js.map +1 -0
- package/models/trace/insights/RenderBlocking.d.ts +5 -5
- package/models/trace/insights/RenderBlocking.js +211 -0
- package/models/trace/insights/RenderBlocking.js.map +1 -0
- package/models/trace/insights/SlowCSSSelector.d.ts +10 -10
- package/models/trace/insights/SlowCSSSelector.js +140 -0
- package/models/trace/insights/SlowCSSSelector.js.map +1 -0
- package/models/trace/insights/Statistics.js +93 -0
- package/models/trace/insights/Statistics.js.map +1 -0
- package/models/trace/insights/ThirdParties.d.ts +6 -6
- package/models/trace/insights/ThirdParties.js +110 -0
- package/models/trace/insights/ThirdParties.js.map +1 -0
- package/models/trace/insights/Viewport.d.ts +3 -3
- package/models/trace/insights/Viewport.js +105 -0
- package/models/trace/insights/Viewport.js.map +1 -0
- package/models/trace/insights/bundle-tsconfig.json +59 -0
- package/models/trace/insights/bundle-tsconfig.ref.json +27 -0
- package/models/trace/insights/foundation_unittests-tsconfig.json +98 -0
- package/models/trace/insights/foundation_unittests-tsconfig.ref.json +65 -0
- package/models/trace/insights/foundation_unittests_node_typecheck-tsconfig.json +94 -0
- package/models/trace/insights/insights-tsconfig.json +114 -0
- package/models/trace/insights/insights-tsconfig.ref.json +82 -0
- package/models/trace/insights/insights.js +10 -0
- package/models/trace/insights/insights.js.map +1 -0
- package/models/trace/insights/insights_node_typecheck-tsconfig.json +111 -0
- package/models/trace/insights/insights_node_typecheck.stamp +0 -0
- package/models/trace/insights/types.d.ts +3 -3
- package/models/trace/insights/types.js +41 -0
- package/models/trace/insights/types.js.map +1 -0
- package/models/trace/lantern/bundle-tsconfig.json +71 -0
- package/models/trace/lantern/bundle-tsconfig.ref.json +39 -0
- package/models/trace/lantern/core/LanternError.js +7 -0
- package/models/trace/lantern/core/LanternError.js.map +1 -0
- package/models/trace/lantern/core/NetworkAnalyzer.js +496 -0
- package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -0
- package/models/trace/lantern/core/bundle-tsconfig.json +59 -0
- package/models/trace/lantern/core/bundle-tsconfig.ref.json +27 -0
- package/models/trace/lantern/core/core-tsconfig.json +60 -0
- package/models/trace/lantern/core/core-tsconfig.ref.json +28 -0
- package/models/trace/lantern/core/core.js +6 -0
- package/models/trace/lantern/core/core.js.map +1 -0
- package/models/trace/lantern/core/core_node_typecheck-tsconfig.json +57 -0
- package/models/trace/lantern/core/core_node_typecheck.stamp +0 -0
- package/models/trace/lantern/core/foundation_unittests-tsconfig.json +69 -0
- package/models/trace/lantern/core/foundation_unittests-tsconfig.ref.json +36 -0
- package/models/trace/lantern/core/foundation_unittests_node_typecheck-tsconfig.json +65 -0
- package/models/trace/lantern/graph/BaseNode.d.ts +2 -2
- package/models/trace/lantern/graph/BaseNode.js +277 -0
- package/models/trace/lantern/graph/BaseNode.js.map +1 -0
- package/models/trace/lantern/graph/CPUNode.js +80 -0
- package/models/trace/lantern/graph/CPUNode.js.map +1 -0
- package/models/trace/lantern/graph/NetworkNode.js +95 -0
- package/models/trace/lantern/graph/NetworkNode.js.map +1 -0
- package/models/trace/lantern/graph/PageDependencyGraph.js +574 -0
- package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -0
- package/models/trace/lantern/graph/bundle-tsconfig.json +59 -0
- package/models/trace/lantern/graph/bundle-tsconfig.ref.json +27 -0
- package/models/trace/lantern/graph/foundation_unittests-tsconfig.json +61 -0
- package/models/trace/lantern/graph/foundation_unittests-tsconfig.ref.json +28 -0
- package/models/trace/lantern/graph/foundation_unittests_node_typecheck-tsconfig.json +57 -0
- package/models/trace/lantern/graph/graph-tsconfig.json +65 -0
- package/models/trace/lantern/graph/graph-tsconfig.ref.json +33 -0
- package/models/trace/lantern/graph/graph.js +8 -0
- package/models/trace/lantern/graph/graph.js.map +1 -0
- package/models/trace/lantern/graph/graph_node_typecheck-tsconfig.json +62 -0
- package/models/trace/lantern/graph/graph_node_typecheck.stamp +0 -0
- package/models/trace/lantern/lantern.js +10 -0
- package/models/trace/lantern/lantern.js.map +1 -0
- package/models/trace/lantern/metrics/FirstContentfulPaint.js +137 -0
- package/models/trace/lantern/metrics/FirstContentfulPaint.js.map +1 -0
- package/models/trace/lantern/metrics/Interactive.js +68 -0
- package/models/trace/lantern/metrics/Interactive.js.map +1 -0
- package/models/trace/lantern/metrics/LargestContentfulPaint.js +75 -0
- package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -0
- package/models/trace/lantern/metrics/MaxPotentialFID.js +49 -0
- package/models/trace/lantern/metrics/MaxPotentialFID.js.map +1 -0
- package/models/trace/lantern/metrics/Metric.js +69 -0
- package/models/trace/lantern/metrics/Metric.js.map +1 -0
- package/models/trace/lantern/metrics/SpeedIndex.js +102 -0
- package/models/trace/lantern/metrics/SpeedIndex.js.map +1 -0
- package/models/trace/lantern/metrics/TBTUtils.js +65 -0
- package/models/trace/lantern/metrics/TBTUtils.js.map +1 -0
- package/models/trace/lantern/metrics/TotalBlockingTime.js +79 -0
- package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -0
- package/models/trace/lantern/metrics/bundle-tsconfig.json +59 -0
- package/models/trace/lantern/metrics/bundle-tsconfig.ref.json +27 -0
- package/models/trace/lantern/metrics/foundation_unittests-tsconfig.json +76 -0
- package/models/trace/lantern/metrics/foundation_unittests-tsconfig.ref.json +43 -0
- package/models/trace/lantern/metrics/foundation_unittests_node_typecheck-tsconfig.json +72 -0
- package/models/trace/lantern/metrics/metrics-tsconfig.json +75 -0
- package/models/trace/lantern/metrics/metrics-tsconfig.ref.json +43 -0
- package/models/trace/lantern/metrics/metrics.js +12 -0
- package/models/trace/lantern/metrics/metrics.js.map +1 -0
- package/models/trace/lantern/metrics/metrics_node_typecheck-tsconfig.json +72 -0
- package/models/trace/lantern/metrics/metrics_node_typecheck.stamp +0 -0
- package/models/trace/lantern/simulation/ConnectionPool.js +116 -0
- package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -0
- package/models/trace/lantern/simulation/Constants.js +45 -0
- package/models/trace/lantern/simulation/Constants.js.map +1 -0
- package/models/trace/lantern/simulation/DNSCache.js +48 -0
- package/models/trace/lantern/simulation/DNSCache.js.map +1 -0
- package/models/trace/lantern/simulation/SimulationTimingMap.js +135 -0
- package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -0
- package/models/trace/lantern/simulation/Simulator.js +457 -0
- package/models/trace/lantern/simulation/Simulator.js.map +1 -0
- package/models/trace/lantern/simulation/TCPConnection.js +155 -0
- package/models/trace/lantern/simulation/TCPConnection.js.map +1 -0
- package/models/trace/lantern/simulation/bundle-tsconfig.json +59 -0
- package/models/trace/lantern/simulation/bundle-tsconfig.ref.json +27 -0
- package/models/trace/lantern/simulation/foundation_unittests-tsconfig.json +75 -0
- package/models/trace/lantern/simulation/foundation_unittests-tsconfig.ref.json +42 -0
- package/models/trace/lantern/simulation/foundation_unittests_node_typecheck-tsconfig.json +71 -0
- package/models/trace/lantern/simulation/simulation-tsconfig.json +70 -0
- package/models/trace/lantern/simulation/simulation-tsconfig.ref.json +38 -0
- package/models/trace/lantern/simulation/simulation.js +10 -0
- package/models/trace/lantern/simulation/simulation.js.map +1 -0
- package/models/trace/lantern/simulation/simulation_node_typecheck-tsconfig.json +67 -0
- package/models/trace/lantern/simulation/simulation_node_typecheck.stamp +0 -0
- package/models/trace/lantern/testing/bundle-tsconfig.json +60 -0
- package/models/trace/lantern/testing/bundle-tsconfig.ref.json +27 -0
- package/models/trace/lantern/testing/testing-tsconfig.json +63 -0
- package/models/trace/lantern/testing/testing-tsconfig.ref.json +30 -0
- package/models/trace/lantern/types/Lantern.d.ts +19 -19
- package/models/trace/lantern/types/Lantern.js +25 -0
- package/models/trace/lantern/types/Lantern.js.map +1 -0
- package/models/trace/lantern/types/bundle-tsconfig.json +59 -0
- package/models/trace/lantern/types/bundle-tsconfig.ref.json +27 -0
- package/models/trace/lantern/types/types-tsconfig.json +59 -0
- package/models/trace/lantern/types/types-tsconfig.ref.json +27 -0
- package/models/trace/lantern/types/types.js +5 -0
- package/models/trace/lantern/types/types.js.map +1 -0
- package/models/trace/lantern/types/types_node_typecheck-tsconfig.json +56 -0
- package/models/trace/lantern/types/types_node_typecheck.stamp +0 -0
- package/models/trace/trace-tsconfig.json +89 -0
- package/models/trace/trace-tsconfig.ref.json +57 -0
- package/models/trace/trace.js +16 -544
- package/models/trace/trace.js.map +1 -0
- package/models/trace/trace_node_typecheck-tsconfig.json +86 -0
- package/models/trace/trace_node_typecheck.stamp +0 -0
- package/models/trace/types/Configuration.d.ts +2 -2
- package/models/trace/types/Configuration.js +19 -0
- package/models/trace/types/Configuration.js.map +1 -0
- package/models/trace/types/Extensions.d.ts +1 -1
- package/models/trace/types/Extensions.js +38 -0
- package/models/trace/types/Extensions.js.map +1 -0
- package/models/trace/types/File.d.ts +9 -3
- package/models/trace/types/File.js +92 -0
- package/models/trace/types/File.js.map +1 -0
- package/models/trace/types/Overlays.js +5 -0
- package/models/trace/types/Overlays.js.map +1 -0
- package/models/trace/types/Timing.js +16 -0
- package/models/trace/types/Timing.js.map +1 -0
- package/models/trace/types/TraceEvents.d.ts +21 -16
- package/models/trace/types/TraceEvents.js +983 -0
- package/models/trace/types/TraceEvents.js.map +1 -0
- package/models/trace/types/bundle-tsconfig.json +59 -0
- package/models/trace/types/bundle-tsconfig.ref.json +27 -0
- package/models/trace/types/foundation_unittests-tsconfig.json +67 -0
- package/models/trace/types/foundation_unittests-tsconfig.ref.json +34 -0
- package/models/trace/types/foundation_unittests_node_typecheck-tsconfig.json +63 -0
- package/models/trace/types/types-tsconfig.json +76 -0
- package/models/trace/types/types-tsconfig.ref.json +44 -0
- package/models/trace/types/types.js +10 -0
- package/models/trace/types/types.js.map +1 -0
- package/models/trace/types/types_node_typecheck-tsconfig.json +73 -0
- package/models/trace/types/types_node_typecheck.stamp +0 -0
- package/package.json +8 -40
- package/test/invalid-animation-events.json.gz +0 -0
- package/test/test-trace-engine.mjs +191 -0
- package/third_party/legacy-javascript/bundle-tsconfig.json +59 -0
- package/third_party/legacy-javascript/bundle-tsconfig.ref.json +27 -0
- package/third_party/legacy-javascript/legacy-javascript-tsconfig.ref.json +15 -0
- package/third_party/legacy-javascript/legacy-javascript.js +3 -0
- package/third_party/legacy-javascript/legacy-javascript.js.map +1 -0
- package/third_party/legacy-javascript/lib/legacy-javascript.js +1119 -0
- package/third_party/marked/marked.d.ts +1 -2
- package/third_party/marked/marked.js +1 -0
- package/third_party/third-party-web/third-party-web.d.ts +1 -2
- package/third_party/third-party-web/third-party-web.js +1 -0
- package/tsconfig.json +29 -0
- package/core/common/Base64.d.ts +0 -12
- package/core/common/CharacterIdMap.d.ts +0 -5
- package/core/common/Color.d.ts +0 -357
- package/core/common/ColorConverter.d.ts +0 -26
- package/core/common/ColorUtils.d.ts +0 -45
- package/core/common/Console.d.ts +0 -54
- package/core/common/Debouncer.d.ts +0 -8
- package/core/common/EventTarget.d.ts +0 -22
- package/core/common/Gzip.d.ts +0 -23
- package/core/common/JavaScriptMetaData.d.ts +0 -20
- package/core/common/Lazy.d.ts +0 -4
- package/core/common/MapWithDefault.d.ts +0 -9
- package/core/common/Mutex.d.ts +0 -13
- package/core/common/Object.d.ts +0 -20
- package/core/common/Progress.d.ts +0 -47
- package/core/common/ResolverBase.d.ts +0 -29
- package/core/common/ResourceType.d.ts +0 -52
- package/core/common/ReturnToPanel.d.ts +0 -10
- package/core/common/Revealer.d.ts +0 -66
- package/core/common/Runnable.d.ts +0 -14
- package/core/common/SegmentedRange.d.ts +0 -14
- package/core/common/SettingRegistration.d.ts +0 -136
- package/core/common/Settings.d.ts +0 -228
- package/core/common/SimpleHistoryManager.d.ts +0 -20
- package/core/common/Srcset.d.ts +0 -16
- package/core/common/StringOutputStream.d.ts +0 -10
- package/core/common/TextDictionary.d.ts +0 -11
- package/core/common/Throttler.d.ts +0 -12
- package/core/common/Trie.d.ts +0 -24
- package/core/common/VersionController.d.ts +0 -85
- package/core/host/AidaClient.d.ts +0 -73
- package/core/host/AidaClientTypes.d.ts +0 -355
- package/core/host/AidaGcaTranslation.d.ts +0 -10
- package/core/host/DispatchHttpRequestClient.d.ts +0 -14
- package/core/host/GcaClient.d.ts +0 -14
- package/core/host/GcaTypes.d.ts +0 -411
- package/core/host/GdpClient.d.ts +0 -84
- package/core/host/InspectorFrontendHost.d.ts +0 -29
- package/core/host/InspectorFrontendHostAPI.d.ts +0 -425
- package/core/host/InspectorFrontendHostStub.d.ts +0 -151
- package/core/host/Platform.d.ts +0 -16
- package/core/host/ResourceLoader.d.ts +0 -15
- package/core/host/UserMetrics.d.ts +0 -116
- package/core/host/UserMetricsEnums.d.ts +0 -888
- package/core/i18n/ByteUtilities.d.ts +0 -11
- package/core/i18n/DevToolsLocale.d.ts +0 -41
- package/core/i18n/NumberFormatter.d.ts +0 -11
- package/core/i18n/i18nImpl.d.ts +0 -64
- package/core/i18n/i18nTypes.d.ts +0 -5
- package/core/i18n/locales.d.ts +0 -15
- package/core/i18n/time-utilities.d.ts +0 -16
- package/core/platform/browser/HostRuntime.d.ts +0 -2
- package/core/platform/browser/browser.d.ts +0 -2
- package/core/platform/node/HostRuntime.d.ts +0 -2
- package/core/platform/node/node.d.ts +0 -2
- package/core/protocol_client/CDPConnection.d.ts +0 -77
- package/core/protocol_client/ConnectionTransport.d.ts +0 -9
- package/core/protocol_client/DevToolsCDPConnection.d.ts +0 -16
- package/core/protocol_client/InspectorBackend.d.ts +0 -223
- package/core/protocol_client/protocol_client.d.ts +0 -5
- package/core/root/DevToolsContext.d.ts +0 -34
- package/core/root/ExperimentNames.d.ts +0 -9
- package/core/root/Runtime.d.ts +0 -353
- package/core/sdk/AccessibilityModel.d.ts +0 -76
- package/core/sdk/AnimationModel.d.ts +0 -161
- package/core/sdk/AutofillModel.d.ts +0 -23
- package/core/sdk/CPUProfilerModel.d.ts +0 -46
- package/core/sdk/CPUThrottlingManager.d.ts +0 -47
- package/core/sdk/CSSContainerQuery.d.ts +0 -42
- package/core/sdk/CSSFontFace.d.ts +0 -10
- package/core/sdk/CSSLayer.d.ts +0 -9
- package/core/sdk/CSSLocation.d.ts +0 -14
- package/core/sdk/CSSMatchedStyles.d.ts +0 -138
- package/core/sdk/CSSMedia.d.ts +0 -36
- package/core/sdk/CSSMetadata.d.ts +0 -87
- package/core/sdk/CSSModel.d.ts +0 -185
- package/core/sdk/CSSNavigation.d.ts +0 -10
- package/core/sdk/CSSProperty.d.ts +0 -53
- package/core/sdk/CSSPropertyParser.d.ts +0 -126
- package/core/sdk/CSSPropertyParserMatchers.d.ts +0 -442
- package/core/sdk/CSSQuery.d.ts +0 -22
- package/core/sdk/CSSRule.d.ts +0 -132
- package/core/sdk/CSSScope.d.ts +0 -9
- package/core/sdk/CSSStartingStyle.d.ts +0 -9
- package/core/sdk/CSSStyleDeclaration.d.ts +0 -38
- package/core/sdk/CSSStyleSheetHeader.d.ts +0 -53
- package/core/sdk/CSSSupports.d.ts +0 -10
- package/core/sdk/CategorizedBreakpoint.d.ts +0 -42
- package/core/sdk/ChildTargetManager.d.ts +0 -40
- package/core/sdk/CompilerSourceMappingContentProvider.d.ts +0 -12
- package/core/sdk/Connections.d.ts +0 -36
- package/core/sdk/ConsoleModel.d.ts +0 -127
- package/core/sdk/ConsoleModelTypes.d.ts +0 -6
- package/core/sdk/Cookie.d.ts +0 -68
- package/core/sdk/CookieModel.d.ts +0 -31
- package/core/sdk/CookieParser.d.ts +0 -14
- package/core/sdk/CrashReportContextModel.d.ts +0 -8
- package/core/sdk/DOMDebuggerModel.d.ts +0 -127
- package/core/sdk/DOMModel.d.ts +0 -440
- package/core/sdk/DOMStorageModel.d.ts +0 -79
- package/core/sdk/DebuggerModel.d.ts +0 -305
- package/core/sdk/EmulationModel.d.ts +0 -95
- package/core/sdk/EnhancedTracesParser.d.ts +0 -105
- package/core/sdk/EventBreakpointsModel.d.ts +0 -66
- package/core/sdk/FrameAssociated.d.ts +0 -6
- package/core/sdk/FrameManager.d.ts +0 -68
- package/core/sdk/HeapProfilerModel.d.ts +0 -75
- package/core/sdk/HttpReasonPhraseStrings.d.ts +0 -5
- package/core/sdk/IOModel.d.ts +0 -10
- package/core/sdk/IsolateManager.d.ts +0 -53
- package/core/sdk/IssuesModel.d.ts +0 -28
- package/core/sdk/LayerTreeBase.d.ts +0 -70
- package/core/sdk/LogModel.d.ts +0 -20
- package/core/sdk/NetworkManager.d.ts +0 -418
- package/core/sdk/NetworkRequest.d.ts +0 -497
- package/core/sdk/NetworkRequestAccess.d.ts +0 -91
- package/core/sdk/OverlayColorGenerator.d.ts +0 -14
- package/core/sdk/OverlayModel.d.ts +0 -186
- package/core/sdk/OverlayPersistentHighlighter.d.ts +0 -116
- package/core/sdk/PageFunctions.d.ts +0 -22
- package/core/sdk/PageLoad.d.ts +0 -14
- package/core/sdk/PageResourceLoader.d.ts +0 -111
- package/core/sdk/PaintProfiler.d.ts +0 -43
- package/core/sdk/PerformanceMetricsModel.d.ts +0 -12
- package/core/sdk/PreloadingModel.d.ts +0 -146
- package/core/sdk/RehydratingConnection.d.ts +0 -73
- package/core/sdk/RehydratingObject.d.ts +0 -59
- package/core/sdk/RemoteObject.d.ts +0 -210
- package/core/sdk/Resource.d.ts +0 -36
- package/core/sdk/ResourceTreeModel.d.ts +0 -280
- package/core/sdk/RuntimeModel.d.ts +0 -164
- package/core/sdk/SDKModel.d.ts +0 -30
- package/core/sdk/SDKSettings.d.ts +0 -54
- package/core/sdk/ScopeTreeCache.d.ts +0 -21
- package/core/sdk/ScreenCaptureModel.d.ts +0 -69
- package/core/sdk/Script.d.ts +0 -134
- package/core/sdk/SecurityOrigin.d.ts +0 -108
- package/core/sdk/SecurityOriginManager.d.ts +0 -23
- package/core/sdk/ServerSentEvents.d.ts +0 -18
- package/core/sdk/ServerSentEventsProtocol.d.ts +0 -18
- package/core/sdk/ServerTiming.d.ts +0 -24
- package/core/sdk/ServiceWorkerCacheModel.d.ts +0 -71
- package/core/sdk/ServiceWorkerManager.d.ts +0 -125
- package/core/sdk/SourceMap.d.ts +0 -211
- package/core/sdk/SourceMapCache.d.ts +0 -12
- package/core/sdk/SourceMapFunctionRanges.d.ts +0 -23
- package/core/sdk/SourceMapManager.d.ts +0 -46
- package/core/sdk/SourceMapRangeMappings.d.ts +0 -15
- package/core/sdk/SourceMapScopeChainEntry.d.ts +0 -23
- package/core/sdk/SourceMapScopesInfo.d.ts +0 -184
- package/core/sdk/StorageBucketsModel.d.ts +0 -48
- package/core/sdk/StorageKeyManager.d.ts +0 -38
- package/core/sdk/Target.d.ts +0 -79
- package/core/sdk/TargetManager.d.ts +0 -92
- package/core/sdk/TraceObject.d.ts +0 -43
- package/core/sdk/WebAuthnModel.d.ts +0 -29
- package/core/text_utils/CodeMirrorUtils.d.ts +0 -3
- package/core/text_utils/ContentData.d.ts +0 -94
- package/core/text_utils/ContentProvider.d.ts +0 -42
- package/core/text_utils/Markdown.d.ts +0 -13
- package/core/text_utils/StaticContentProvider.d.ts +0 -13
- package/core/text_utils/StreamingContentData.d.ts +0 -49
- package/core/text_utils/Text.d.ts +0 -19
- package/core/text_utils/TextCursor.d.ts +0 -9
- package/core/text_utils/TextRange.d.ts +0 -81
- package/core/text_utils/TextUtils.d.ts +0 -97
- package/core/text_utils/WasmDisassembly.d.ts +0 -29
- package/core/text_utils/text_utils.d.ts +0 -12
- package/entrypoints/formatter_actions/formatter_actions.d.ts +0 -65
- package/generated/InspectorBackendCommands.d.ts +0 -14
- package/generated/SupportedCSSProperties.d.ts +0 -18
- package/generated/protocol-mapping.d.ts +0 -5985
- package/generated/protocol-proxy-api.d.ts +0 -5447
- package/index.d.ts +0 -2
- package/index.js +0 -6
- package/models/crux-manager/CrUXManager.d.ts +0 -107
- package/models/emulation/DeviceModeModel.d.ts +0 -157
- package/models/emulation/EmulatedDevices.d.ts +0 -148
- package/models/emulation/emulation.d.ts +0 -3
- package/models/formatter/FormatterWorkerPool.d.ts +0 -58
- package/models/formatter/ScriptFormatter.d.ts +0 -11
- package/models/formatter/formatter.d.ts +0 -3
- package/third_party/codemirror.next/codemirror.next.d.ts +0 -9196
- package/third_party/i18n/i18n-impl.d.ts +0 -25
- package/third_party/i18n/i18n.d.ts +0 -3
- package/third_party/i18n/localized-string-set.d.ts +0 -49
- package/third_party/intl-messageformat/intl-messageformat.d.ts +0 -1
- package/third_party/marked/package/lib/marked.esm.d.ts +0 -760
- package/third_party/source-map-scopes-codec/package/src/builder/builder.d.ts +0 -70
- package/third_party/source-map-scopes-codec/package/src/builder/safe_builder.d.ts +0 -40
- package/third_party/source-map-scopes-codec/package/src/codec.d.ts +0 -49
- package/third_party/source-map-scopes-codec/package/src/decode/decode.d.ts +0 -33
- package/third_party/source-map-scopes-codec/package/src/encode/encode.d.ts +0 -8
- package/third_party/source-map-scopes-codec/package/src/encode/encoder.d.ts +0 -9
- package/third_party/source-map-scopes-codec/package/src/mod.d.ts +0 -5
- package/third_party/source-map-scopes-codec/package/src/scopes.d.ts +0 -169
- package/third_party/source-map-scopes-codec/package/src/util.d.ts +0 -5
- package/third_party/source-map-scopes-codec/package/src/vlq.d.ts +0 -14
- package/third_party/source-map-scopes-codec/source-map-scopes-codec.d.ts +0 -1
- package/third_party/third-party-web/lib/nostats-subset.d.ts +0 -2
- package/third_party/third-party-web/package/lib/index.d.ts +0 -34
- package/third_party/third-party-web/package/lib/subsets/nostats.d.ts +0 -1
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
// Copyright 2023 The Chromium Authors
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
var _a;
|
|
5
|
+
import * as Types from '../types/types.js';
|
|
6
|
+
import { milliToMicro } from './Timing.js';
|
|
7
|
+
import { extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace } from './Trace.js';
|
|
8
|
+
/**
|
|
9
|
+
* This is a helper that integrates CPU profiling data coming in the
|
|
10
|
+
* shape of samples, with trace events. Samples indicate what the JS
|
|
11
|
+
* stack trace looked at a given point in time, but they don't have
|
|
12
|
+
* duration. The SamplesIntegrator task is to make an approximation
|
|
13
|
+
* of what the duration of each JS call was, given the sample data and
|
|
14
|
+
* given the trace events profiled during that time. At the end of its
|
|
15
|
+
* execution, the SamplesIntegrator returns an array of ProfileCalls
|
|
16
|
+
* (under SamplesIntegrator::buildProfileCalls()), which
|
|
17
|
+
* represent JS calls, with a call frame and duration. These calls have
|
|
18
|
+
* the shape of a complete trace events and can be treated as flame
|
|
19
|
+
* chart entries in the timeline.
|
|
20
|
+
*
|
|
21
|
+
* The approach to build the profile calls consists in tracking the
|
|
22
|
+
* current stack as the following events happen (in order):
|
|
23
|
+
* 1. A sample was done.
|
|
24
|
+
* 2. A trace event started.
|
|
25
|
+
* 3. A trace event ended.
|
|
26
|
+
* Depending on the event and on the data that's coming with it the
|
|
27
|
+
* stack is updated by adding or removing JS calls to it and updating
|
|
28
|
+
* the duration of the calls in the tracking stack.
|
|
29
|
+
*
|
|
30
|
+
* note: Although this approach has been implemented since long ago, and
|
|
31
|
+
* is relatively efficient (adds a complexity over the trace parsing of
|
|
32
|
+
* O(n) where n is the number of samples) it has proven to be faulty.
|
|
33
|
+
* It might be worthwhile experimenting with improvements or with a
|
|
34
|
+
* completely different approach. Improving the approach is tracked in
|
|
35
|
+
* crbug.com/1417439
|
|
36
|
+
*/
|
|
37
|
+
export class SamplesIntegrator {
|
|
38
|
+
/**
|
|
39
|
+
* The result of running the samples integrator. Holds the JS calls
|
|
40
|
+
* with their approximated duration after integrating samples into the
|
|
41
|
+
* trace event tree.
|
|
42
|
+
*/
|
|
43
|
+
#constructedProfileCalls = [];
|
|
44
|
+
/**
|
|
45
|
+
* tracks the state of the JS stack at each point in time to update
|
|
46
|
+
* the profile call durations as new events arrive. This doesn't only
|
|
47
|
+
* happen with new profile calls (in which case we would compare the
|
|
48
|
+
* stack in them) but also with trace events (in which case we would
|
|
49
|
+
* update the duration of the events we are tracking at the moment).
|
|
50
|
+
*/
|
|
51
|
+
#currentJSStack = [];
|
|
52
|
+
/**
|
|
53
|
+
* Process holding the CPU profile and trace events.
|
|
54
|
+
*/
|
|
55
|
+
#processId;
|
|
56
|
+
/**
|
|
57
|
+
* Thread holding the CPU profile and trace events.
|
|
58
|
+
*/
|
|
59
|
+
#threadId;
|
|
60
|
+
/**
|
|
61
|
+
* Tracks the depth of the JS stack at the moment a trace event starts
|
|
62
|
+
* or ends. It is assumed that for the duration of a trace event, the
|
|
63
|
+
* JS stack's depth cannot decrease, since JS calls that started
|
|
64
|
+
* before a trace event cannot end during the trace event. So as trace
|
|
65
|
+
* events arrive, we store the "locked" amount of JS frames that were
|
|
66
|
+
* in the stack before the event came.
|
|
67
|
+
*/
|
|
68
|
+
#lockedJsStackDepth = [];
|
|
69
|
+
/**
|
|
70
|
+
* Used to keep track when samples should be integrated even if they
|
|
71
|
+
* are not children of invocation trace events. This is used in two cases:
|
|
72
|
+
* 1. We start tracing half-way through, so we miss the start of JS
|
|
73
|
+
* invocation events.
|
|
74
|
+
* 2. On threads (like Web Workers) without real JS invocation parent events,
|
|
75
|
+
* but where trace events (like SchedulePostMessage) integrate stack traces.
|
|
76
|
+
* Enabling fake JS mode allows subsequent samples to be processed and
|
|
77
|
+
* eventually correct the stack, preventing a deadlock.
|
|
78
|
+
*/
|
|
79
|
+
#fakeJSInvocation = false;
|
|
80
|
+
/**
|
|
81
|
+
* The parsed CPU profile, holding the tree hierarchy of JS frames and
|
|
82
|
+
* the sample data.
|
|
83
|
+
*/
|
|
84
|
+
#profileModel;
|
|
85
|
+
/**
|
|
86
|
+
* Because GC nodes don't have a stack, we artificially add a stack to
|
|
87
|
+
* them which corresponds to that of the previous sample. This map
|
|
88
|
+
* tracks which node is used for the stack of a GC call.
|
|
89
|
+
* Note that GC samples are not shown in the flamechart, however they
|
|
90
|
+
* are used during the construction of for profile calls, as we can
|
|
91
|
+
* infer information about the duration of the executed code when a
|
|
92
|
+
* GC node is sampled.
|
|
93
|
+
*/
|
|
94
|
+
#nodeForGC = new Map();
|
|
95
|
+
#engineConfig;
|
|
96
|
+
#profileId;
|
|
97
|
+
/**
|
|
98
|
+
* Keeps track of the individual samples from the CPU Profile.
|
|
99
|
+
* Only used with Debug Mode experiment enabled.
|
|
100
|
+
*/
|
|
101
|
+
jsSampleEvents = [];
|
|
102
|
+
constructor(profileModel, profileId, pid, tid, configuration) {
|
|
103
|
+
this.#profileModel = profileModel;
|
|
104
|
+
this.#threadId = tid;
|
|
105
|
+
this.#processId = pid;
|
|
106
|
+
this.#engineConfig = configuration || Types.Configuration.defaults();
|
|
107
|
+
this.#profileId = profileId;
|
|
108
|
+
}
|
|
109
|
+
buildProfileCalls(traceEvents) {
|
|
110
|
+
const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());
|
|
111
|
+
const stack = [];
|
|
112
|
+
for (let i = 0; i < mergedEvents.length; i++) {
|
|
113
|
+
const event = mergedEvents[i];
|
|
114
|
+
// Because instant trace events have no duration, they don't provide
|
|
115
|
+
// useful information for possible changes in the duration of calls
|
|
116
|
+
// in the JS stack.
|
|
117
|
+
if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (stack.length === 0) {
|
|
121
|
+
if (Types.Events.isProfileCall(event)) {
|
|
122
|
+
this.#onProfileCall(event);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
stack.push(event);
|
|
126
|
+
this.#onTraceEventStart(event);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const parentEvent = stack.at(-1);
|
|
130
|
+
if (parentEvent === undefined) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const begin = event.ts;
|
|
134
|
+
const parentBegin = parentEvent.ts;
|
|
135
|
+
const parentDuration = parentEvent.dur || 0;
|
|
136
|
+
const parentEnd = parentBegin + parentDuration;
|
|
137
|
+
const startsAfterParent = begin >= parentEnd;
|
|
138
|
+
if (startsAfterParent) {
|
|
139
|
+
this.#onTraceEventEnd(parentEvent);
|
|
140
|
+
stack.pop();
|
|
141
|
+
i--;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (Types.Events.isProfileCall(event)) {
|
|
145
|
+
this.#onProfileCall(event, parentEvent);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
this.#onTraceEventStart(event, parentEvent);
|
|
149
|
+
stack.push(event);
|
|
150
|
+
}
|
|
151
|
+
while (stack.length) {
|
|
152
|
+
const last = stack.pop();
|
|
153
|
+
if (last) {
|
|
154
|
+
this.#onTraceEventEnd(last);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
sortTraceEventsInPlace(this.jsSampleEvents);
|
|
158
|
+
return this.#constructedProfileCalls;
|
|
159
|
+
}
|
|
160
|
+
#onTraceEventStart(event, parent) {
|
|
161
|
+
// Top level events cannot be nested into JS frames so we reset
|
|
162
|
+
// the stack when we find one.
|
|
163
|
+
if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {
|
|
164
|
+
this.#lockedJsStackDepth = [];
|
|
165
|
+
this.#truncateJSStack(0, event.ts);
|
|
166
|
+
this.#fakeJSInvocation = false;
|
|
167
|
+
}
|
|
168
|
+
if (this.#fakeJSInvocation) {
|
|
169
|
+
this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);
|
|
170
|
+
this.#fakeJSInvocation = false;
|
|
171
|
+
}
|
|
172
|
+
this.#extractStackTrace(event);
|
|
173
|
+
if (extractSampleTraceId(event)) {
|
|
174
|
+
const hasJSInvocationParent = parent && Types.Events.isJSInvocationEvent(parent);
|
|
175
|
+
if (!hasJSInvocationParent) {
|
|
176
|
+
// If the event has a sampleTraceId (meaning it has a stack trace) but
|
|
177
|
+
// no JS invocation parent, we enter fake JS mode. This ensures that
|
|
178
|
+
// subsequent samples on this thread are processed, allowing the stack
|
|
179
|
+
// to be correctly updated/truncated. Without this, subsequent samples
|
|
180
|
+
// would be ignored because the stack is non-empty but we are not
|
|
181
|
+
// considered to be in JS.
|
|
182
|
+
this.#fakeJSInvocation = true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Keep track of the call frames in the stack before the event
|
|
186
|
+
// happened. For the duration of this event, these frames cannot
|
|
187
|
+
// change (none can be terminated before this event finishes).
|
|
188
|
+
//
|
|
189
|
+
// Also, every frame that is opened after this event, is considered
|
|
190
|
+
// to be a descendant of the event. So once the event finishes, the
|
|
191
|
+
// frames that were opened after it, need to be closed (see
|
|
192
|
+
// onEndEvent).
|
|
193
|
+
//
|
|
194
|
+
// TODO(crbug.com/1417439):
|
|
195
|
+
// The assumption that every frame opened after an event is a
|
|
196
|
+
// descendant of the event is incorrect. For example, a JS call that
|
|
197
|
+
// parents a trace event might have been sampled after the event was
|
|
198
|
+
// dispatched. In this case the JS call would be discarded if this
|
|
199
|
+
// event isn't an invocation event, otherwise the call will be
|
|
200
|
+
// considered a child of the event. In both cases, the result would
|
|
201
|
+
// be incorrect.
|
|
202
|
+
this.#lockedJsStackDepth.push(this.#currentJSStack.length);
|
|
203
|
+
}
|
|
204
|
+
#onProfileCall(event, parent) {
|
|
205
|
+
if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {
|
|
206
|
+
this.#extractStackTrace(event);
|
|
207
|
+
}
|
|
208
|
+
else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {
|
|
209
|
+
// Force JS Samples to show up even if we are not inside a JS
|
|
210
|
+
// invocation event, because we can be missing the start of JS
|
|
211
|
+
// invocation events if we start tracing half-way through. Pretend
|
|
212
|
+
// we have a top-level JS invocation event.
|
|
213
|
+
this.#fakeJSInvocation = true;
|
|
214
|
+
const stackDepthBefore = this.#currentJSStack.length;
|
|
215
|
+
this.#extractStackTrace(event);
|
|
216
|
+
this.#lockedJsStackDepth.push(stackDepthBefore);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
#onTraceEventEnd(event) {
|
|
220
|
+
// Because the event has ended, any frames that happened after
|
|
221
|
+
// this event are terminated. Frames that are ancestors to this
|
|
222
|
+
// event are extended to cover its ending.
|
|
223
|
+
const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));
|
|
224
|
+
this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Builds the initial calls with no duration from samples. Their
|
|
228
|
+
* purpose is to be merged with the trace event array being parsed so
|
|
229
|
+
* that they can be traversed in order with them and their duration
|
|
230
|
+
* can be updated as the SampleIntegrator callbacks are invoked.
|
|
231
|
+
*/
|
|
232
|
+
callsFromProfileSamples() {
|
|
233
|
+
const samples = this.#profileModel.samples;
|
|
234
|
+
const timestamps = this.#profileModel.timestamps;
|
|
235
|
+
if (!samples) {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
const calls = [];
|
|
239
|
+
let prevNode;
|
|
240
|
+
for (let i = 0; i < samples.length; i++) {
|
|
241
|
+
const node = this.#profileModel.nodeByIndex(i);
|
|
242
|
+
const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));
|
|
243
|
+
if (!node) {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);
|
|
247
|
+
calls.push(call);
|
|
248
|
+
if (this.#engineConfig.debugMode) {
|
|
249
|
+
const traceId = this.#profileModel.traceIds?.[i];
|
|
250
|
+
this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));
|
|
251
|
+
}
|
|
252
|
+
if (node.id === this.#profileModel.gcNode?.id && prevNode) {
|
|
253
|
+
// GC samples have no stack, so we just put GC node on top of the
|
|
254
|
+
// last recorded sample. Cache the previous sample for future
|
|
255
|
+
// reference.
|
|
256
|
+
this.#nodeForGC.set(call, prevNode);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
prevNode = node;
|
|
260
|
+
}
|
|
261
|
+
return calls;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Given a synthetic profile call, returns the profile nodes of the
|
|
265
|
+
* stack trace that profile call belongs to based on its nodeId,
|
|
266
|
+
* ordered from the bottom of the stack to the top. The root node is
|
|
267
|
+
* omitted. The node of the input profile call will be at the top of
|
|
268
|
+
* the returned stack (last position), meaning that any other frames
|
|
269
|
+
* that were effectively above it are omitted.
|
|
270
|
+
*/
|
|
271
|
+
#stackNodesForProfileCall(profileCall) {
|
|
272
|
+
const sampledNode = this.#profileModel.nodeById(profileCall.nodeId);
|
|
273
|
+
let node = sampledNode;
|
|
274
|
+
const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;
|
|
275
|
+
if (isGarbageCollection) {
|
|
276
|
+
// Because GC don't have a stack, we use the stack of the previous
|
|
277
|
+
// sample.
|
|
278
|
+
node = this.#nodeForGC.get(profileCall) || null;
|
|
279
|
+
}
|
|
280
|
+
if (!sampledNode || !node) {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
// `node.depth` is 0 based, so to set the size of the array we need
|
|
284
|
+
// to add 1 to its value.
|
|
285
|
+
const nodes = new Array(node.depth + 1 + Number(isGarbageCollection));
|
|
286
|
+
// Add the stack trace in reverse order (bottom first).
|
|
287
|
+
let i = nodes.length - 1;
|
|
288
|
+
if (isGarbageCollection) {
|
|
289
|
+
// Place the garbage collection node on top of the stack.
|
|
290
|
+
nodes[i--] = sampledNode;
|
|
291
|
+
}
|
|
292
|
+
// The root node has a depth of -1, so the loop stops before it.
|
|
293
|
+
while (node && i >= 0) {
|
|
294
|
+
nodes[i--] = node;
|
|
295
|
+
node = node.parent;
|
|
296
|
+
}
|
|
297
|
+
return nodes;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Returns a profile call for the node sampled with the given trace id,
|
|
301
|
+
* or null if the profile has no node for it.
|
|
302
|
+
*/
|
|
303
|
+
#callForSampleTraceId(traceId, timestamp) {
|
|
304
|
+
const nodeId = this.#profileModel.traceIds?.[traceId];
|
|
305
|
+
const node = nodeId && this.#profileModel.nodeById(nodeId);
|
|
306
|
+
if (!node) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
const callForTraceId = makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);
|
|
310
|
+
if (this.#engineConfig.debugMode) {
|
|
311
|
+
this.jsSampleEvents.push(this.#makeJSSampleEvent(callForTraceId, timestamp, traceId));
|
|
312
|
+
}
|
|
313
|
+
return callForTraceId;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Update tracked stack using this event's call stack.
|
|
317
|
+
*/
|
|
318
|
+
#extractStackTrace(event) {
|
|
319
|
+
const traceId = extractSampleTraceId(event);
|
|
320
|
+
const callForTraceId = traceId ? this.#callForSampleTraceId(traceId, event.ts) : null;
|
|
321
|
+
const stackSource = callForTraceId ?? (Types.Events.isProfileCall(event) ? event : null);
|
|
322
|
+
if (!stackSource) {
|
|
323
|
+
// The event carries no stack of its own, so merging the tracked
|
|
324
|
+
// stack with itself only updates the durations of its frames.
|
|
325
|
+
this.#mergeWithCurrentStack(event, this.#currentJSStack);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const stackNodes = this.#stackNodesForProfileCall(stackSource);
|
|
329
|
+
let i = this.#mergeWithCurrentStack(event, stackNodes);
|
|
330
|
+
for (; i < stackNodes.length; ++i) {
|
|
331
|
+
const node = stackNodes[i];
|
|
332
|
+
if (node.id === this.#profileModel.programNode?.id || node.id === this.#profileModel.root?.id ||
|
|
333
|
+
node.id === this.#profileModel.idleNode?.id || node.id === this.#profileModel.gcNode?.id) {
|
|
334
|
+
// Skip (root), (program) and (idle) frames, since this are not
|
|
335
|
+
// relevant for web profiling and we don't want to show them in
|
|
336
|
+
// the timeline.
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
// Profile calls are only created for the frames that are added to
|
|
340
|
+
// the tracked stack, rather than for every frame of every sample.
|
|
341
|
+
const call = makeProfileCall(node, stackSource.profileId, stackSource.sampleIndex, stackSource.ts, this.#processId, this.#threadId);
|
|
342
|
+
this.#currentJSStack.push(call);
|
|
343
|
+
this.#constructedProfileCalls.push(call);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Merges the given stack with the tracked stack: the durations of
|
|
348
|
+
* the shared frames are extended to cover the event, and the tracked
|
|
349
|
+
* stack is truncated where the two stacks differ.
|
|
350
|
+
* @returns the index of the first frame in the given stack that is
|
|
351
|
+
* not shared with the tracked stack.
|
|
352
|
+
*/
|
|
353
|
+
#mergeWithCurrentStack(event, stackTrace) {
|
|
354
|
+
_a.filterStackFrames(stackTrace, this.#engineConfig);
|
|
355
|
+
const endTime = event.ts + (event.dur || 0);
|
|
356
|
+
const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);
|
|
357
|
+
let i;
|
|
358
|
+
// Merge a sample's stack frames with the stack frames we have
|
|
359
|
+
// so far if we detect they are equivalent.
|
|
360
|
+
// Graphically
|
|
361
|
+
// This:
|
|
362
|
+
// Current stack trace Sample
|
|
363
|
+
// [-------A------] [A]
|
|
364
|
+
// [-------B------] [B]
|
|
365
|
+
// [-------C------] [C]
|
|
366
|
+
// ^ t = x1 ^ t = x2
|
|
367
|
+
// Becomes this:
|
|
368
|
+
// New stack trace after merge
|
|
369
|
+
// [--------A-------]
|
|
370
|
+
// [--------B-------]
|
|
371
|
+
// [--------C-------]
|
|
372
|
+
// ^ t = x2
|
|
373
|
+
for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {
|
|
374
|
+
const newFrame = stackTrace[i].callFrame;
|
|
375
|
+
const oldFrame = this.#currentJSStack[i].callFrame;
|
|
376
|
+
if (!_a.framesAreEqual(newFrame, oldFrame)) {
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
// Scoot the right edge of this callFrame to the right
|
|
380
|
+
this.#currentJSStack[i].dur =
|
|
381
|
+
Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));
|
|
382
|
+
}
|
|
383
|
+
// If there are call frames in the sample that differ with the stack
|
|
384
|
+
// we have, update the stack, but keeping the common frames in place
|
|
385
|
+
// Graphically
|
|
386
|
+
// This:
|
|
387
|
+
// Current stack trace Sample
|
|
388
|
+
// [-------A------] [A]
|
|
389
|
+
// [-------B------] [B]
|
|
390
|
+
// [-------C------] [C]
|
|
391
|
+
// [-------D------] [E]
|
|
392
|
+
// ^ t = x1 ^ t = x2
|
|
393
|
+
// Becomes this:
|
|
394
|
+
// New stack trace after merge
|
|
395
|
+
// [--------A-------]
|
|
396
|
+
// [--------B-------]
|
|
397
|
+
// [--------C-------]
|
|
398
|
+
// [E]
|
|
399
|
+
// ^ t = x2
|
|
400
|
+
// This method only truncates the tracked stack; the caller pushes
|
|
401
|
+
// the differing frames (E in the diagram above).
|
|
402
|
+
this.#truncateJSStack(i, event.ts);
|
|
403
|
+
return i;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* When a call stack that differs from the one we are tracking has
|
|
407
|
+
* been detected in the samples, the latter is "truncated" by
|
|
408
|
+
* setting the ending time of its call frames and removing the top
|
|
409
|
+
* call frames that aren't shared with the new call stack. This way,
|
|
410
|
+
* we can update the tracked stack with the new call frames on top.
|
|
411
|
+
* @param depth the amount of call frames from bottom to top that
|
|
412
|
+
* should be kept in the tracking stack trace. AKA amount of shared
|
|
413
|
+
* call frames between two stacks.
|
|
414
|
+
* @param time the new end of the call frames in the stack.
|
|
415
|
+
*/
|
|
416
|
+
#truncateJSStack(depth, time) {
|
|
417
|
+
if (this.#lockedJsStackDepth.length) {
|
|
418
|
+
const lockedDepth = this.#lockedJsStackDepth.at(-1);
|
|
419
|
+
if (lockedDepth && depth < lockedDepth) {
|
|
420
|
+
console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);
|
|
421
|
+
depth = lockedDepth;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
if (this.#currentJSStack.length < depth) {
|
|
425
|
+
console.error(`Trying to truncate higher than the current stack size at ${time}`);
|
|
426
|
+
depth = this.#currentJSStack.length;
|
|
427
|
+
}
|
|
428
|
+
for (let k = 0; k < this.#currentJSStack.length; ++k) {
|
|
429
|
+
this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));
|
|
430
|
+
}
|
|
431
|
+
this.#currentJSStack.length = depth;
|
|
432
|
+
}
|
|
433
|
+
#makeJSSampleEvent(call, timestamp, traceId) {
|
|
434
|
+
const JSSampleEvent = {
|
|
435
|
+
name: Types.Events.Name.JS_SAMPLE,
|
|
436
|
+
cat: 'devtools.timeline',
|
|
437
|
+
args: {
|
|
438
|
+
data: { traceId, stackTrace: this.#stackNodesForProfileCall(call).map(node => node.callFrame) },
|
|
439
|
+
},
|
|
440
|
+
ph: Types.Events.Phase.INSTANT,
|
|
441
|
+
ts: timestamp,
|
|
442
|
+
dur: Types.Timing.Micro(0),
|
|
443
|
+
pid: this.#processId,
|
|
444
|
+
tid: this.#threadId,
|
|
445
|
+
};
|
|
446
|
+
return JSSampleEvent;
|
|
447
|
+
}
|
|
448
|
+
static framesAreEqual(frame1, frame2) {
|
|
449
|
+
return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&
|
|
450
|
+
frame1.lineNumber === frame2.lineNumber;
|
|
451
|
+
}
|
|
452
|
+
static showNativeName(name, runtimeCallStatsEnabled) {
|
|
453
|
+
return runtimeCallStatsEnabled && Boolean(_a.nativeGroup(name));
|
|
454
|
+
}
|
|
455
|
+
static nativeGroup(nativeName) {
|
|
456
|
+
if (nativeName.startsWith('Parse')) {
|
|
457
|
+
return _a.NativeGroups.PARSE;
|
|
458
|
+
}
|
|
459
|
+
if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {
|
|
460
|
+
return _a.NativeGroups.COMPILE;
|
|
461
|
+
}
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
static isNativeRuntimeFrame(frame) {
|
|
465
|
+
return frame.url === 'native V8Runtime';
|
|
466
|
+
}
|
|
467
|
+
static filterStackFrames(stack, engineConfig) {
|
|
468
|
+
const showAllEvents = engineConfig.showAllEvents;
|
|
469
|
+
if (showAllEvents) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
let j = 0;
|
|
473
|
+
for (let i = 0; i < stack.length; ++i) {
|
|
474
|
+
const frame = stack[i].callFrame;
|
|
475
|
+
const nativeRuntimeFrame = _a.isNativeRuntimeFrame(frame);
|
|
476
|
+
if (nativeRuntimeFrame) {
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
stack[j++] = stack[i];
|
|
480
|
+
}
|
|
481
|
+
stack.length = j;
|
|
482
|
+
}
|
|
483
|
+
static createFakeTraceFromCpuProfile(profile, tid) {
|
|
484
|
+
if (!profile) {
|
|
485
|
+
return { traceEvents: [], metadata: {} };
|
|
486
|
+
}
|
|
487
|
+
// The |Name.CPU_PROFILE| will let MetaHandler to set |traceIsGeneric| to false
|
|
488
|
+
// The start time and duration is important here because we'll use them to determine the traceBounds
|
|
489
|
+
// We use the start and end time of the profile (which is longer than all samples), so the Performance
|
|
490
|
+
// panel won't truncate this time period.
|
|
491
|
+
const cpuProfileEvent = {
|
|
492
|
+
cat: 'disabled-by-default-devtools.timeline',
|
|
493
|
+
name: Types.Events.Name.CPU_PROFILE,
|
|
494
|
+
ph: Types.Events.Phase.COMPLETE,
|
|
495
|
+
pid: Types.Events.ProcessID(1),
|
|
496
|
+
tid,
|
|
497
|
+
ts: Types.Timing.Micro(profile.startTime),
|
|
498
|
+
dur: Types.Timing.Micro(profile.endTime - profile.startTime),
|
|
499
|
+
args: { data: { cpuProfile: profile } },
|
|
500
|
+
// Create an arbitrary profile id.
|
|
501
|
+
id: '0x1',
|
|
502
|
+
};
|
|
503
|
+
return {
|
|
504
|
+
traceEvents: [cpuProfileEvent],
|
|
505
|
+
metadata: {
|
|
506
|
+
dataOrigin: Types.File.DataOrigin.CPU_PROFILE,
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
static extractCpuProfileFromFakeTrace(traceEvents) {
|
|
511
|
+
const profileEvent = traceEvents.find(e => Types.Events.isSyntheticCpuProfile(e));
|
|
512
|
+
const profile = profileEvent?.args.data.cpuProfile;
|
|
513
|
+
if (!profile) {
|
|
514
|
+
throw new Error('Missing cpuProfile data');
|
|
515
|
+
}
|
|
516
|
+
return profile;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
_a = SamplesIntegrator;
|
|
520
|
+
(function (SamplesIntegrator) {
|
|
521
|
+
let NativeGroups;
|
|
522
|
+
(function (NativeGroups) {
|
|
523
|
+
NativeGroups["COMPILE"] = "Compile";
|
|
524
|
+
NativeGroups["PARSE"] = "Parse";
|
|
525
|
+
})(NativeGroups = SamplesIntegrator.NativeGroups || (SamplesIntegrator.NativeGroups = {}));
|
|
526
|
+
})(SamplesIntegrator || (SamplesIntegrator = {}));
|
|
527
|
+
//# sourceMappingURL=SamplesIntegrator.js.map
|
|
@@ -0,0 +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,sB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ED,WAAiB,iBAAiB;IAChC,IAAY,YAGX;IAHD,WAAY,YAAY;QACtB,mCAAmB,CAAA;QACnB,+BAAe,CAAA;IACjB,CAAC,EAHW,YAAY,GAAZ,kBAAA,YAAY,KAAZ,kBAAA,YAAY,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 used in two cases:\n * 1. We start tracing half-way through, so we miss the start of JS\n * invocation events.\n * 2. On threads (like Web Workers) without real JS invocation parent events,\n * but where trace events (like SchedulePostMessage) integrate stack traces.\n * Enabling fake JS mode allows subsequent samples to be processed and\n * eventually correct the stack, preventing a deadlock.\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, parentEvent);\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, parent?: 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 if (extractSampleTraceId(event)) {\n const hasJSInvocationParent = parent && Types.Events.isJSInvocationEvent(parent);\n if (!hasJSInvocationParent) {\n // If the event has a sampleTraceId (meaning it has a stack trace) but\n // no JS invocation parent, we enter fake JS mode. This ensures that\n // subsequent samples on this thread are processed, allowing the stack\n // to be correctly updated/truncated. Without this, subsequent samples\n // would be ignored because the stack is non-empty but we are not\n // considered to be in JS.\n this.#fakeJSInvocation = true;\n }\n }\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 the profile nodes of the\n * stack trace that profile call belongs to based on its nodeId,\n * ordered from the bottom of the stack to the top. The root node is\n * omitted. The node of the input profile call will be at the top of\n * the returned stack (last position), meaning that any other frames\n * that were effectively above it are omitted.\n */\n #stackNodesForProfileCall(profileCall: Types.Events.SyntheticProfileCall): CPUProfile.ProfileTreeModel.ProfileNode[] {\n const sampledNode = this.#profileModel.nodeById(profileCall.nodeId);\n let node = sampledNode;\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 (!sampledNode || !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 nodes = new Array<CPUProfile.ProfileTreeModel.ProfileNode>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = nodes.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection node on top of the stack.\n nodes[i--] = sampledNode;\n }\n // The root node has a depth of -1, so the loop stops before it.\n while (node && i >= 0) {\n nodes[i--] = node;\n node = node.parent;\n }\n return nodes;\n }\n\n /**\n * Returns a profile call for the node sampled with the given trace id,\n * or null if the profile has no node for it.\n */\n #callForSampleTraceId(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 if (!node) {\n return null;\n }\n const callForTraceId = makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);\n if (this.#engineConfig.debugMode) {\n this.jsSampleEvents.push(this.#makeJSSampleEvent(callForTraceId, timestamp, traceId));\n }\n return callForTraceId;\n }\n\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.Events.Event): void {\n const traceId = extractSampleTraceId(event);\n const callForTraceId = traceId ? this.#callForSampleTraceId(traceId, event.ts) : null;\n const stackSource = callForTraceId ?? (Types.Events.isProfileCall(event) ? event : null);\n if (!stackSource) {\n // The event carries no stack of its own, so merging the tracked\n // stack with itself only updates the durations of its frames.\n this.#mergeWithCurrentStack(event, this.#currentJSStack);\n return;\n }\n\n const stackNodes = this.#stackNodesForProfileCall(stackSource);\n let i = this.#mergeWithCurrentStack(event, stackNodes);\n for (; i < stackNodes.length; ++i) {\n const node = stackNodes[i];\n if (node.id === this.#profileModel.programNode?.id || node.id === this.#profileModel.root?.id ||\n node.id === this.#profileModel.idleNode?.id || node.id === 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 // Profile calls are only created for the frames that are added to\n // the tracked stack, rather than for every frame of every sample.\n const call = makeProfileCall(node, stackSource.profileId, stackSource.sampleIndex, stackSource.ts,\n this.#processId, this.#threadId);\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * Merges the given stack with the tracked stack: the durations of\n * the shared frames are extended to cover the event, and the tracked\n * stack is truncated where the two stacks differ.\n * @returns the index of the first frame in the given stack that is\n * not shared with the tracked stack.\n */\n #mergeWithCurrentStack<T extends {callFrame: Protocol.Runtime.CallFrame}>(event: Types.Events.Event,\n stackTrace: T[]): number {\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 method only truncates the tracked stack; the caller pushes\n // the differing frames (E in the diagram above).\n this.#truncateJSStack(i, event.ts);\n return i;\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.#stackNodesForProfileCall(call).map(node => node.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<T extends {callFrame: Protocol.Runtime.CallFrame}>(\n stack: T[], engineConfig: Types.Configuration.Configuration): 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"]}
|