@paulirish/trace_engine 0.0.19 → 0.0.21

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.
Files changed (51) hide show
  1. package/README.md +2 -5
  2. package/generated/protocol.d.ts +235 -8
  3. package/models/cpu_profile/CPUProfileDataModel.js +3 -3
  4. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
  5. package/models/trace/LegacyTracingModel.js.map +1 -1
  6. package/models/trace/ModelImpl.d.ts +1 -0
  7. package/models/trace/ModelImpl.js +5 -0
  8. package/models/trace/ModelImpl.js.map +1 -1
  9. package/models/trace/extras/FetchNodes.d.ts +8 -0
  10. package/models/trace/extras/FetchNodes.js +54 -2
  11. package/models/trace/extras/FetchNodes.js.map +1 -1
  12. package/models/trace/handlers/ImagePaintingHandler.d.ts +8 -0
  13. package/models/trace/handlers/ImagePaintingHandler.js +108 -0
  14. package/models/trace/handlers/ImagePaintingHandler.js.map +1 -0
  15. package/models/trace/handlers/InvalidationsHandler.js +0 -9
  16. package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
  17. package/models/trace/handlers/MetaHandler.js +25 -6
  18. package/models/trace/handlers/MetaHandler.js.map +1 -1
  19. package/models/trace/handlers/ModelHandlers.d.ts +3 -0
  20. package/models/trace/handlers/ModelHandlers.js +3 -0
  21. package/models/trace/handlers/ModelHandlers.js.map +1 -1
  22. package/models/trace/handlers/NetworkRequestsHandler.js +4 -0
  23. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  24. package/models/trace/handlers/PageFramesHandler.d.ts +7 -0
  25. package/models/trace/handlers/PageFramesHandler.js +41 -0
  26. package/models/trace/handlers/PageFramesHandler.js.map +1 -0
  27. package/models/trace/handlers/SelectorStatsHandler.d.ts +9 -0
  28. package/models/trace/handlers/SelectorStatsHandler.js +28 -0
  29. package/models/trace/handlers/SelectorStatsHandler.js.map +1 -0
  30. package/models/trace/handlers/UserInteractionsHandler.d.ts +2 -0
  31. package/models/trace/handlers/UserInteractionsHandler.js +7 -0
  32. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -1
  33. package/models/trace/handlers/handlers-tsconfig.json +3 -0
  34. package/models/trace/helpers/Trace.d.ts +11 -0
  35. package/models/trace/helpers/Trace.js +101 -0
  36. package/models/trace/helpers/Trace.js.map +1 -1
  37. package/models/trace/insights/InsightRunners.d.ts +1 -0
  38. package/models/trace/insights/InsightRunners.js +1 -0
  39. package/models/trace/insights/InsightRunners.js.map +1 -1
  40. package/models/trace/insights/Viewport.d.ts +5 -0
  41. package/models/trace/insights/Viewport.js +39 -0
  42. package/models/trace/insights/Viewport.js.map +1 -0
  43. package/models/trace/insights/insights-tsconfig.json +1 -0
  44. package/models/trace/insights/types.d.ts +2 -1
  45. package/models/trace/insights/types.js +1 -0
  46. package/models/trace/insights/types.js.map +1 -1
  47. package/models/trace/types/TraceEvents.d.ts +94 -14
  48. package/models/trace/types/TraceEvents.js +23 -2
  49. package/models/trace/types/TraceEvents.js.map +1 -1
  50. package/package.json +1 -1
  51. package/PAUL.readme.md +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"LegacyTracingModel.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/LegacyTracingModel.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAC7B,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,yCAAyC;AAEzC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAM1C,MAAM,OAAO,YAAY;IACd,MAAM,CAAmB;IACzB,YAAY,CAA8B;IAC1C,cAAc,CAAuB;IAC9C,0BAA0B,CAAS;IACnC,0BAA0B,CAAS;IAC1B,+BAA+B,CAAU;IAClD,YAAY,CAAe;IAClB,gBAAgB,CAA0B;IAC1C,wBAAwB,CAA4B;IACpD,cAAc,CAAkC;IAChD,iBAAiB,CAA2B;IAC5C,iBAAiB,GA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AAC,KAA2B,EAAE,QAAgB;IAC5E,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,wBAAwB,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/D,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,wBAAwB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAA6C;IACzE,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC,EAAE,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA6C;IAC5E,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,UAAwC,CAAC;IAC/D,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC;AACrD,CAAC","sourcesContent":["// Copyright 2014 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n//\n// This is what was SDK.TracingModel moved into models/trace to avoid circular\n// dependency issues. Our ultimate goal is to remove this model entirely once\n// the migration to the new model is done\n\nimport * as Helpers from './helpers/helpers.js';\nimport {type EventPayload} from './TracingManager.js';\nimport * as Types from './types/types.js';\n\ntype IgnoreListArgs = {\n [key: string]: string|number|ObjectSnapshot,\n};\n\nexport class TracingModel {\n readonly #title: string|undefined;\n readonly #processById: Map<string|number, Process>;\n readonly #processByName: Map<string, Process>;\n #minimumRecordTimeInternal: number;\n #maximumRecordTimeInternal: number;\n readonly #devToolsMetadataEventsInternal: Event[];\n #asyncEvents: AsyncEvent[];\n readonly #openAsyncEvents: Map<string, AsyncEvent>;\n readonly #openNestableAsyncEvents: Map<string, AsyncEvent[]>;\n readonly #profileGroups: Map<string, ProfileEventsGroup>;\n readonly #parsedCategories: Map<string, Set<string>>;\n readonly #allEventsPayload: EventPayload[] = [];\n\n constructor(title?: string) {\n this.#title = title;\n this.#processById = new Map();\n this.#processByName = new Map();\n this.#minimumRecordTimeInternal = Number(Infinity);\n this.#maximumRecordTimeInternal = Number(-Infinity);\n this.#devToolsMetadataEventsInternal = [];\n this.#asyncEvents = [];\n this.#openAsyncEvents = new Map();\n this.#openNestableAsyncEvents = new Map();\n this.#profileGroups = new Map();\n this.#parsedCategories = new Map();\n }\n\n static isTopLevelEvent(event: CompatibleTraceEvent): boolean {\n return eventHasCategory(event, DevToolsTimelineEventCategory) && event.name === 'RunTask' ||\n eventHasCategory(event, LegacyTopLevelEventCategory) ||\n eventHasCategory(event, DevToolsMetadataEventCategory) &&\n event.name === 'Program'; // Older timelines may have this instead of toplevel.\n }\n\n static extractId(payload: EventPayload): string|undefined {\n const scope = payload.scope || '';\n if (typeof payload.id2 === 'undefined') {\n return scope && payload.id ? `${scope}@${payload.id}` : payload.id;\n }\n const id2 = payload.id2;\n if (typeof id2 === 'object' && ('global' in id2) !== ('local' in id2)) {\n return typeof id2['global'] !== 'undefined' ? `:${scope}:${id2['global']}` :\n `:${scope}:${payload.pid}:${id2['local']}`;\n }\n console.error(\n `Unexpected id2 field at ${payload.ts / 1000}, one and only one of 'local' and 'global' should be present.`);\n return undefined;\n }\n\n static browserMainThread(tracingModel: TracingModel): Thread|null {\n const processes = tracingModel.sortedProcesses();\n // Avoid warning for an empty #model.\n if (!processes.length) {\n return null;\n }\n const browserMainThreadName = 'CrBrowserMain';\n const browserProcesses = [];\n const browserMainThreads = [];\n for (const process of processes) {\n if (process.name().toLowerCase().endsWith('browser')) {\n browserProcesses.push(process);\n }\n browserMainThreads.push(...process.sortedThreads().filter(t => t.name() === browserMainThreadName));\n }\n if (browserMainThreads.length === 1) {\n return browserMainThreads[0];\n }\n if (browserProcesses.length === 1) {\n return browserProcesses[0].threadByName(browserMainThreadName);\n }\n const tracingStartedInBrowser =\n tracingModel.devToolsMetadataEvents().filter(e => e.name === 'TracingStartedInBrowser');\n if (tracingStartedInBrowser.length === 1) {\n return tracingStartedInBrowser[0].thread;\n }\n console.error(\n 'Failed to find browser main thread in trace, some timeline features may be unavailable');\n return null;\n }\n\n allRawEvents(): readonly EventPayload[] {\n return this.#allEventsPayload;\n }\n\n devToolsMetadataEvents(): Event[] {\n return this.#devToolsMetadataEventsInternal;\n }\n\n addEvents(events: readonly EventPayload[]): void {\n for (let i = 0; i < events.length; ++i) {\n this.addEvent(events[i]);\n }\n }\n\n tracingComplete(): void {\n this.processPendingAsyncEvents();\n for (const process of this.#processById.values()) {\n for (const thread of process.threads.values()) {\n thread.tracingComplete();\n }\n }\n }\n\n private addEvent(payload: EventPayload): void {\n this.#allEventsPayload.push(payload);\n let process = this.#processById.get(payload.pid);\n if (!process) {\n process = new Process(this, payload.pid);\n this.#processById.set(payload.pid, process);\n }\n\n const timestamp = payload.ts / 1000;\n // We do allow records for unrelated threads to arrive out-of-order,\n // so there's a chance we're getting records from the past.\n if (timestamp && timestamp < this.#minimumRecordTimeInternal &&\n eventPhasesOfInterestForTraceBounds.has(payload.ph as Types.TraceEvents.Phase) &&\n // UMA related events are ignored when calculating the minimumRecordTime because they might\n // be related to previous navigations that happened before the current trace started and\n // will currently not be displayed anyways.\n // See crbug.com/1201198\n (!payload.name.endsWith('::UMA'))) {\n this.#minimumRecordTimeInternal = timestamp;\n }\n\n if (payload.name === 'TracingStartedInBrowser') {\n // If we received a timestamp for tracing start, use that for minimumRecordTime.\n this.#minimumRecordTimeInternal = timestamp;\n }\n\n if (eventPhasesOfInterestForTraceBounds.has(payload.ph as Types.TraceEvents.Phase)) {\n const endTimeStamp = (payload.ts + (payload.dur || 0)) / 1000;\n this.#maximumRecordTimeInternal = Math.max(this.#maximumRecordTimeInternal, endTimeStamp);\n }\n const event = process.addEvent(payload);\n if (!event) {\n return;\n }\n if (payload.ph === Types.TraceEvents.Phase.SAMPLE) {\n this.addSampleEvent(event);\n return;\n }\n // Build async event when we've got events from all threads & processes, so we can sort them and process in the\n // chronological order. However, also add individual async events to the thread flow (above), so we can easily\n // display them on the same chart as other events, should we choose so.\n if (Types.TraceEvents.isAsyncPhase(payload.ph)) {\n this.#asyncEvents.push((event as AsyncEvent));\n }\n if (event.hasCategory(DevToolsMetadataEventCategory)) {\n this.#devToolsMetadataEventsInternal.push(event);\n }\n\n if (payload.ph !== Types.TraceEvents.Phase.METADATA) {\n return;\n }\n\n switch (payload.name) {\n case MetadataEvent.ProcessSortIndex: {\n process.setSortIndex(payload.args['sort_index']);\n break;\n }\n case MetadataEvent.ProcessName: {\n const processName = payload.args['name'];\n process.setName(processName);\n this.#processByName.set(processName, process);\n break;\n }\n case MetadataEvent.ThreadSortIndex: {\n process.threadById(payload.tid).setSortIndex(payload.args['sort_index']);\n break;\n }\n case MetadataEvent.ThreadName: {\n process.threadById(payload.tid).setName(payload.args['name']);\n break;\n }\n }\n }\n\n private addSampleEvent(event: Event): void {\n const id = `${event.thread.process().id()}:${event.id}`;\n const group = this.#profileGroups.get(id);\n if (group) {\n group.addChild(event);\n } else {\n this.#profileGroups.set(id, new ProfileEventsGroup(event));\n }\n }\n\n profileGroup(event: Event): ProfileEventsGroup|null {\n return this.#profileGroups.get(`${event.thread.process().id()}:${event.id}`) || null;\n }\n\n minimumRecordTime(): number {\n return this.#minimumRecordTimeInternal;\n }\n\n maximumRecordTime(): number {\n return this.#maximumRecordTimeInternal;\n }\n\n sortedProcesses(): Process[] {\n return NamedObject.sort([...this.#processById.values()]);\n }\n\n getProcessByName(name: string): Process|null {\n return this.#processByName.get(name) ?? null;\n }\n\n getProcessById(pid: number): Process|null {\n return this.#processById.get(pid) || null;\n }\n\n getThreadByName(processName: string, threadName: string): Thread|null {\n const process = this.getProcessByName(processName);\n return process && process.threadByName(threadName);\n }\n\n private processPendingAsyncEvents(): void {\n this.#asyncEvents.sort(Event.compareStartTime);\n for (let i = 0; i < this.#asyncEvents.length; ++i) {\n const event = this.#asyncEvents[i];\n if (Types.TraceEvents.isNestableAsyncPhase(event.phase)) {\n this.addNestableAsyncEvent(event);\n } else {\n this.addAsyncEvent(event);\n }\n }\n this.#asyncEvents = [];\n this.closeOpenAsyncEvents();\n }\n\n private closeOpenAsyncEvents(): void {\n for (const event of this.#openAsyncEvents.values()) {\n event.setEndTime(this.#maximumRecordTimeInternal);\n // FIXME: remove this once we figure a better way to convert async console\n // events to sync [waterfall] timeline records.\n event.steps[0].setEndTime(this.#maximumRecordTimeInternal);\n }\n this.#openAsyncEvents.clear();\n\n for (const eventStack of this.#openNestableAsyncEvents.values()) {\n while (eventStack.length) {\n const event = eventStack.pop();\n if (!event) {\n continue;\n }\n event.setEndTime(this.#maximumRecordTimeInternal);\n }\n }\n this.#openNestableAsyncEvents.clear();\n }\n\n private addNestableAsyncEvent(event: Event): void {\n const key = event.categoriesString + '.' + event.id;\n let openEventsStack = this.#openNestableAsyncEvents.get(key);\n\n switch (event.phase) {\n case Types.TraceEvents.Phase.ASYNC_NESTABLE_START: {\n if (!openEventsStack) {\n openEventsStack = [];\n this.#openNestableAsyncEvents.set(key, openEventsStack);\n }\n const asyncEvent = new AsyncEvent(event);\n openEventsStack.push(asyncEvent);\n event.thread.addAsyncEvent(asyncEvent);\n break;\n }\n\n case Types.TraceEvents.Phase.ASYNC_NESTABLE_INSTANT: {\n if (openEventsStack && openEventsStack.length) {\n const event = openEventsStack[openEventsStack.length - 1];\n if (event) {\n event.addStep(event);\n }\n }\n break;\n }\n\n case Types.TraceEvents.Phase.ASYNC_NESTABLE_END: {\n if (!openEventsStack || !openEventsStack.length) {\n break;\n }\n const top = openEventsStack.pop();\n if (!top) {\n break;\n }\n if (top.name !== event.name) {\n console.error(\n `Begin/end event mismatch for nestable async event, ${top.name} vs. ${event.name}, key: ${key}`);\n break;\n }\n top.addStep(event);\n }\n }\n }\n\n private addAsyncEvent(event: Event): void {\n const key = event.categoriesString + '.' + event.name + '.' + event.id;\n let asyncEvent = this.#openAsyncEvents.get(key);\n\n if (event.phase === Types.TraceEvents.Phase.ASYNC_BEGIN) {\n if (asyncEvent) {\n console.error(`Event ${event.name} has already been started`);\n return;\n }\n asyncEvent = new AsyncEvent(event);\n this.#openAsyncEvents.set(key, asyncEvent);\n event.thread.addAsyncEvent(asyncEvent);\n return;\n }\n if (!asyncEvent) {\n // Quietly ignore stray async events, we're probably too late for the start.\n return;\n }\n if (event.phase === Types.TraceEvents.Phase.ASYNC_END) {\n asyncEvent.addStep(event);\n this.#openAsyncEvents.delete(key);\n return;\n }\n if (event.phase === Types.TraceEvents.Phase.ASYNC_STEP_INTO ||\n event.phase === Types.TraceEvents.Phase.ASYNC_STEP_PAST) {\n const lastStep = asyncEvent.steps[asyncEvent.steps.length - 1];\n if (lastStep && lastStep.phase !== Types.TraceEvents.Phase.ASYNC_BEGIN && lastStep.phase !== event.phase) {\n console.assert(\n false,\n 'Async event step phase mismatch: ' + lastStep.phase + ' at ' + lastStep.startTime + ' vs. ' + event.phase +\n ' at ' + event.startTime);\n return;\n }\n asyncEvent.addStep(event);\n return;\n }\n console.assert(false, 'Invalid async event phase');\n }\n\n title(): string|undefined {\n return this.#title;\n }\n\n parsedCategoriesForString(str: string): Set<string> {\n let parsedCategories = this.#parsedCategories.get(str);\n if (!parsedCategories) {\n parsedCategories = new Set(str ? str.split(',') : []);\n this.#parsedCategories.set(str, parsedCategories);\n }\n return parsedCategories;\n }\n}\n\nexport const eventPhasesOfInterestForTraceBounds: Set<Types.TraceEvents.Phase> = new Set([\n Types.TraceEvents.Phase.BEGIN,\n Types.TraceEvents.Phase.END,\n Types.TraceEvents.Phase.COMPLETE,\n Types.TraceEvents.Phase.INSTANT,\n]);\n\nexport const MetadataEvent = {\n ProcessSortIndex: 'process_sort_index',\n ProcessName: 'process_name',\n ThreadSortIndex: 'thread_sort_index',\n ThreadName: 'thread_name',\n};\n\n// TODO(alph): LegacyTopLevelEventCategory is not recorded since M74 and used for loading\n// legacy profiles. Drop at some point.\nexport const LegacyTopLevelEventCategory = 'toplevel';\n\nexport const DevToolsMetadataEventCategory = 'disabled-by-default-devtools.timeline';\nexport const DevToolsTimelineEventCategory = 'disabled-by-default-devtools.timeline';\n\nexport function eventHasPayload(event: Event): event is PayloadEvent {\n return 'rawPayload' in event;\n}\n\nexport class Event {\n categoriesString: string;\n readonly #parsedCategories: Set<string>;\n name: string;\n phase: Types.TraceEvents.Phase;\n startTime: number;\n thread: Thread;\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n args: any;\n id!: string|null;\n ordinal: number;\n selfTime: number;\n endTime?: number;\n duration?: number;\n\n // The constructor is protected so that we ensure that only classes or\n // subclasses can directly instantiate events. All other callers should\n // either create ConstructedEvent instances, which have a public constructor,\n // or use the static fromPayload method which can create an event instance\n // from the trace payload.\n protected constructor(\n categories: string|undefined, name: string, phase: Types.TraceEvents.Phase, startTime: number, thread: Thread) {\n this.categoriesString = categories || '';\n this.#parsedCategories = thread.getModel().parsedCategoriesForString(this.categoriesString);\n this.name = name;\n this.phase = phase;\n this.startTime = startTime;\n this.thread = thread;\n this.args = {};\n this.ordinal = 0;\n\n this.selfTime = 0;\n }\n\n static compareStartTime(a: Event|null, b: Event|null): number {\n if (!a || !b) {\n return 0;\n }\n\n return a.startTime - b.startTime;\n }\n\n static orderedCompareStartTime(a: Event, b: Event): number {\n // Array.mergeOrdered coalesces objects if comparator returns 0.\n // To change this behavior this comparator return -1 in the case events\n // startTime's are equal, so both events got placed into the result array.\n return a.startTime - b.startTime || a.ordinal - b.ordinal || -1;\n }\n\n hasCategory(categoryName: string): boolean {\n return this.#parsedCategories.has(categoryName);\n }\n\n setEndTime(endTime: number): void {\n if (endTime < this.startTime) {\n console.assert(false, 'Event out of order: ' + this.name);\n return;\n }\n this.endTime = endTime;\n this.duration = endTime - this.startTime;\n }\n\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n addArgs(args: any): void {\n // Shallow copy args to avoid modifying original #payload which may be saved to file.\n for (const name in args) {\n if (name in this.args) {\n console.error('Same argument name (' + name + ') is used for begin and end phases of ' + this.name);\n }\n\n (this.args as IgnoreListArgs)[name] = (args as IgnoreListArgs)[name];\n }\n }\n\n complete(endEvent: Event): void {\n if (endEvent.args) {\n this.addArgs(endEvent.args);\n } else {\n console.error('Missing mandatory event argument \\'args\\' at ' + endEvent.startTime);\n }\n this.setEndTime(endEvent.startTime);\n }\n}\n\n/**\n * Represents a tracing event that is not directly linked to an individual\n * object in the trace. We construct these events at times, particularly when\n * building up the CPU profile data for JS Profiling.\n **/\nexport class ConstructedEvent extends Event {\n // Because the constructor of Event is marked as protected, but we want\n // people to be able to create constructed events, we override the\n // constructor here, even though we are only calling super, in order to mark\n // it as public.\n constructor(\n categories: string|undefined, name: string, phase: Types.TraceEvents.Phase, startTime: number, thread: Thread) {\n super(categories, name, phase, startTime, thread);\n }\n}\n\n/**\n * Represents a tracing event that has been created directly from an object in\n * the trace file and therefore is guaranteed to have a payload associated with\n * it. The only way to create these events is to use the static fromPayload\n * method, which you must call with a payload.\n **/\nexport class PayloadEvent extends Event {\n #rawPayload: EventPayload;\n\n /**\n * Returns the raw payload that was used to create this event instance.\n **/\n rawLegacyPayload(): EventPayload {\n return this.#rawPayload;\n }\n\n /**\n * Returns the raw payload that was used to create this event instance, but\n * returns it typed as the new engine's TraceEventArgs option.\n **/\n rawPayload(): Types.TraceEvents.TraceEventData {\n return this.#rawPayload as unknown as Types.TraceEvents.TraceEventData;\n }\n\n protected constructor(\n categories: string|undefined, name: string, phase: Types.TraceEvents.Phase, startTime: number, thread: Thread,\n rawPayload: EventPayload) {\n super(categories, name, phase, startTime, thread);\n this.#rawPayload = rawPayload;\n }\n\n static fromPayload(payload: EventPayload, thread: Thread): PayloadEvent {\n const event = new PayloadEvent(payload.cat, payload.name, payload.ph, payload.ts / 1000, thread, payload);\n event.#rawPayload = payload;\n if (payload.args) {\n event.addArgs(payload.args);\n }\n if (typeof payload.dur === 'number') {\n event.setEndTime((payload.ts + payload.dur) / 1000);\n }\n const id = TracingModel.extractId(payload);\n if (typeof id !== 'undefined') {\n event.id = id;\n }\n\n return event;\n }\n}\n\nexport class ObjectSnapshot extends PayloadEvent {\n private constructor(\n category: string|undefined, name: string, startTime: number, thread: Thread, rawPayload: EventPayload) {\n super(category, name, Types.TraceEvents.Phase.OBJECT_SNAPSHOT, startTime, thread, rawPayload);\n }\n\n static override fromPayload(payload: EventPayload, thread: Thread): ObjectSnapshot {\n const snapshot = new ObjectSnapshot(payload.cat, payload.name, payload.ts / 1000, thread, payload);\n const id = TracingModel.extractId(payload);\n if (typeof id !== 'undefined') {\n snapshot.id = id;\n }\n if (!payload.args || !payload.args['snapshot']) {\n console.error('Missing mandatory \\'snapshot\\' argument at ' + payload.ts / 1000);\n return snapshot;\n }\n if (payload.args) {\n snapshot.addArgs(payload.args);\n }\n return snapshot;\n }\n\n getSnapshot(): ObjectSnapshot {\n const snapshot = this.args['snapshot'];\n if (!snapshot) {\n throw new Error('ObjectSnapshot has no snapshot argument.');\n }\n return snapshot;\n }\n}\n\nexport class AsyncEvent extends ConstructedEvent {\n steps: Event[];\n causedFrame: boolean;\n\n constructor(startEvent: Event) {\n super(startEvent.categoriesString, startEvent.name, startEvent.phase, startEvent.startTime, startEvent.thread);\n this.addArgs(startEvent.args);\n this.steps = [startEvent];\n this.causedFrame = false;\n }\n\n addStep(event: Event): void {\n this.steps.push(event);\n if (event.phase === Types.TraceEvents.Phase.ASYNC_END ||\n event.phase === Types.TraceEvents.Phase.ASYNC_NESTABLE_END) {\n this.setEndTime(event.startTime);\n // FIXME: ideally, we shouldn't do this, but this makes the logic of converting\n // async console events to sync ones much simpler.\n this.steps[0].setEndTime(event.startTime);\n }\n }\n}\n\nclass ProfileEventsGroup {\n children: Event[];\n constructor(event: Event) {\n this.children = [event];\n }\n\n addChild(event: Event): void {\n this.children.push(event);\n }\n}\n\nclass NamedObject {\n model: TracingModel;\n readonly idInternal: number;\n #nameInternal: string;\n #sortIndex: number;\n constructor(model: TracingModel, id: number) {\n this.model = model;\n this.idInternal = id;\n this.#nameInternal = '';\n this.#sortIndex = 0;\n }\n\n static sort<Item extends NamedObject>(array: Item[]): Item[] {\n return array.sort((a, b) => {\n return a.#sortIndex !== b.#sortIndex ? a.#sortIndex - b.#sortIndex : a.name().localeCompare(b.name());\n });\n }\n\n setName(name: string): void {\n this.#nameInternal = name;\n }\n\n name(): string {\n return this.#nameInternal;\n }\n\n id(): number {\n return this.idInternal;\n }\n\n setSortIndex(sortIndex: number): void {\n this.#sortIndex = sortIndex;\n }\n\n getModel(): TracingModel {\n return this.model;\n }\n}\n\nexport class Process extends NamedObject {\n readonly threads: Map<number, Thread>;\n readonly #threadByNameInternal: Map<string, Thread|null>;\n constructor(model: TracingModel, id: number) {\n super(model, id);\n this.threads = new Map();\n this.#threadByNameInternal = new Map();\n }\n\n threadById(id: number): Thread {\n let thread = this.threads.get(id);\n if (!thread) {\n thread = new Thread(this, id);\n this.threads.set(id, thread);\n }\n return thread;\n }\n\n threadByName(name: string): Thread|null {\n return this.#threadByNameInternal.get(name) || null;\n }\n\n setThreadByName(name: string, thread: Thread): void {\n this.#threadByNameInternal.set(name, thread);\n }\n\n addEvent(payload: EventPayload): Event|null {\n return this.threadById(payload.tid).addEvent(payload);\n }\n\n sortedThreads(): Thread[] {\n return NamedObject.sort([...this.threads.values()]);\n }\n}\n\nexport class Thread extends NamedObject {\n readonly #processInternal: Process;\n #eventsInternal: Event[];\n readonly #asyncEventsInternal: AsyncEvent[];\n #lastTopLevelEvent: Event|null;\n constructor(process: Process, id: number) {\n super(process.getModel(), id);\n this.#processInternal = process;\n\n this.#eventsInternal = [];\n this.#asyncEventsInternal = [];\n this.#lastTopLevelEvent = null;\n }\n\n /**\n * Whilst we are in the middle of migrating to the new Phase enum, we need to\n * be able to compare events with the legacy phase to the new enum. This method\n * does this by casting the event phase to a string, ensuring we can compare it\n * against either enum. Once the migration is complete (crbug.com/1417587), we\n * will be able to use === to compare with no TS errors and this method can be\n * removed.\n */\n #eventMatchesPhase(event: Event, phase: Types.TraceEvents.Phase): boolean {\n return (event.phase as string) === phase;\n }\n\n tracingComplete(): void {\n this.#asyncEventsInternal.sort(Event.compareStartTime);\n this.#eventsInternal.sort(Event.compareStartTime);\n const stack: Event[] = [];\n const toDelete = new Set<number>();\n for (let i = 0; i < this.#eventsInternal.length; ++i) {\n const e = this.#eventsInternal[i];\n e.ordinal = i;\n if (this.#eventMatchesPhase(e, Types.TraceEvents.Phase.END)) {\n toDelete.add(i); // Mark for removal.\n // Quietly ignore unbalanced close events, they're legit (we could have missed start one).\n if (!stack.length) {\n continue;\n }\n const top = stack.pop();\n if (!top) {\n continue;\n }\n if (top.name !== e.name || top.categoriesString !== e.categoriesString) {\n console.error(\n 'B/E events mismatch at ' + top.startTime + ' (' + top.name + ') vs. ' + e.startTime + ' (' + e.name +\n ')');\n } else {\n top.complete(e);\n }\n } else if (this.#eventMatchesPhase(e, Types.TraceEvents.Phase.BEGIN)) {\n stack.push(e);\n }\n }\n\n // Handle Begin events with no matching End.\n // This commonly happens due to a bug in the trace machinery. See crbug.com/982252\n while (stack.length) {\n const event = stack.pop();\n if (event) {\n // Masquerade the event as Instant, so it's rendered to the user.\n // The ideal fix is resolving crbug.com/1021571, but handling that without a perfetto migration appears prohibitive\n event.phase = Types.TraceEvents.Phase.INSTANT;\n }\n }\n this.#eventsInternal = this.#eventsInternal.filter((_, idx) => !toDelete.has(idx));\n }\n\n addEvent(payload: EventPayload): Event|null {\n const event = payload.ph === Types.TraceEvents.Phase.OBJECT_SNAPSHOT ? ObjectSnapshot.fromPayload(payload, this) :\n PayloadEvent.fromPayload(payload, this);\n if (TracingModel.isTopLevelEvent(event)) {\n // Discard nested \"top-level\" events.\n const lastTopLevelEvent = this.#lastTopLevelEvent;\n if (lastTopLevelEvent && (lastTopLevelEvent.endTime || 0) > event.startTime) {\n return null;\n }\n this.#lastTopLevelEvent = event;\n }\n this.#eventsInternal.push(event);\n return event;\n }\n\n addAsyncEvent(asyncEvent: AsyncEvent): void {\n this.#asyncEventsInternal.push(asyncEvent);\n }\n\n override setName(name: string): void {\n super.setName(name);\n this.#processInternal.setThreadByName(name, this);\n }\n\n process(): Process {\n return this.#processInternal;\n }\n\n events(): Event[] {\n return this.#eventsInternal;\n }\n\n asyncEvents(): AsyncEvent[] {\n return this.#asyncEventsInternal;\n }\n\n removeEventsByName(name: string): Event[] {\n const extracted: Event[] = [];\n this.#eventsInternal = this.#eventsInternal.filter(e => {\n if (!e) {\n return false;\n }\n\n if (e.name !== name) {\n return true;\n }\n\n extracted.push(e);\n return false;\n });\n\n return extracted;\n }\n}\n\nexport interface TimesForEventMs {\n startTime: Types.Timing.MilliSeconds;\n endTime?: Types.Timing.MilliSeconds;\n selfTime: Types.Timing.MilliSeconds;\n duration: Types.Timing.MilliSeconds;\n}\n\nexport function timesForEventInMilliseconds(event: Event|Types.TraceEvents.TraceEventData): TimesForEventMs {\n if (event instanceof Event) {\n return {\n startTime: Types.Timing.MilliSeconds(event.startTime),\n endTime: event.endTime ? Types.Timing.MilliSeconds(event.endTime) : undefined,\n duration: Types.Timing.MilliSeconds(event.duration || 0),\n selfTime: Types.Timing.MilliSeconds(event.selfTime),\n };\n }\n return Helpers.Timing.eventTimingsMilliSeconds(event);\n}\n// Parsed categories are cached to prevent calling cat.split() multiple\n// times on the same categories string.\nconst parsedCategories = new Map<string, Set<string>>();\nexport function eventHasCategory(event: CompatibleTraceEvent, category: string): boolean {\n if (event instanceof Event) {\n return event.hasCategory(category);\n }\n let parsedCategoriesForEvent = parsedCategories.get(event.cat);\n if (!parsedCategoriesForEvent) {\n parsedCategoriesForEvent = new Set(event.cat.split(',') || []);\n }\n return parsedCategoriesForEvent.has(category);\n}\n\nexport function phaseForEvent(event: Event|Types.TraceEvents.TraceEventData): Types.TraceEvents.Phase {\n if (event instanceof Event) {\n return event.phase;\n }\n return event.ph;\n}\n\nexport function threadIDForEvent(event: Event|Types.TraceEvents.TraceEventData): Types.TraceEvents.ThreadID {\n if (event instanceof Event) {\n return event.thread.idInternal as Types.TraceEvents.ThreadID;\n }\n return event.tid;\n}\n\nexport function eventIsFromNewEngine(event: CompatibleTraceEvent|null): event is Types.TraceEvents.TraceEventData {\n return event !== null && !(event instanceof Event);\n}\n\nexport type CompatibleTraceEvent = Event|Types.TraceEvents.TraceEventData;\n"]}
1
+ {"version":3,"file":"LegacyTracingModel.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/LegacyTracingModel.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAC7B,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,yCAAyC;AAEzC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAM1C,MAAM,OAAO,YAAY;IACd,MAAM,CAAmB;IACzB,YAAY,CAA8B;IAC1C,cAAc,CAAuB;IAC9C,0BAA0B,CAAS;IACnC,0BAA0B,CAAS;IAC1B,+BAA+B,CAAU;IAClD,YAAY,CAAe;IAClB,gBAAgB,CAA0B;IAC1C,wBAAwB,CAA4B;IACpD,cAAc,CAAkC;IAChD,iBAAiB,CAA2B;IAC5C,iBAAiB,GAAmB,EAAE,CAAC;IAEhD,YAAY,KAAc;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE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,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/D,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,wBAAwB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAA6C;IACzE,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC,EAAE,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA6C;IAC5E,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,UAAwC,CAAC;IAC/D,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC;AACrD,CAAC","sourcesContent":["// Copyright 2014 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n//\n// This is what was SDK.TracingModel moved into models/trace to avoid circular\n// dependency issues. Our ultimate goal is to remove this model entirely once\n// the migration to the new model is done\n\nimport * as Helpers from './helpers/helpers.js';\nimport {type EventPayload} from './TracingManager.js';\nimport * as Types from './types/types.js';\n\ntype IgnoreListArgs = {\n [key: string]: string|number|ObjectSnapshot,\n};\n\nexport class TracingModel {\n readonly #title: string|undefined;\n readonly #processById: Map<string|number, Process>;\n readonly #processByName: Map<string, Process>;\n #minimumRecordTimeInternal: number;\n #maximumRecordTimeInternal: number;\n readonly #devToolsMetadataEventsInternal: Event[];\n #asyncEvents: AsyncEvent[];\n readonly #openAsyncEvents: Map<string, AsyncEvent>;\n readonly #openNestableAsyncEvents: Map<string, AsyncEvent[]>;\n readonly #profileGroups: Map<string, ProfileEventsGroup>;\n readonly #parsedCategories: Map<string, Set<string>>;\n readonly #allEventsPayload: EventPayload[] = [];\n\n constructor(title?: string) {\n this.#title = title;\n this.#processById = new Map();\n this.#processByName = new Map();\n this.#minimumRecordTimeInternal = Number(Infinity);\n this.#maximumRecordTimeInternal = Number(-Infinity);\n this.#devToolsMetadataEventsInternal = [];\n this.#asyncEvents = [];\n this.#openAsyncEvents = new Map();\n this.#openNestableAsyncEvents = new Map();\n this.#profileGroups = new Map();\n this.#parsedCategories = new Map();\n }\n\n static isTopLevelEvent(event: CompatibleTraceEvent): boolean {\n return eventHasCategory(event, DevToolsTimelineEventCategory) && event.name === 'RunTask' ||\n eventHasCategory(event, LegacyTopLevelEventCategory) ||\n eventHasCategory(event, DevToolsMetadataEventCategory) &&\n event.name === 'Program'; // Older timelines may have this instead of toplevel.\n }\n\n static extractId(payload: EventPayload): string|undefined {\n const scope = payload.scope || '';\n if (typeof payload.id2 === 'undefined') {\n return scope && payload.id ? `${scope}@${payload.id}` : payload.id;\n }\n const id2 = payload.id2;\n if (typeof id2 === 'object' && ('global' in id2) !== ('local' in id2)) {\n return typeof id2['global'] !== 'undefined' ? `:${scope}:${id2['global']}` :\n `:${scope}:${payload.pid}:${id2['local']}`;\n }\n console.error(\n `Unexpected id2 field at ${payload.ts / 1000}, one and only one of 'local' and 'global' should be present.`);\n return undefined;\n }\n\n static browserMainThread(tracingModel: TracingModel): Thread|null {\n const processes = tracingModel.sortedProcesses();\n // Avoid warning for an empty #model.\n if (!processes.length) {\n return null;\n }\n const browserMainThreadName = 'CrBrowserMain';\n const browserProcesses = [];\n const browserMainThreads = [];\n for (const process of processes) {\n if (process.name().toLowerCase().endsWith('browser')) {\n browserProcesses.push(process);\n }\n browserMainThreads.push(...process.sortedThreads().filter(t => t.name() === browserMainThreadName));\n }\n if (browserMainThreads.length === 1) {\n return browserMainThreads[0];\n }\n if (browserProcesses.length === 1) {\n return browserProcesses[0].threadByName(browserMainThreadName);\n }\n const tracingStartedInBrowser =\n tracingModel.devToolsMetadataEvents().filter(e => e.name === 'TracingStartedInBrowser');\n if (tracingStartedInBrowser.length === 1) {\n return tracingStartedInBrowser[0].thread;\n }\n console.error(\n 'Failed to find browser main thread in trace, some timeline features may be unavailable');\n return null;\n }\n\n allRawEvents(): readonly EventPayload[] {\n return this.#allEventsPayload;\n }\n\n devToolsMetadataEvents(): Event[] {\n return this.#devToolsMetadataEventsInternal;\n }\n\n addEvents(events: readonly EventPayload[]): void {\n for (let i = 0; i < events.length; ++i) {\n this.addEvent(events[i]);\n }\n }\n\n tracingComplete(): void {\n this.processPendingAsyncEvents();\n for (const process of this.#processById.values()) {\n for (const thread of process.threads.values()) {\n thread.tracingComplete();\n }\n }\n }\n\n private addEvent(payload: EventPayload): void {\n this.#allEventsPayload.push(payload);\n let process = this.#processById.get(payload.pid);\n if (!process) {\n process = new Process(this, payload.pid);\n this.#processById.set(payload.pid, process);\n }\n\n const timestamp = payload.ts / 1000;\n // We do allow records for unrelated threads to arrive out-of-order,\n // so there's a chance we're getting records from the past.\n if (timestamp && timestamp < this.#minimumRecordTimeInternal &&\n eventPhasesOfInterestForTraceBounds.has(payload.ph as Types.TraceEvents.Phase) &&\n // UMA related events are ignored when calculating the minimumRecordTime because they might\n // be related to previous navigations that happened before the current trace started and\n // will currently not be displayed anyways.\n // See crbug.com/1201198\n (!payload.name.endsWith('::UMA'))) {\n this.#minimumRecordTimeInternal = timestamp;\n }\n\n if (payload.name === 'TracingStartedInBrowser') {\n // If we received a timestamp for tracing start, use that for minimumRecordTime.\n this.#minimumRecordTimeInternal = timestamp;\n }\n\n if (eventPhasesOfInterestForTraceBounds.has(payload.ph as Types.TraceEvents.Phase)) {\n const endTimeStamp = (payload.ts + (payload.dur || 0)) / 1000;\n this.#maximumRecordTimeInternal = Math.max(this.#maximumRecordTimeInternal, endTimeStamp);\n }\n const event = process.addEvent(payload);\n if (!event) {\n return;\n }\n if (payload.ph === Types.TraceEvents.Phase.SAMPLE) {\n this.addSampleEvent(event);\n return;\n }\n // Build async event when we've got events from all threads & processes, so we can sort them and process in the\n // chronological order. However, also add individual async events to the thread flow (above), so we can easily\n // display them on the same chart as other events, should we choose so.\n if (Types.TraceEvents.isAsyncPhase(payload.ph)) {\n this.#asyncEvents.push((event as AsyncEvent));\n }\n if (event.hasCategory(DevToolsMetadataEventCategory)) {\n this.#devToolsMetadataEventsInternal.push(event);\n }\n\n if (payload.ph !== Types.TraceEvents.Phase.METADATA) {\n return;\n }\n\n switch (payload.name) {\n case MetadataEvent.ProcessSortIndex: {\n process.setSortIndex(payload.args['sort_index']);\n break;\n }\n case MetadataEvent.ProcessName: {\n const processName = payload.args['name'];\n process.setName(processName);\n this.#processByName.set(processName, process);\n break;\n }\n case MetadataEvent.ThreadSortIndex: {\n process.threadById(payload.tid).setSortIndex(payload.args['sort_index']);\n break;\n }\n case MetadataEvent.ThreadName: {\n process.threadById(payload.tid).setName(payload.args['name']);\n break;\n }\n }\n }\n\n private addSampleEvent(event: Event): void {\n const id = `${event.thread.process().id()}:${event.id}`;\n const group = this.#profileGroups.get(id);\n if (group) {\n group.addChild(event);\n } else {\n this.#profileGroups.set(id, new ProfileEventsGroup(event));\n }\n }\n\n profileGroup(event: Event): ProfileEventsGroup|null {\n return this.#profileGroups.get(`${event.thread.process().id()}:${event.id}`) || null;\n }\n\n minimumRecordTime(): number {\n return this.#minimumRecordTimeInternal;\n }\n\n sortedProcesses(): Process[] {\n return NamedObject.sort([...this.#processById.values()]);\n }\n\n getProcessByName(name: string): Process|null {\n return this.#processByName.get(name) ?? null;\n }\n\n getProcessById(pid: number): Process|null {\n return this.#processById.get(pid) || null;\n }\n\n getThreadByName(processName: string, threadName: string): Thread|null {\n const process = this.getProcessByName(processName);\n return process && process.threadByName(threadName);\n }\n\n private processPendingAsyncEvents(): void {\n this.#asyncEvents.sort(Event.compareStartTime);\n for (let i = 0; i < this.#asyncEvents.length; ++i) {\n const event = this.#asyncEvents[i];\n if (Types.TraceEvents.isNestableAsyncPhase(event.phase)) {\n this.addNestableAsyncEvent(event);\n } else {\n this.addAsyncEvent(event);\n }\n }\n this.#asyncEvents = [];\n this.closeOpenAsyncEvents();\n }\n\n private closeOpenAsyncEvents(): void {\n for (const event of this.#openAsyncEvents.values()) {\n event.setEndTime(this.#maximumRecordTimeInternal);\n // FIXME: remove this once we figure a better way to convert async console\n // events to sync [waterfall] timeline records.\n event.steps[0].setEndTime(this.#maximumRecordTimeInternal);\n }\n this.#openAsyncEvents.clear();\n\n for (const eventStack of this.#openNestableAsyncEvents.values()) {\n while (eventStack.length) {\n const event = eventStack.pop();\n if (!event) {\n continue;\n }\n event.setEndTime(this.#maximumRecordTimeInternal);\n }\n }\n this.#openNestableAsyncEvents.clear();\n }\n\n private addNestableAsyncEvent(event: Event): void {\n const key = event.categoriesString + '.' + event.id;\n let openEventsStack = this.#openNestableAsyncEvents.get(key);\n\n switch (event.phase) {\n case Types.TraceEvents.Phase.ASYNC_NESTABLE_START: {\n if (!openEventsStack) {\n openEventsStack = [];\n this.#openNestableAsyncEvents.set(key, openEventsStack);\n }\n const asyncEvent = new AsyncEvent(event);\n openEventsStack.push(asyncEvent);\n event.thread.addAsyncEvent(asyncEvent);\n break;\n }\n\n case Types.TraceEvents.Phase.ASYNC_NESTABLE_INSTANT: {\n if (openEventsStack && openEventsStack.length) {\n const event = openEventsStack[openEventsStack.length - 1];\n if (event) {\n event.addStep(event);\n }\n }\n break;\n }\n\n case Types.TraceEvents.Phase.ASYNC_NESTABLE_END: {\n if (!openEventsStack || !openEventsStack.length) {\n break;\n }\n const top = openEventsStack.pop();\n if (!top) {\n break;\n }\n if (top.name !== event.name) {\n console.error(\n `Begin/end event mismatch for nestable async event, ${top.name} vs. ${event.name}, key: ${key}`);\n break;\n }\n top.addStep(event);\n }\n }\n }\n\n private addAsyncEvent(event: Event): void {\n const key = event.categoriesString + '.' + event.name + '.' + event.id;\n let asyncEvent = this.#openAsyncEvents.get(key);\n\n if (event.phase === Types.TraceEvents.Phase.ASYNC_BEGIN) {\n if (asyncEvent) {\n console.error(`Event ${event.name} has already been started`);\n return;\n }\n asyncEvent = new AsyncEvent(event);\n this.#openAsyncEvents.set(key, asyncEvent);\n event.thread.addAsyncEvent(asyncEvent);\n return;\n }\n if (!asyncEvent) {\n // Quietly ignore stray async events, we're probably too late for the start.\n return;\n }\n if (event.phase === Types.TraceEvents.Phase.ASYNC_END) {\n asyncEvent.addStep(event);\n this.#openAsyncEvents.delete(key);\n return;\n }\n if (event.phase === Types.TraceEvents.Phase.ASYNC_STEP_INTO ||\n event.phase === Types.TraceEvents.Phase.ASYNC_STEP_PAST) {\n const lastStep = asyncEvent.steps[asyncEvent.steps.length - 1];\n if (lastStep && lastStep.phase !== Types.TraceEvents.Phase.ASYNC_BEGIN && lastStep.phase !== event.phase) {\n console.assert(\n false,\n 'Async event step phase mismatch: ' + lastStep.phase + ' at ' + lastStep.startTime + ' vs. ' + event.phase +\n ' at ' + event.startTime);\n return;\n }\n asyncEvent.addStep(event);\n return;\n }\n console.assert(false, 'Invalid async event phase');\n }\n\n title(): string|undefined {\n return this.#title;\n }\n\n parsedCategoriesForString(str: string): Set<string> {\n let parsedCategories = this.#parsedCategories.get(str);\n if (!parsedCategories) {\n parsedCategories = new Set(str ? str.split(',') : []);\n this.#parsedCategories.set(str, parsedCategories);\n }\n return parsedCategories;\n }\n}\n\nexport const eventPhasesOfInterestForTraceBounds: Set<Types.TraceEvents.Phase> = new Set([\n Types.TraceEvents.Phase.BEGIN,\n Types.TraceEvents.Phase.END,\n Types.TraceEvents.Phase.COMPLETE,\n Types.TraceEvents.Phase.INSTANT,\n]);\n\nexport const MetadataEvent = {\n ProcessSortIndex: 'process_sort_index',\n ProcessName: 'process_name',\n ThreadSortIndex: 'thread_sort_index',\n ThreadName: 'thread_name',\n};\n\n// TODO(alph): LegacyTopLevelEventCategory is not recorded since M74 and used for loading\n// legacy profiles. Drop at some point.\nexport const LegacyTopLevelEventCategory = 'toplevel';\n\nexport const DevToolsMetadataEventCategory = 'disabled-by-default-devtools.timeline';\nexport const DevToolsTimelineEventCategory = 'disabled-by-default-devtools.timeline';\n\nexport function eventHasPayload(event: Event): event is PayloadEvent {\n return 'rawPayload' in event;\n}\n\nexport class Event {\n categoriesString: string;\n readonly #parsedCategories: Set<string>;\n name: string;\n phase: Types.TraceEvents.Phase;\n startTime: number;\n thread: Thread;\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n args: any;\n id!: string|null;\n ordinal: number;\n selfTime: number;\n endTime?: number;\n duration?: number;\n\n // The constructor is protected so that we ensure that only classes or\n // subclasses can directly instantiate events. All other callers should\n // either create ConstructedEvent instances, which have a public constructor,\n // or use the static fromPayload method which can create an event instance\n // from the trace payload.\n protected constructor(\n categories: string|undefined, name: string, phase: Types.TraceEvents.Phase, startTime: number, thread: Thread) {\n this.categoriesString = categories || '';\n this.#parsedCategories = thread.getModel().parsedCategoriesForString(this.categoriesString);\n this.name = name;\n this.phase = phase;\n this.startTime = startTime;\n this.thread = thread;\n this.args = {};\n this.ordinal = 0;\n\n this.selfTime = 0;\n }\n\n static compareStartTime(a: Event|null, b: Event|null): number {\n if (!a || !b) {\n return 0;\n }\n\n return a.startTime - b.startTime;\n }\n\n static orderedCompareStartTime(a: Event, b: Event): number {\n // Array.mergeOrdered coalesces objects if comparator returns 0.\n // To change this behavior this comparator return -1 in the case events\n // startTime's are equal, so both events got placed into the result array.\n return a.startTime - b.startTime || a.ordinal - b.ordinal || -1;\n }\n\n hasCategory(categoryName: string): boolean {\n return this.#parsedCategories.has(categoryName);\n }\n\n setEndTime(endTime: number): void {\n if (endTime < this.startTime) {\n console.assert(false, 'Event out of order: ' + this.name);\n return;\n }\n this.endTime = endTime;\n this.duration = endTime - this.startTime;\n }\n\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n addArgs(args: any): void {\n // Shallow copy args to avoid modifying original #payload which may be saved to file.\n for (const name in args) {\n if (name in this.args) {\n console.error('Same argument name (' + name + ') is used for begin and end phases of ' + this.name);\n }\n\n (this.args as IgnoreListArgs)[name] = (args as IgnoreListArgs)[name];\n }\n }\n\n complete(endEvent: Event): void {\n if (endEvent.args) {\n this.addArgs(endEvent.args);\n } else {\n console.error('Missing mandatory event argument \\'args\\' at ' + endEvent.startTime);\n }\n this.setEndTime(endEvent.startTime);\n }\n}\n\n/**\n * Represents a tracing event that is not directly linked to an individual\n * object in the trace. We construct these events at times, particularly when\n * building up the CPU profile data for JS Profiling.\n **/\nexport class ConstructedEvent extends Event {\n // Because the constructor of Event is marked as protected, but we want\n // people to be able to create constructed events, we override the\n // constructor here, even though we are only calling super, in order to mark\n // it as public.\n constructor(\n categories: string|undefined, name: string, phase: Types.TraceEvents.Phase, startTime: number, thread: Thread) {\n super(categories, name, phase, startTime, thread);\n }\n}\n\n/**\n * Represents a tracing event that has been created directly from an object in\n * the trace file and therefore is guaranteed to have a payload associated with\n * it. The only way to create these events is to use the static fromPayload\n * method, which you must call with a payload.\n **/\nexport class PayloadEvent extends Event {\n #rawPayload: EventPayload;\n\n /**\n * Returns the raw payload that was used to create this event instance.\n **/\n rawLegacyPayload(): EventPayload {\n return this.#rawPayload;\n }\n\n /**\n * Returns the raw payload that was used to create this event instance, but\n * returns it typed as the new engine's TraceEventArgs option.\n **/\n rawPayload(): Types.TraceEvents.TraceEventData {\n return this.#rawPayload as unknown as Types.TraceEvents.TraceEventData;\n }\n\n protected constructor(\n categories: string|undefined, name: string, phase: Types.TraceEvents.Phase, startTime: number, thread: Thread,\n rawPayload: EventPayload) {\n super(categories, name, phase, startTime, thread);\n this.#rawPayload = rawPayload;\n }\n\n static fromPayload(payload: EventPayload, thread: Thread): PayloadEvent {\n const event = new PayloadEvent(payload.cat, payload.name, payload.ph, payload.ts / 1000, thread, payload);\n event.#rawPayload = payload;\n if (payload.args) {\n event.addArgs(payload.args);\n }\n if (typeof payload.dur === 'number') {\n event.setEndTime((payload.ts + payload.dur) / 1000);\n }\n const id = TracingModel.extractId(payload);\n if (typeof id !== 'undefined') {\n event.id = id;\n }\n\n return event;\n }\n}\n\nexport class ObjectSnapshot extends PayloadEvent {\n private constructor(\n category: string|undefined, name: string, startTime: number, thread: Thread, rawPayload: EventPayload) {\n super(category, name, Types.TraceEvents.Phase.OBJECT_SNAPSHOT, startTime, thread, rawPayload);\n }\n\n static override fromPayload(payload: EventPayload, thread: Thread): ObjectSnapshot {\n const snapshot = new ObjectSnapshot(payload.cat, payload.name, payload.ts / 1000, thread, payload);\n const id = TracingModel.extractId(payload);\n if (typeof id !== 'undefined') {\n snapshot.id = id;\n }\n if (!payload.args || !payload.args['snapshot']) {\n console.error('Missing mandatory \\'snapshot\\' argument at ' + payload.ts / 1000);\n return snapshot;\n }\n if (payload.args) {\n snapshot.addArgs(payload.args);\n }\n return snapshot;\n }\n\n getSnapshot(): ObjectSnapshot {\n const snapshot = this.args['snapshot'];\n if (!snapshot) {\n throw new Error('ObjectSnapshot has no snapshot argument.');\n }\n return snapshot;\n }\n}\n\nexport class AsyncEvent extends ConstructedEvent {\n steps: Event[];\n causedFrame: boolean;\n\n constructor(startEvent: Event) {\n super(startEvent.categoriesString, startEvent.name, startEvent.phase, startEvent.startTime, startEvent.thread);\n this.addArgs(startEvent.args);\n this.steps = [startEvent];\n this.causedFrame = false;\n }\n\n addStep(event: Event): void {\n this.steps.push(event);\n if (event.phase === Types.TraceEvents.Phase.ASYNC_END ||\n event.phase === Types.TraceEvents.Phase.ASYNC_NESTABLE_END) {\n this.setEndTime(event.startTime);\n // FIXME: ideally, we shouldn't do this, but this makes the logic of converting\n // async console events to sync ones much simpler.\n this.steps[0].setEndTime(event.startTime);\n }\n }\n}\n\nclass ProfileEventsGroup {\n children: Event[];\n constructor(event: Event) {\n this.children = [event];\n }\n\n addChild(event: Event): void {\n this.children.push(event);\n }\n}\n\nclass NamedObject {\n model: TracingModel;\n readonly idInternal: number;\n #nameInternal: string;\n #sortIndex: number;\n constructor(model: TracingModel, id: number) {\n this.model = model;\n this.idInternal = id;\n this.#nameInternal = '';\n this.#sortIndex = 0;\n }\n\n static sort<Item extends NamedObject>(array: Item[]): Item[] {\n return array.sort((a, b) => {\n return a.#sortIndex !== b.#sortIndex ? a.#sortIndex - b.#sortIndex : a.name().localeCompare(b.name());\n });\n }\n\n setName(name: string): void {\n this.#nameInternal = name;\n }\n\n name(): string {\n return this.#nameInternal;\n }\n\n id(): number {\n return this.idInternal;\n }\n\n setSortIndex(sortIndex: number): void {\n this.#sortIndex = sortIndex;\n }\n\n getModel(): TracingModel {\n return this.model;\n }\n}\n\nexport class Process extends NamedObject {\n readonly threads: Map<number, Thread>;\n readonly #threadByNameInternal: Map<string, Thread|null>;\n constructor(model: TracingModel, id: number) {\n super(model, id);\n this.threads = new Map();\n this.#threadByNameInternal = new Map();\n }\n\n threadById(id: number): Thread {\n let thread = this.threads.get(id);\n if (!thread) {\n thread = new Thread(this, id);\n this.threads.set(id, thread);\n }\n return thread;\n }\n\n threadByName(name: string): Thread|null {\n return this.#threadByNameInternal.get(name) || null;\n }\n\n setThreadByName(name: string, thread: Thread): void {\n this.#threadByNameInternal.set(name, thread);\n }\n\n addEvent(payload: EventPayload): Event|null {\n return this.threadById(payload.tid).addEvent(payload);\n }\n\n sortedThreads(): Thread[] {\n return NamedObject.sort([...this.threads.values()]);\n }\n}\n\nexport class Thread extends NamedObject {\n readonly #processInternal: Process;\n #eventsInternal: Event[];\n readonly #asyncEventsInternal: AsyncEvent[];\n #lastTopLevelEvent: Event|null;\n constructor(process: Process, id: number) {\n super(process.getModel(), id);\n this.#processInternal = process;\n\n this.#eventsInternal = [];\n this.#asyncEventsInternal = [];\n this.#lastTopLevelEvent = null;\n }\n\n /**\n * Whilst we are in the middle of migrating to the new Phase enum, we need to\n * be able to compare events with the legacy phase to the new enum. This method\n * does this by casting the event phase to a string, ensuring we can compare it\n * against either enum. Once the migration is complete (crbug.com/1417587), we\n * will be able to use === to compare with no TS errors and this method can be\n * removed.\n */\n #eventMatchesPhase(event: Event, phase: Types.TraceEvents.Phase): boolean {\n return (event.phase as string) === phase;\n }\n\n tracingComplete(): void {\n this.#asyncEventsInternal.sort(Event.compareStartTime);\n this.#eventsInternal.sort(Event.compareStartTime);\n const stack: Event[] = [];\n const toDelete = new Set<number>();\n for (let i = 0; i < this.#eventsInternal.length; ++i) {\n const e = this.#eventsInternal[i];\n e.ordinal = i;\n if (this.#eventMatchesPhase(e, Types.TraceEvents.Phase.END)) {\n toDelete.add(i); // Mark for removal.\n // Quietly ignore unbalanced close events, they're legit (we could have missed start one).\n if (!stack.length) {\n continue;\n }\n const top = stack.pop();\n if (!top) {\n continue;\n }\n if (top.name !== e.name || top.categoriesString !== e.categoriesString) {\n console.error(\n 'B/E events mismatch at ' + top.startTime + ' (' + top.name + ') vs. ' + e.startTime + ' (' + e.name +\n ')');\n } else {\n top.complete(e);\n }\n } else if (this.#eventMatchesPhase(e, Types.TraceEvents.Phase.BEGIN)) {\n stack.push(e);\n }\n }\n\n // Handle Begin events with no matching End.\n // This commonly happens due to a bug in the trace machinery. See crbug.com/982252\n while (stack.length) {\n const event = stack.pop();\n if (event) {\n // Masquerade the event as Instant, so it's rendered to the user.\n // The ideal fix is resolving crbug.com/1021571, but handling that without a perfetto migration appears prohibitive\n event.phase = Types.TraceEvents.Phase.INSTANT;\n }\n }\n this.#eventsInternal = this.#eventsInternal.filter((_, idx) => !toDelete.has(idx));\n }\n\n addEvent(payload: EventPayload): Event|null {\n const event = payload.ph === Types.TraceEvents.Phase.OBJECT_SNAPSHOT ? ObjectSnapshot.fromPayload(payload, this) :\n PayloadEvent.fromPayload(payload, this);\n if (TracingModel.isTopLevelEvent(event)) {\n // Discard nested \"top-level\" events.\n const lastTopLevelEvent = this.#lastTopLevelEvent;\n if (lastTopLevelEvent && (lastTopLevelEvent.endTime || 0) > event.startTime) {\n return null;\n }\n this.#lastTopLevelEvent = event;\n }\n this.#eventsInternal.push(event);\n return event;\n }\n\n addAsyncEvent(asyncEvent: AsyncEvent): void {\n this.#asyncEventsInternal.push(asyncEvent);\n }\n\n override setName(name: string): void {\n super.setName(name);\n this.#processInternal.setThreadByName(name, this);\n }\n\n process(): Process {\n return this.#processInternal;\n }\n\n events(): Event[] {\n return this.#eventsInternal;\n }\n\n asyncEvents(): AsyncEvent[] {\n return this.#asyncEventsInternal;\n }\n\n removeEventsByName(name: string): Event[] {\n const extracted: Event[] = [];\n this.#eventsInternal = this.#eventsInternal.filter(e => {\n if (!e) {\n return false;\n }\n\n if (e.name !== name) {\n return true;\n }\n\n extracted.push(e);\n return false;\n });\n\n return extracted;\n }\n}\n\nexport interface TimesForEventMs {\n startTime: Types.Timing.MilliSeconds;\n endTime?: Types.Timing.MilliSeconds;\n selfTime: Types.Timing.MilliSeconds;\n duration: Types.Timing.MilliSeconds;\n}\n\nexport function timesForEventInMilliseconds(event: Event|Types.TraceEvents.TraceEventData): TimesForEventMs {\n if (event instanceof Event) {\n return {\n startTime: Types.Timing.MilliSeconds(event.startTime),\n endTime: event.endTime ? Types.Timing.MilliSeconds(event.endTime) : undefined,\n duration: Types.Timing.MilliSeconds(event.duration || 0),\n selfTime: Types.Timing.MilliSeconds(event.selfTime),\n };\n }\n return Helpers.Timing.eventTimingsMilliSeconds(event);\n}\n// Parsed categories are cached to prevent calling cat.split() multiple\n// times on the same categories string.\nconst parsedCategories = new Map<string, Set<string>>();\nexport function eventHasCategory(event: CompatibleTraceEvent, category: string): boolean {\n if (event instanceof Event) {\n return event.hasCategory(category);\n }\n let parsedCategoriesForEvent = parsedCategories.get(event.cat);\n if (!parsedCategoriesForEvent) {\n parsedCategoriesForEvent = new Set(event.cat.split(',') || []);\n }\n return parsedCategoriesForEvent.has(category);\n}\n\nexport function phaseForEvent(event: Event|Types.TraceEvents.TraceEventData): Types.TraceEvents.Phase {\n if (event instanceof Event) {\n return event.phase;\n }\n return event.ph;\n}\n\nexport function threadIDForEvent(event: Event|Types.TraceEvents.TraceEventData): Types.TraceEvents.ThreadID {\n if (event instanceof Event) {\n return event.thread.idInternal as Types.TraceEvents.ThreadID;\n }\n return event.tid;\n}\n\nexport function eventIsFromNewEngine(event: CompatibleTraceEvent|null): event is Types.TraceEvents.TraceEventData {\n return event !== null && !(event instanceof Event);\n}\n\nexport type CompatibleTraceEvent = Event|Types.TraceEvents.TraceEventData;\n"]}
@@ -65,6 +65,7 @@ export declare class Model<EnabledModelHandlers extends {
65
65
  traceParsedData(index?: number): Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers> | null;
66
66
  traceInsights(index?: number): Insights.Types.TraceInsightData<EnabledModelHandlers> | null;
67
67
  metadata(index: number): Types.File.MetaData | null;
68
+ overrideAnnotations(index: number, newAnnotations: Types.File.Annotations): void;
68
69
  traceEvents(index: number): readonly Types.TraceEvents.TraceEventData[] | null;
69
70
  size(): number;
70
71
  deleteTraceByIndex(recordingIndex: number): void;
@@ -146,6 +146,11 @@ export class Model extends EventTarget {
146
146
  }
147
147
  return this.#traces[index].metadata;
148
148
  }
149
+ overrideAnnotations(index, newAnnotations) {
150
+ if (this.#traces[index]) {
151
+ this.#traces[index].metadata.annotations = newAnnotations;
152
+ }
153
+ }
149
154
  traceEvents(index) {
150
155
  if (!this.#traces[index]) {
151
156
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"ModelImpl.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/ModelImpl.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAE5D,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACv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B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;IACtC,CAAC;IAED,WAAW,CAAC,KAAa;QACvB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC;IACzC,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,kBAAkB,CAAC,cAAsB;QACvC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,sBAAsB;QACpB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF;AAiCD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAEtB;IADnB,MAAM,CAAU,SAAS,GAAG,aAAa,CAAC;IAC1C,YAAmB,IAA0B;QAC3C,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QADjB,SAAI,GAAJ,IAAI,CAAsB;IAE7C,CAAC;;AASH,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,8CAA6B,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,4DAAoC,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../core/platform/platform.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport type * as Insights from './insights/insights.js';\nimport {TraceParseProgressEvent, TraceProcessor} from './Processor.js';\nimport * as Types from './types/types.js';\n\n// Note: this model is implemented in a way that can support multiple trace\n// processors. Currently there is only one implemented, but you will see\n// references to \"processors\" plural because it can easily be extended in the future.\n\nexport interface ParseConfig {\n metadata?: Types.File.MetaData;\n // Unused but will eventually be consumed by UIUtils Linkifier, etc.\n isFreshRecording?: boolean;\n}\n\n/**\n * The new trace engine model we are migrating to. The Model is responsible for\n * parsing arrays of raw trace events and storing the resulting data. It can\n * store multiple traces at once, and can return the data for any of them.\n * Currently as we migrate from the old engine to this, we are turning on the\n * model handlers incrementally as we need the data, to save performance costs\n * of running handlers that we do not use. Therefore, when the model is\n * constructed we pass through a set of handlers that should be used. Once we\n * have migrated all tracks in the Performance Panel to this model, we can\n * remove this ability to run a subset of handlers, as we will need all handlers\n * to be used at that point. For tests, if you want to construct a model with\n * all handlers, you can use the static `Model.createWithAllHandlers` method.\n **/\nexport class Model<EnabledModelHandlers extends {[key: string]: Handlers.Types.TraceEventHandler}> extends EventTarget {\n readonly #traces: ParsedTraceFile<EnabledModelHandlers>[] = [];\n readonly #nextNumberByDomain = new Map<string, number>();\n\n readonly #recordingsAvailable: string[] = [];\n #lastRecordingIndex = 0;\n #processor: TraceProcessor<Handlers.Types.HandlersWithMeta<EnabledModelHandlers>>;\n #config: Types.Configuration.Configuration = Types.Configuration.DEFAULT;\n\n static createWithAllHandlers(config?: Types.Configuration.Configuration): Model<typeof Handlers.ModelHandlers> {\n return new Model(Handlers.ModelHandlers, config);\n }\n\n constructor(handlers: EnabledModelHandlers, config?: Types.Configuration.Configuration) {\n super();\n if (config) {\n this.#config = config;\n }\n this.#processor = new TraceProcessor(handlers, this.#config);\n }\n\n /**\n * Updates the configuration. Useful if a user changes a setting - this lets\n * us update the model without having to destroy it and recreate it with the\n * new settings.\n */\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#config = config;\n this.#processor.updateConfiguration(config);\n }\n\n /**\n * Parses an array of trace events into a structured object containing all the\n * information parsed by the trace handlers.\n * You can `await` this function to pause execution until parsing is complete,\n * or instead rely on the `ModuleUpdateEvent` that is dispatched when the\n * parsing is finished.\n *\n * Once parsed, you then have to call the `traceParsedData` method, providing an\n * index of the trace you want to have the data for. This is because any model\n * can store a number of traces. Each trace is given an index, which starts at 0\n * and increments by one as a new trace is parsed.\n *\n * @example\n * // Awaiting the parse method() to block until parsing complete\n * await this.traceModel.parse(events);\n * const data = this.traceModel.traceParsedData(0)\n *\n * @example\n * // Using an event listener to be notified when tracing is complete.\n * this.traceModel.addEventListener(Trace.ModelUpdateEvent.eventName, (event) => {\n * if(event.data.data === 'done') {\n * // trace complete\n * const data = this.traceModel.traceParsedData(0);\n * }\n * });\n * void this.traceModel.parse(events);\n **/\n async parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], config?: ParseConfig): Promise<void> {\n const metadata = config?.metadata || {};\n const isFreshRecording = config?.isFreshRecording || false;\n // During parsing, periodically update any listeners on each processors'\n // progress (if they have any updates).\n const onTraceUpdate = (event: Event): void => {\n const {data} = event as TraceParseProgressEvent;\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.PROGRESS_UPDATE, data: data}));\n };\n\n this.#processor.addEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n\n // Create a parsed trace file. It will be populated with data from the processor.\n const file: ParsedTraceFile<EnabledModelHandlers> = {\n traceEvents,\n metadata,\n traceParsedData: null,\n traceInsights: null,\n };\n\n try {\n // Wait for all outstanding promises before finishing the async execution,\n // but perform all tasks in parallel.\n await this.#processor.parse(traceEvents, isFreshRecording);\n this.#storeParsedFileData(file, this.#processor.traceParsedData, this.#processor.insights);\n // We only push the file onto this.#traces here once we know it's valid\n // and there's been no errors in the parsing.\n this.#traces.push(file);\n } catch (e) {\n throw e;\n } finally {\n // All processors have finished parsing, no more updates are expected.\n this.#processor.removeEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n // Finally, update any listeners that all processors are 'done'.\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.COMPLETE, data: 'done'}));\n }\n }\n\n #storeParsedFileData(\n file: ParsedTraceFile<EnabledModelHandlers>,\n data: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null,\n insights: Insights.Types.TraceInsightData<EnabledModelHandlers>|null): void {\n file.traceParsedData = data;\n file.traceInsights = insights;\n this.#lastRecordingIndex++;\n let recordingName = `Trace ${this.#lastRecordingIndex}`;\n let origin: string|null = null;\n if (file.traceParsedData) {\n origin = Helpers.Trace.extractOriginFromTrace(file.traceParsedData.Meta.mainFrameURL);\n if (origin) {\n const nextSequenceForDomain = Platform.MapUtilities.getWithDefault(this.#nextNumberByDomain, origin, () => 1);\n recordingName = `${origin} (${nextSequenceForDomain})`;\n this.#nextNumberByDomain.set(origin, nextSequenceForDomain + 1);\n }\n }\n this.#recordingsAvailable.push(recordingName);\n }\n\n /**\n * Returns the parsed trace data indexed by the order in which it was stored.\n * If no index is given, the last stored parsed data is returned.\n */\n traceParsedData(index: number = this.#traces.length - 1):\n Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceParsedData;\n }\n\n traceInsights(index: number = this.#traces.length - 1): Insights.Types.TraceInsightData<EnabledModelHandlers>|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceInsights;\n }\n\n metadata(index: number): Types.File.MetaData|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].metadata;\n }\n\n traceEvents(index: number): readonly Types.TraceEvents.TraceEventData[]|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceEvents;\n }\n\n size(): number {\n return this.#traces.length;\n }\n\n deleteTraceByIndex(recordingIndex: number): void {\n this.#traces.splice(recordingIndex, 1);\n this.#recordingsAvailable.splice(recordingIndex, 1);\n }\n\n getRecordingsAvailable(): string[] {\n return this.#recordingsAvailable;\n }\n\n resetProcessor(): void {\n this.#processor.reset();\n }\n}\n\n/**\n * This parsed trace file is used by the Model. It keeps multiple instances\n * of these so that the user can swap between them. The key is that it is\n * essentially the TraceFile plus whatever the model has parsed from it.\n */\nexport type ParsedTraceFile<Handlers extends {[key: string]: Handlers.Types.TraceEventHandler}> = Types.File.TraceFile&{\n traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<Handlers>| null,\n traceInsights: Insights.Types.TraceInsightData<Handlers>| null,\n};\n\nexport const enum ModelUpdateType {\n COMPLETE = 'COMPLETE',\n PROGRESS_UPDATE = 'PROGRESS_UPDATE',\n}\n\nexport type ModelUpdateEventData = ModelUpdateEventComplete|ModelUpdateEventProgress;\n\nexport type ModelUpdateEventComplete = {\n type: ModelUpdateType.COMPLETE,\n data: 'done',\n};\nexport type ModelUpdateEventProgress = {\n type: ModelUpdateType.PROGRESS_UPDATE,\n data: TraceParseEventProgressData,\n};\n\nexport type TraceParseEventProgressData = {\n index: number,\n total: number,\n};\n\nexport class ModelUpdateEvent extends Event {\n static readonly eventName = 'modelupdate';\n constructor(public data: ModelUpdateEventData) {\n super(ModelUpdateEvent.eventName);\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n [ModelUpdateEvent.eventName]: ModelUpdateEvent;\n }\n}\n\nexport function isModelUpdateDataComplete(eventData: ModelUpdateEventData): eventData is ModelUpdateEventComplete {\n return eventData.type === ModelUpdateType.COMPLETE;\n}\n\nexport function isModelUpdateDataProgress(eventData: ModelUpdateEventData): eventData is ModelUpdateEventProgress {\n return eventData.type === ModelUpdateType.PROGRESS_UPDATE;\n}\n"]}
1
+ {"version":3,"file":"ModelImpl.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/ModelImpl.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAE5D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C;QADjB,SAAI,GAAJ,IAAI,CAAsB;IAE7C,CAAC;;AASH,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,8CAA6B,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,4DAAoC,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../core/platform/platform.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport type * as Insights from './insights/insights.js';\nimport {TraceParseProgressEvent, TraceProcessor} from './Processor.js';\nimport * as Types from './types/types.js';\n\n// Note: this model is implemented in a way that can support multiple trace\n// processors. Currently there is only one implemented, but you will see\n// references to \"processors\" plural because it can easily be extended in the future.\n\nexport interface ParseConfig {\n metadata?: Types.File.MetaData;\n // Unused but will eventually be consumed by UIUtils Linkifier, etc.\n isFreshRecording?: boolean;\n}\n\n/**\n * The new trace engine model we are migrating to. The Model is responsible for\n * parsing arrays of raw trace events and storing the resulting data. It can\n * store multiple traces at once, and can return the data for any of them.\n * Currently as we migrate from the old engine to this, we are turning on the\n * model handlers incrementally as we need the data, to save performance costs\n * of running handlers that we do not use. Therefore, when the model is\n * constructed we pass through a set of handlers that should be used. Once we\n * have migrated all tracks in the Performance Panel to this model, we can\n * remove this ability to run a subset of handlers, as we will need all handlers\n * to be used at that point. For tests, if you want to construct a model with\n * all handlers, you can use the static `Model.createWithAllHandlers` method.\n **/\nexport class Model<EnabledModelHandlers extends {[key: string]: Handlers.Types.TraceEventHandler}> extends EventTarget {\n readonly #traces: ParsedTraceFile<EnabledModelHandlers>[] = [];\n readonly #nextNumberByDomain = new Map<string, number>();\n\n readonly #recordingsAvailable: string[] = [];\n #lastRecordingIndex = 0;\n #processor: TraceProcessor<Handlers.Types.HandlersWithMeta<EnabledModelHandlers>>;\n #config: Types.Configuration.Configuration = Types.Configuration.DEFAULT;\n\n static createWithAllHandlers(config?: Types.Configuration.Configuration): Model<typeof Handlers.ModelHandlers> {\n return new Model(Handlers.ModelHandlers, config);\n }\n\n constructor(handlers: EnabledModelHandlers, config?: Types.Configuration.Configuration) {\n super();\n if (config) {\n this.#config = config;\n }\n this.#processor = new TraceProcessor(handlers, this.#config);\n }\n\n /**\n * Updates the configuration. Useful if a user changes a setting - this lets\n * us update the model without having to destroy it and recreate it with the\n * new settings.\n */\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#config = config;\n this.#processor.updateConfiguration(config);\n }\n\n /**\n * Parses an array of trace events into a structured object containing all the\n * information parsed by the trace handlers.\n * You can `await` this function to pause execution until parsing is complete,\n * or instead rely on the `ModuleUpdateEvent` that is dispatched when the\n * parsing is finished.\n *\n * Once parsed, you then have to call the `traceParsedData` method, providing an\n * index of the trace you want to have the data for. This is because any model\n * can store a number of traces. Each trace is given an index, which starts at 0\n * and increments by one as a new trace is parsed.\n *\n * @example\n * // Awaiting the parse method() to block until parsing complete\n * await this.traceModel.parse(events);\n * const data = this.traceModel.traceParsedData(0)\n *\n * @example\n * // Using an event listener to be notified when tracing is complete.\n * this.traceModel.addEventListener(Trace.ModelUpdateEvent.eventName, (event) => {\n * if(event.data.data === 'done') {\n * // trace complete\n * const data = this.traceModel.traceParsedData(0);\n * }\n * });\n * void this.traceModel.parse(events);\n **/\n async parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], config?: ParseConfig): Promise<void> {\n const metadata = config?.metadata || {};\n const isFreshRecording = config?.isFreshRecording || false;\n // During parsing, periodically update any listeners on each processors'\n // progress (if they have any updates).\n const onTraceUpdate = (event: Event): void => {\n const {data} = event as TraceParseProgressEvent;\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.PROGRESS_UPDATE, data: data}));\n };\n\n this.#processor.addEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n\n // Create a parsed trace file. It will be populated with data from the processor.\n const file: ParsedTraceFile<EnabledModelHandlers> = {\n traceEvents,\n metadata,\n traceParsedData: null,\n traceInsights: null,\n };\n\n try {\n // Wait for all outstanding promises before finishing the async execution,\n // but perform all tasks in parallel.\n await this.#processor.parse(traceEvents, isFreshRecording);\n this.#storeParsedFileData(file, this.#processor.traceParsedData, this.#processor.insights);\n // We only push the file onto this.#traces here once we know it's valid\n // and there's been no errors in the parsing.\n this.#traces.push(file);\n } catch (e) {\n throw e;\n } finally {\n // All processors have finished parsing, no more updates are expected.\n this.#processor.removeEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n // Finally, update any listeners that all processors are 'done'.\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.COMPLETE, data: 'done'}));\n }\n }\n\n #storeParsedFileData(\n file: ParsedTraceFile<EnabledModelHandlers>,\n data: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null,\n insights: Insights.Types.TraceInsightData<EnabledModelHandlers>|null): void {\n file.traceParsedData = data;\n file.traceInsights = insights;\n this.#lastRecordingIndex++;\n let recordingName = `Trace ${this.#lastRecordingIndex}`;\n let origin: string|null = null;\n if (file.traceParsedData) {\n origin = Helpers.Trace.extractOriginFromTrace(file.traceParsedData.Meta.mainFrameURL);\n if (origin) {\n const nextSequenceForDomain = Platform.MapUtilities.getWithDefault(this.#nextNumberByDomain, origin, () => 1);\n recordingName = `${origin} (${nextSequenceForDomain})`;\n this.#nextNumberByDomain.set(origin, nextSequenceForDomain + 1);\n }\n }\n this.#recordingsAvailable.push(recordingName);\n }\n\n /**\n * Returns the parsed trace data indexed by the order in which it was stored.\n * If no index is given, the last stored parsed data is returned.\n */\n traceParsedData(index: number = this.#traces.length - 1):\n Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceParsedData;\n }\n\n traceInsights(index: number = this.#traces.length - 1): Insights.Types.TraceInsightData<EnabledModelHandlers>|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceInsights;\n }\n\n metadata(index: number): Types.File.MetaData|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].metadata;\n }\n\n overrideAnnotations(index: number, newAnnotations: Types.File.Annotations): void {\n if (this.#traces[index]) {\n this.#traces[index].metadata.annotations = newAnnotations;\n }\n }\n\n traceEvents(index: number): readonly Types.TraceEvents.TraceEventData[]|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceEvents;\n }\n\n size(): number {\n return this.#traces.length;\n }\n\n deleteTraceByIndex(recordingIndex: number): void {\n this.#traces.splice(recordingIndex, 1);\n this.#recordingsAvailable.splice(recordingIndex, 1);\n }\n\n getRecordingsAvailable(): string[] {\n return this.#recordingsAvailable;\n }\n\n resetProcessor(): void {\n this.#processor.reset();\n }\n}\n\n/**\n * This parsed trace file is used by the Model. It keeps multiple instances\n * of these so that the user can swap between them. The key is that it is\n * essentially the TraceFile plus whatever the model has parsed from it.\n */\nexport type ParsedTraceFile<Handlers extends {[key: string]: Handlers.Types.TraceEventHandler}> = Types.File.TraceFile&{\n traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<Handlers>| null,\n traceInsights: Insights.Types.TraceInsightData<Handlers>| null,\n};\n\nexport const enum ModelUpdateType {\n COMPLETE = 'COMPLETE',\n PROGRESS_UPDATE = 'PROGRESS_UPDATE',\n}\n\nexport type ModelUpdateEventData = ModelUpdateEventComplete|ModelUpdateEventProgress;\n\nexport type ModelUpdateEventComplete = {\n type: ModelUpdateType.COMPLETE,\n data: 'done',\n};\nexport type ModelUpdateEventProgress = {\n type: ModelUpdateType.PROGRESS_UPDATE,\n data: TraceParseEventProgressData,\n};\n\nexport type TraceParseEventProgressData = {\n index: number,\n total: number,\n};\n\nexport class ModelUpdateEvent extends Event {\n static readonly eventName = 'modelupdate';\n constructor(public data: ModelUpdateEventData) {\n super(ModelUpdateEvent.eventName);\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n [ModelUpdateEvent.eventName]: ModelUpdateEvent;\n }\n}\n\nexport function isModelUpdateDataComplete(eventData: ModelUpdateEventData): eventData is ModelUpdateEventComplete {\n return eventData.type === ModelUpdateType.COMPLETE;\n}\n\nexport function isModelUpdateDataProgress(eventData: ModelUpdateEventData): eventData is ModelUpdateEventProgress {\n return eventData.type === ModelUpdateType.PROGRESS_UPDATE;\n}\n"]}
@@ -9,6 +9,14 @@ export declare function clearCacheForTesting(): void;
9
9
  * first lookup.
10
10
  */
11
11
  export declare function domNodeForBackendNodeID(modelData: Handlers.Types.TraceParseData, nodeId: Protocol.DOM.BackendNodeId): Promise<SDK.DOMModel.DOMNode | null>;
12
+ /**
13
+ * Extracts a set of NodeIds for a given event.
14
+ * NOTE: you probably don't want to call this and instead use
15
+ * `extractRelatedDOMNodesFromEvent`, which will fetch the nodes over CDP.
16
+ * This method is primarily exported so we can test the logic more easily
17
+ * without having to mock the CDP layer.
18
+ **/
19
+ export declare function nodeIdsForEvent(modelData: Handlers.Types.TraceParseData, event: Types.TraceEvents.TraceEventData): Set<Protocol.DOM.BackendNodeId>;
12
20
  /**
13
21
  * Looks up for backend node ids in different types of trace events
14
22
  * and resolves them into related DOM nodes.
@@ -33,6 +33,57 @@ export async function domNodeForBackendNodeID(modelData, nodeId) {
33
33
  domLookUpSingleNodeCache.set(modelData, cacheForModel);
34
34
  return result;
35
35
  }
36
+ const nodeIdsForEventCache = new WeakMap();
37
+ /**
38
+ * Extracts a set of NodeIds for a given event.
39
+ * NOTE: you probably don't want to call this and instead use
40
+ * `extractRelatedDOMNodesFromEvent`, which will fetch the nodes over CDP.
41
+ * This method is primarily exported so we can test the logic more easily
42
+ * without having to mock the CDP layer.
43
+ **/
44
+ export function nodeIdsForEvent(modelData, event) {
45
+ const fromCache = nodeIdsForEventCache.get(event);
46
+ if (fromCache) {
47
+ return fromCache;
48
+ }
49
+ const foundIds = new Set();
50
+ if (Types.TraceEvents.isTraceEventLayout(event)) {
51
+ event.args.endData.layoutRoots.forEach(root => foundIds.add(root.nodeId));
52
+ }
53
+ else if (Types.TraceEvents.isSyntheticLayoutShift(event) && event.args.data?.impacted_nodes) {
54
+ event.args.data.impacted_nodes.forEach(node => foundIds.add(node.node_id));
55
+ }
56
+ else if (Types.TraceEvents.isTraceEventLargestContentfulPaintCandidate(event) &&
57
+ typeof event.args.data?.nodeId !== 'undefined') {
58
+ foundIds.add(event.args.data.nodeId);
59
+ }
60
+ else if (Types.TraceEvents.isTraceEventPaint(event) && typeof event.args.data.nodeId !== 'undefined') {
61
+ foundIds.add(event.args.data.nodeId);
62
+ }
63
+ else if (Types.TraceEvents.isTraceEventPaintImage(event) && typeof event.args.data.nodeId !== 'undefined') {
64
+ foundIds.add(event.args.data.nodeId);
65
+ }
66
+ else if (Types.TraceEvents.isTraceEventScrollLayer(event) && typeof event.args.data.nodeId !== 'undefined') {
67
+ foundIds.add(event.args.data.nodeId);
68
+ }
69
+ else if (Types.TraceEvents.isTraceEventDecodeImage(event)) {
70
+ // For a DecodeImage event, we can use the ImagePaintingHandler, which has
71
+ // done the work to build the relationship between a DecodeImage event and
72
+ // the corresponding PaintImage event.
73
+ const paintImageEvent = modelData.ImagePainting.paintImageForEvent.get(event);
74
+ if (paintImageEvent && typeof paintImageEvent.args.data.nodeId !== 'undefined') {
75
+ foundIds.add(paintImageEvent.args.data.nodeId);
76
+ }
77
+ }
78
+ else if (Types.TraceEvents.isTraceEventDrawLazyPixelRef(event) && event.args?.LazyPixelRef) {
79
+ const paintImageEvent = modelData.ImagePainting.paintImageByDrawLazyPixelRef.get(event.args.LazyPixelRef);
80
+ if (paintImageEvent && typeof paintImageEvent.args.data.nodeId !== 'undefined') {
81
+ foundIds.add(paintImageEvent.args.data.nodeId);
82
+ }
83
+ }
84
+ nodeIdsForEventCache.set(event, foundIds);
85
+ return foundIds;
86
+ }
36
87
  /**
37
88
  * Looks up for backend node ids in different types of trace events
38
89
  * and resolves them into related DOM nodes.
@@ -40,8 +91,9 @@ export async function domNodeForBackendNodeID(modelData, nodeId) {
40
91
  * containing node ids which we want to resolve.
41
92
  */
42
93
  export async function extractRelatedDOMNodesFromEvent(modelData, event) {
43
- if (Types.TraceEvents.isSyntheticLayoutShift(event) && event.args.data?.impacted_nodes) {
44
- return domNodesForMultipleBackendNodeIds(modelData, event.args.data.impacted_nodes.map(node => node.node_id));
94
+ const nodeIds = nodeIdsForEvent(modelData, event);
95
+ if (nodeIds.size) {
96
+ return domNodesForMultipleBackendNodeIds(modelData, Array.from(nodeIds));
45
97
  }
46
98
  return null;
47
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FetchNodes.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/FetchNodes.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAGhD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,MAAM,wBAAwB,GAC1B,IAAI,GAAG,EAA6F,CAAC;AACzG,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAEiE,CAAC;AAE1G,MAAM,UAAU,oBAAoB;IAClC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IACjC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IACjC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IAChC,+BAA+B,CAAC,KAAK,EAAE,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CACzC,SAAwC,EAAE,MAAkC;IAC9E,MAAM,SAAS,GAAG,wBAAwB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,QA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,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,aAAa,GAAG,+BAA+B,CAAC,GAAG,CAAC,SAAS,CAAC;QAChE,IAAI,GAAG,EAA2F,CAAC;IACvG,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC1C,+BAA+B,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAE9D,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as SDK from '../../../core/sdk/sdk.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Types from '../types/types.js';\n\nconst domLookUpSingleNodeCache =\n new Map<Handlers.Types.TraceParseData, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>();\nconst domLookUpBatchNodesCache = new Map<\n Handlers.Types.TraceParseData,\n Map<Array<Protocol.DOM.BackendNodeId>, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>>();\n\nexport function clearCacheForTesting(): void {\n domLookUpSingleNodeCache.clear();\n domLookUpBatchNodesCache.clear();\n layoutShiftSourcesCache.clear();\n normalizedLayoutShiftNodesCache.clear();\n}\n\n/**\n * Looks up the DOM Node on the page for the given BackendNodeId. Uses the\n * provided TraceParseData as the cache and will cache the result after the\n * first lookup.\n */\nexport async function domNodeForBackendNodeID(\n modelData: Handlers.Types.TraceParseData, nodeId: Protocol.DOM.BackendNodeId): Promise<SDK.DOMModel.DOMNode|null> {\n const fromCache = domLookUpSingleNodeCache.get(modelData)?.get(nodeId);\n if (fromCache !== undefined) {\n return fromCache;\n }\n\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n const domModel = target?.model(SDK.DOMModel.DOMModel);\n if (!domModel) {\n return null;\n }\n\n const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set([nodeId]));\n const result = domNodesMap?.get(nodeId) || null;\n\n const cacheForModel =\n domLookUpSingleNodeCache.get(modelData) || new Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>();\n cacheForModel.set(nodeId, result);\n domLookUpSingleNodeCache.set(modelData, cacheForModel);\n\n return result;\n}\n\n/**\n * Looks up for backend node ids in different types of trace events\n * and resolves them into related DOM nodes.\n * This method should be progressively updated to support more events\n * containing node ids which we want to resolve.\n */\nexport async function extractRelatedDOMNodesFromEvent(\n modelData: Handlers.Types.TraceParseData,\n event: Types.TraceEvents.TraceEventData): Promise<Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>|null> {\n if (Types.TraceEvents.isSyntheticLayoutShift(event) && event.args.data?.impacted_nodes) {\n return domNodesForMultipleBackendNodeIds(modelData, event.args.data.impacted_nodes.map(node => node.node_id));\n }\n return null;\n}\n\n/**\n * Takes a set of Protocol.DOM.BackendNodeId ids and will return a map of NodeId=>DOMNode.\n * Results are cached based on 1) the provided TraceParseData and 2) the provided set of IDs.\n */\nexport async function domNodesForMultipleBackendNodeIds(\n modelData: Handlers.Types.TraceParseData,\n nodeIds: Array<Protocol.DOM.BackendNodeId>): Promise<Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>> {\n const fromCache = domLookUpBatchNodesCache.get(modelData)?.get(nodeIds);\n if (fromCache) {\n return fromCache;\n }\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n const domModel = target?.model(SDK.DOMModel.DOMModel);\n if (!domModel) {\n return new Map();\n }\n\n const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set(nodeIds)) || new Map();\n\n const cacheForModel = domLookUpBatchNodesCache.get(modelData) ||\n new Map<Array<Protocol.DOM.BackendNodeId>, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>();\n cacheForModel.set(nodeIds, domNodesMap);\n domLookUpBatchNodesCache.set(modelData, cacheForModel);\n\n return domNodesMap;\n}\n\nconst layoutShiftSourcesCache = new Map<\n Handlers.Types.TraceParseData, Map<Types.TraceEvents.TraceEventLayoutShift, readonly LayoutShiftSource[]>>();\n\nconst normalizedLayoutShiftNodesCache = new Map<\n Handlers.Types.TraceParseData,\n Map<Types.TraceEvents.TraceEventLayoutShift, readonly Types.TraceEvents.TraceImpactedNode[]>>();\n\nexport interface LayoutShiftSource {\n previousRect: DOMRect;\n currentRect: DOMRect;\n node: SDK.DOMModel.DOMNode;\n}\n\n/**\n * Calculates and returns a list of sources for a LayoutShift.\n * Here, a source is considered as a node that moved and contributed to the\n * given LayoutShift existing and the score it was given. Each source returned\n * contains a reference to the DOM Node, and its dimensions (as a DOMRect), both\n * before and now, so we can see how this node changed and how that impacted the\n * layout shift.\n *\n * This data is cached based on the provided model data and the given layout\n * shift, so it is is safe to call multiple times with the same input.\n */\nexport async function sourcesForLayoutShift(\n modelData: Handlers.Types.TraceParseData,\n event: Types.TraceEvents.TraceEventLayoutShift): Promise<readonly LayoutShiftSource[]> {\n const fromCache = layoutShiftSourcesCache.get(modelData)?.get(event);\n if (fromCache) {\n return fromCache;\n }\n const impactedNodes = event.args.data?.impacted_nodes;\n if (!impactedNodes) {\n return [];\n }\n const sources: LayoutShiftSource[] = [];\n await Promise.all(impactedNodes.map(async node => {\n const domNode = await domNodeForBackendNodeID(modelData, node.node_id);\n if (domNode) {\n sources.push({\n previousRect: new DOMRect(node.old_rect[0], node.old_rect[1], node.old_rect[2], node.old_rect[3]),\n currentRect: new DOMRect(node.new_rect[0], node.new_rect[1], node.new_rect[2], node.new_rect[3]),\n node: domNode,\n });\n }\n }));\n const cacheForModel =\n layoutShiftSourcesCache.get(modelData) || new Map<Types.TraceEvents.TraceEventLayoutShift, LayoutShiftSource[]>();\n cacheForModel.set(event, sources);\n layoutShiftSourcesCache.set(modelData, cacheForModel);\n return sources;\n}\n\n/**\n * Takes a LayoutShift and normalizes its node dimensions based on the device\n * pixel ratio (DPR) of the user's display.\n * This is required because the Layout Instability API is not based on CSS\n * pixels, but physical pixels. Therefore we need to map these to normalized CSS\n * pixels if we can. For example, if the user is on a device with a DPR of 2,\n * the values of the node dimensions reported by the Instability API need to be\n * divided by 2 to be accurate.\n * This function is safe to call multiple times as results are cached based on\n * the provided model data.\n * See https://crbug.com/1300309 for details.\n */\nexport async function normalizedImpactedNodesForLayoutShift(\n modelData: Handlers.Types.TraceParseData,\n event: Types.TraceEvents.TraceEventLayoutShift): Promise<readonly Types.TraceEvents.TraceImpactedNode[]> {\n const fromCache = normalizedLayoutShiftNodesCache.get(modelData)?.get(event);\n if (fromCache) {\n return fromCache;\n }\n const impactedNodes = event.args?.data?.impacted_nodes;\n if (!impactedNodes) {\n return [];\n }\n\n let viewportScale: number|null = null;\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n // Get the CSS-to-physical pixel ratio of the device the inspected\n // target is running at.\n const evaluateResult = await target?.runtimeAgent().invoke_evaluate({expression: 'window.devicePixelRatio'});\n if (evaluateResult?.result.type === 'number') {\n viewportScale = evaluateResult?.result.value as number ?? null;\n }\n\n if (!viewportScale) {\n // Bail and return the nodes as is.\n return impactedNodes;\n }\n\n const normalizedNodes: Types.TraceEvents.TraceImpactedNode[] = [];\n for (const impactedNode of impactedNodes) {\n const newNode = {...impactedNode};\n for (let i = 0; i < impactedNode.old_rect.length; i++) {\n newNode.old_rect[i] /= viewportScale;\n }\n for (let i = 0; i < impactedNode.new_rect.length; i++) {\n newNode.new_rect[i] /= viewportScale;\n }\n normalizedNodes.push(newNode);\n }\n\n const cacheForModel = normalizedLayoutShiftNodesCache.get(modelData) ||\n new Map<Types.TraceEvents.TraceEventLayoutShift, readonly Types.TraceEvents.TraceImpactedNode[]>();\n cacheForModel.set(event, normalizedNodes);\n normalizedLayoutShiftNodesCache.set(modelData, cacheForModel);\n\n return normalizedNodes;\n}\n"]}
1
+ {"version":3,"file":"FetchNodes.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/extras/FetchNodes.ts"],"names":[],"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AACzB,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as SDK from '../../../core/sdk/sdk.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Types from '../types/types.js';\n\nconst domLookUpSingleNodeCache =\n new Map<Handlers.Types.TraceParseData, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>();\nconst domLookUpBatchNodesCache = new Map<\n Handlers.Types.TraceParseData,\n Map<Array<Protocol.DOM.BackendNodeId>, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>>();\n\nexport function clearCacheForTesting(): void {\n domLookUpSingleNodeCache.clear();\n domLookUpBatchNodesCache.clear();\n layoutShiftSourcesCache.clear();\n normalizedLayoutShiftNodesCache.clear();\n}\n\n/**\n * Looks up the DOM Node on the page for the given BackendNodeId. Uses the\n * provided TraceParseData as the cache and will cache the result after the\n * first lookup.\n */\nexport async function domNodeForBackendNodeID(\n modelData: Handlers.Types.TraceParseData, nodeId: Protocol.DOM.BackendNodeId): Promise<SDK.DOMModel.DOMNode|null> {\n const fromCache = domLookUpSingleNodeCache.get(modelData)?.get(nodeId);\n if (fromCache !== undefined) {\n return fromCache;\n }\n\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n const domModel = target?.model(SDK.DOMModel.DOMModel);\n if (!domModel) {\n return null;\n }\n\n const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set([nodeId]));\n const result = domNodesMap?.get(nodeId) || null;\n\n const cacheForModel =\n domLookUpSingleNodeCache.get(modelData) || new Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>();\n cacheForModel.set(nodeId, result);\n domLookUpSingleNodeCache.set(modelData, cacheForModel);\n\n return result;\n}\n\nconst nodeIdsForEventCache = new WeakMap<Types.TraceEvents.TraceEventData, Set<Protocol.DOM.BackendNodeId>>();\n/**\n * Extracts a set of NodeIds for a given event.\n * NOTE: you probably don't want to call this and instead use\n * `extractRelatedDOMNodesFromEvent`, which will fetch the nodes over CDP.\n * This method is primarily exported so we can test the logic more easily\n * without having to mock the CDP layer.\n **/\nexport function nodeIdsForEvent(\n modelData: Handlers.Types.TraceParseData,\n event: Types.TraceEvents.TraceEventData,\n ): Set<Protocol.DOM.BackendNodeId> {\n const fromCache = nodeIdsForEventCache.get(event);\n if (fromCache) {\n return fromCache;\n }\n const foundIds = new Set<Protocol.DOM.BackendNodeId>();\n\n if (Types.TraceEvents.isTraceEventLayout(event)) {\n event.args.endData.layoutRoots.forEach(root => foundIds.add(root.nodeId));\n } else if (Types.TraceEvents.isSyntheticLayoutShift(event) && event.args.data?.impacted_nodes) {\n event.args.data.impacted_nodes.forEach(node => foundIds.add(node.node_id));\n } else if (\n Types.TraceEvents.isTraceEventLargestContentfulPaintCandidate(event) &&\n typeof event.args.data?.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.TraceEvents.isTraceEventPaint(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.TraceEvents.isTraceEventPaintImage(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.TraceEvents.isTraceEventScrollLayer(event) && typeof event.args.data.nodeId !== 'undefined') {\n foundIds.add(event.args.data.nodeId);\n } else if (Types.TraceEvents.isTraceEventDecodeImage(event)) {\n // For a DecodeImage event, we can use the ImagePaintingHandler, which has\n // done the work to build the relationship between a DecodeImage event and\n // the corresponding PaintImage event.\n const paintImageEvent = modelData.ImagePainting.paintImageForEvent.get(event);\n if (paintImageEvent && typeof paintImageEvent.args.data.nodeId !== 'undefined') {\n foundIds.add(paintImageEvent.args.data.nodeId);\n }\n } else if (Types.TraceEvents.isTraceEventDrawLazyPixelRef(event) && event.args?.LazyPixelRef) {\n const paintImageEvent = modelData.ImagePainting.paintImageByDrawLazyPixelRef.get(event.args.LazyPixelRef);\n if (paintImageEvent && typeof paintImageEvent.args.data.nodeId !== 'undefined') {\n foundIds.add(paintImageEvent.args.data.nodeId);\n }\n }\n nodeIdsForEventCache.set(event, foundIds);\n return foundIds;\n}\n\n/**\n * Looks up for backend node ids in different types of trace events\n * and resolves them into related DOM nodes.\n * This method should be progressively updated to support more events\n * containing node ids which we want to resolve.\n */\nexport async function extractRelatedDOMNodesFromEvent(\n modelData: Handlers.Types.TraceParseData,\n event: Types.TraceEvents.TraceEventData): Promise<Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>|null> {\n const nodeIds = nodeIdsForEvent(modelData, event);\n if (nodeIds.size) {\n return domNodesForMultipleBackendNodeIds(modelData, Array.from(nodeIds));\n }\n return null;\n}\n\n/**\n * Takes a set of Protocol.DOM.BackendNodeId ids and will return a map of NodeId=>DOMNode.\n * Results are cached based on 1) the provided TraceParseData and 2) the provided set of IDs.\n */\nexport async function domNodesForMultipleBackendNodeIds(\n modelData: Handlers.Types.TraceParseData,\n nodeIds: Array<Protocol.DOM.BackendNodeId>): Promise<Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>> {\n const fromCache = domLookUpBatchNodesCache.get(modelData)?.get(nodeIds);\n if (fromCache) {\n return fromCache;\n }\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n const domModel = target?.model(SDK.DOMModel.DOMModel);\n if (!domModel) {\n return new Map();\n }\n\n const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set(nodeIds)) || new Map();\n\n const cacheForModel = domLookUpBatchNodesCache.get(modelData) ||\n new Map<Array<Protocol.DOM.BackendNodeId>, Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode|null>>();\n cacheForModel.set(nodeIds, domNodesMap);\n domLookUpBatchNodesCache.set(modelData, cacheForModel);\n\n return domNodesMap;\n}\n\nconst layoutShiftSourcesCache = new Map<\n Handlers.Types.TraceParseData, Map<Types.TraceEvents.TraceEventLayoutShift, readonly LayoutShiftSource[]>>();\n\nconst normalizedLayoutShiftNodesCache = new Map<\n Handlers.Types.TraceParseData,\n Map<Types.TraceEvents.TraceEventLayoutShift, readonly Types.TraceEvents.TraceImpactedNode[]>>();\n\nexport interface LayoutShiftSource {\n previousRect: DOMRect;\n currentRect: DOMRect;\n node: SDK.DOMModel.DOMNode;\n}\n\n/**\n * Calculates and returns a list of sources for a LayoutShift.\n * Here, a source is considered as a node that moved and contributed to the\n * given LayoutShift existing and the score it was given. Each source returned\n * contains a reference to the DOM Node, and its dimensions (as a DOMRect), both\n * before and now, so we can see how this node changed and how that impacted the\n * layout shift.\n *\n * This data is cached based on the provided model data and the given layout\n * shift, so it is is safe to call multiple times with the same input.\n */\nexport async function sourcesForLayoutShift(\n modelData: Handlers.Types.TraceParseData,\n event: Types.TraceEvents.TraceEventLayoutShift): Promise<readonly LayoutShiftSource[]> {\n const fromCache = layoutShiftSourcesCache.get(modelData)?.get(event);\n if (fromCache) {\n return fromCache;\n }\n const impactedNodes = event.args.data?.impacted_nodes;\n if (!impactedNodes) {\n return [];\n }\n const sources: LayoutShiftSource[] = [];\n await Promise.all(impactedNodes.map(async node => {\n const domNode = await domNodeForBackendNodeID(modelData, node.node_id);\n if (domNode) {\n sources.push({\n previousRect: new DOMRect(node.old_rect[0], node.old_rect[1], node.old_rect[2], node.old_rect[3]),\n currentRect: new DOMRect(node.new_rect[0], node.new_rect[1], node.new_rect[2], node.new_rect[3]),\n node: domNode,\n });\n }\n }));\n const cacheForModel =\n layoutShiftSourcesCache.get(modelData) || new Map<Types.TraceEvents.TraceEventLayoutShift, LayoutShiftSource[]>();\n cacheForModel.set(event, sources);\n layoutShiftSourcesCache.set(modelData, cacheForModel);\n return sources;\n}\n\n/**\n * Takes a LayoutShift and normalizes its node dimensions based on the device\n * pixel ratio (DPR) of the user's display.\n * This is required because the Layout Instability API is not based on CSS\n * pixels, but physical pixels. Therefore we need to map these to normalized CSS\n * pixels if we can. For example, if the user is on a device with a DPR of 2,\n * the values of the node dimensions reported by the Instability API need to be\n * divided by 2 to be accurate.\n * This function is safe to call multiple times as results are cached based on\n * the provided model data.\n * See https://crbug.com/1300309 for details.\n */\nexport async function normalizedImpactedNodesForLayoutShift(\n modelData: Handlers.Types.TraceParseData,\n event: Types.TraceEvents.TraceEventLayoutShift): Promise<readonly Types.TraceEvents.TraceImpactedNode[]> {\n const fromCache = normalizedLayoutShiftNodesCache.get(modelData)?.get(event);\n if (fromCache) {\n return fromCache;\n }\n const impactedNodes = event.args?.data?.impacted_nodes;\n if (!impactedNodes) {\n return [];\n }\n\n let viewportScale: number|null = null;\n const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();\n // Get the CSS-to-physical pixel ratio of the device the inspected\n // target is running at.\n const evaluateResult = await target?.runtimeAgent().invoke_evaluate({expression: 'window.devicePixelRatio'});\n if (evaluateResult?.result.type === 'number') {\n viewportScale = evaluateResult?.result.value as number ?? null;\n }\n\n if (!viewportScale) {\n // Bail and return the nodes as is.\n return impactedNodes;\n }\n\n const normalizedNodes: Types.TraceEvents.TraceImpactedNode[] = [];\n for (const impactedNode of impactedNodes) {\n const newNode = {...impactedNode};\n for (let i = 0; i < impactedNode.old_rect.length; i++) {\n newNode.old_rect[i] /= viewportScale;\n }\n for (let i = 0; i < impactedNode.new_rect.length; i++) {\n newNode.new_rect[i] /= viewportScale;\n }\n normalizedNodes.push(newNode);\n }\n\n const cacheForModel = normalizedLayoutShiftNodesCache.get(modelData) ||\n new Map<Types.TraceEvents.TraceEventLayoutShift, readonly Types.TraceEvents.TraceImpactedNode[]>();\n cacheForModel.set(event, normalizedNodes);\n normalizedLayoutShiftNodesCache.set(modelData, cacheForModel);\n\n return normalizedNodes;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import * as Types from '../types/types.js';
2
+ export declare function reset(): void;
3
+ export declare function handleEvent(event: Types.TraceEvents.TraceEventData): void;
4
+ export interface ImagePaintData {
5
+ paintImageByDrawLazyPixelRef: Map<number, Types.TraceEvents.TraceEventPaintImage>;
6
+ paintImageForEvent: Map<Types.TraceEvents.TraceEventData, Types.TraceEvents.TraceEventPaintImage>;
7
+ }
8
+ export declare function data(): ImagePaintData;