From 0de46e7c9843cb17c905be2431aec7dd4ffb7e73 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Thu, 24 Jun 2021 14:08:33 -0500 Subject: [PATCH] core(fr): add lighthouseMarker timeOrigin support (#12688) --- lighthouse-core/gather/gatherers/trace.js | 8 +++- .../lib/tracehouse/trace-processor.js | 44 +++++++++++++++-- .../fixtures/traces/timespan-trace-m91.json | 48 +++++++++++++++++++ .../lib/tracehouse/trace-processor-test.js | 11 +++++ types/externs.d.ts | 1 + 5 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 lighthouse-core/test/fixtures/traces/timespan-trace-m91.json diff --git a/lighthouse-core/gather/gatherers/trace.js b/lighthouse-core/gather/gatherers/trace.js index d7cf6dc67d52..00e53cd33f81 100644 --- a/lighthouse-core/gather/gatherers/trace.js +++ b/lighthouse-core/gather/gatherers/trace.js @@ -12,6 +12,7 @@ */ const FRGatherer = require('../../fraggle-rock/gather/base-gatherer.js'); +const TraceProcessor = require('../../lib/tracehouse/trace-processor.js'); class Trace extends FRGatherer { /** @type {LH.Trace} */ @@ -95,7 +96,7 @@ class Trace extends FRGatherer { /** * @param {LH.Gatherer.FRTransitionalContext} passContext */ - async startSensitiveInstrumentation({driver}) { + async startSensitiveInstrumentation({driver, gatherMode}) { // TODO(FR-COMPAT): read additional trace categories from overall settings? // TODO(FR-COMPAT): check if CSS/DOM domains have been enabled in another session and warn? await driver.defaultSession.sendCommand('Page.enable'); @@ -103,6 +104,11 @@ class Trace extends FRGatherer { categories: Trace.getDefaultTraceCategories().join(','), options: 'sampling-frequency=10000', // 1000 is default and too slow. }); + + if (gatherMode === 'timespan') { + await driver.defaultSession.sendCommand('Tracing.recordClockSyncMarker', + {syncId: TraceProcessor.TIMESPAN_MARKER_ID}); + } } /** diff --git a/lighthouse-core/lib/tracehouse/trace-processor.js b/lighthouse-core/lib/tracehouse/trace-processor.js index 50b26e8f01d2..9c837c10adcf 100644 --- a/lighthouse-core/lib/tracehouse/trace-processor.js +++ b/lighthouse-core/lib/tracehouse/trace-processor.js @@ -17,7 +17,7 @@ */ /** @typedef {Omit} TraceNavigationTimesForFrame */ -/** @typedef {'lastNavigationStart'|'firstResourceSendRequest'} TimeOriginDeterminationMethod */ +/** @typedef {'lastNavigationStart'|'firstResourceSendRequest'|'lighthouseMarker'|'auto'} TimeOriginDeterminationMethod */ /** @typedef {Omit & {name: 'FrameCommittedInBrowser', args: {data: {frame: string, url: string, parent?: string}}}} FrameCommittedEvent */ /** @typedef {Omit & {name: 'largestContentfulPaint::Invalidate'|'largestContentfulPaint::Candidate', args: {data?: {size?: number}, frame: string}}} LCPEvent */ /** @typedef {Omit & {name: 'largestContentfulPaint::Candidate', args: {data: {size: number}, frame: string}}} LCPCandidateEvent */ @@ -39,6 +39,10 @@ const SCHEDULABLE_TASK_TITLE_ALT2 = 'ThreadControllerImpl::DoWork'; const SCHEDULABLE_TASK_TITLE_ALT3 = 'TaskQueueManager::ProcessTaskFromWorkQueue'; class TraceProcessor { + static get TIMESPAN_MARKER_ID() { + return '__lighthouseTimespanStart__'; + } + /** * @return {Error} */ @@ -67,6 +71,13 @@ class TraceProcessor { return new Error('No FirstContentfulPaint event found'); } + /** + * @return {Error} + */ + static createNoLighthouseMarkerError() { + return new Error('No Lighthouse timespan marker event found'); + } + /** * Returns true if the event is a navigation start event of a document whose URL seems valid. * @@ -584,7 +595,7 @@ class TraceProcessor { * @return {LH.Artifacts.ProcessedTrace} */ static processTrace(trace, options) { - const {timeOriginDeterminationMethod = 'lastNavigationStart'} = options || {}; + const {timeOriginDeterminationMethod = 'auto'} = options || {}; // Parse the trace for our key events and sort them by timestamp. Note: sort // *must* be stable to keep events correctly nested. @@ -780,6 +791,21 @@ class TraceProcessor { * @return {LH.TraceEvent} */ static computeTimeOrigin(traceEventSubsets, method) { + const lastNavigationStart = () => { + // Our time origin will be the last frame navigation in the trace + const frameEvents = traceEventSubsets.frameEvents; + return frameEvents.filter(this._isNavigationStartOfInterest).pop(); + }; + + const lighthouseMarker = () => { + const frameEvents = traceEventSubsets.keyEvents; + return frameEvents.find( + evt => + evt.name === 'clock_sync' && + evt.args.sync_id === TraceProcessor.TIMESPAN_MARKER_ID + ); + }; + switch (method) { case 'firstResourceSendRequest': { // Our time origin will be the timestamp of the first request that's sent in the frame. @@ -792,12 +818,20 @@ class TraceProcessor { return fetchStart; } case 'lastNavigationStart': { - // Our time origin will be the last frame navigation in the trace - const frameEvents = traceEventSubsets.frameEvents; - const navigationStart = frameEvents.filter(this._isNavigationStartOfInterest).pop(); + const navigationStart = lastNavigationStart(); if (!navigationStart) throw this.createNoNavstartError(); return navigationStart; } + case 'lighthouseMarker': { + const marker = lighthouseMarker(); + if (!marker) throw this.createNoLighthouseMarkerError(); + return marker; + } + case 'auto': { + const marker = lighthouseMarker() || lastNavigationStart(); + if (!marker) throw this.createNoNavstartError(); + return marker; + } } } diff --git a/lighthouse-core/test/fixtures/traces/timespan-trace-m91.json b/lighthouse-core/test/fixtures/traces/timespan-trace-m91.json new file mode 100644 index 000000000000..20786840aeab --- /dev/null +++ b/lighthouse-core/test/fixtures/traces/timespan-trace-m91.json @@ -0,0 +1,48 @@ +{ + "traceEvents": [ + {"args":{"name":"swapper"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":0,"ts":0}, + {"args":{"name":"StackSamplingProfiler"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98673,"tid":11011,"ts":0}, + {"args":{"name":"CrBrowserMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":775,"ts":0}, + {"args":{"name":"NetworkService"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":53507,"ts":0}, + {"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98676,"tid":775,"ts":0}, + {"args":{"name":"Chrome_DevToolsHandlerThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":130819,"ts":0}, + {"args":{"name":"VizCompositorThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98673,"tid":44547,"ts":0}, + {"args":{"name":"CrGpuMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98673,"tid":775,"ts":0}, + {"args":{"name":"Chrome_ChildIOThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98673,"tid":34307,"ts":0}, + {"args":{"name":"CacheThread_BlockFile"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":79875,"ts":0}, + {"args":{"name":"Chrome_IOThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":33283,"ts":0}, + {"args":{"name":"StackSamplingProfiler"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":6659,"ts":0}, + {"args":{"name":"ThreadPoolServiceThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":36867,"ts":0}, + {"args":{"name":"ThreadPoolServiceThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98673,"tid":35587,"ts":0}, + {"args":{"name":"ThreadPoolServiceThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98676,"tid":20483,"ts":0}, + {"args":{"name":"Chrome_ChildIOThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98676,"tid":13059,"ts":0}, + {"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98676,"tid":11779,"ts":0}, + {"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98676,"tid":19203,"ts":0}, + {"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98662,"tid":63747,"ts":0}, + {"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":98673,"tid":32259,"ts":0}, + {"args":{"name":"Browser"},"cat":"__metadata","name":"process_name","ph":"M","pid":98662,"tid":0,"ts":0}, + {"args":{"name":"GPU Process"},"cat":"__metadata","name":"process_name","ph":"M","pid":98673,"tid":0,"ts":0}, + {"args":{"name":"Renderer"},"cat":"__metadata","name":"process_name","ph":"M","pid":98676,"tid":0,"ts":0}, + {"args":{"uptime":"17"},"cat":"__metadata","name":"process_uptime_seconds","ph":"M","pid":98662,"tid":0,"ts":0}, + {"args":{"uptime":"17"},"cat":"__metadata","name":"process_uptime_seconds","ph":"M","pid":98673,"tid":0,"ts":0}, + {"args":{"uptime":"16"},"cat":"__metadata","name":"process_uptime_seconds","ph":"M","pid":98676,"tid":0,"ts":0}, + {"args":{"data":{"frameTreeNodeId":2,"frames":[{"frame":"CDC7FDACD95C50606A7BC08529E7F1CD","name":"","processId":98676,"url":"https://example.com/"}],"persistentIds":true}},"cat":"disabled-by-default-devtools.timeline","name":"TracingStartedInBrowser","ph":"I","pid":98662,"s":"t","tid":775,"ts":260758704187,"tts":489667}, + {"args":{},"cat":"disabled-by-default-devtools.timeline","dur":99652,"name":"RunTask","ph":"X","pid":98676,"tdur":99335,"tid":775,"ts":260760721453,"tts":144263}, + {"args":{"microtask_count":1},"cat":"v8.execute","dur":66,"name":"RunMicrotasks","ph":"X","pid":98676,"tdur":67,"tid":775,"ts":260760820980,"tts":243474}, + {"args":{},"cat":"disabled-by-default-devtools.timeline","dur":1004488,"name":"RunTask","ph":"X","pid":98676,"tdur":997136,"tid":775,"ts":260761324398,"tts":243766}, + {"args":{},"cat":"disabled-by-default-devtools.timeline","dur":1004344,"name":"EvaluateScript","ph":"X","pid":98676,"tdur":996992,"tid":775,"ts":260761324446,"tts":243813}, + {"args":{"data":{"columnNumber":1,"lineNumber":1,"notStreamedReason":"inline script","streamed":false,"url":""},"fileName":""},"cat":"v8,devtools.timeline","dur":118,"name":"v8.compile","ph":"X","pid":98676,"tdur":124,"tid":775,"ts":260761324588,"tts":243955}, + {"args":{"microtask_count":3},"cat":"v8.execute","dur":1003400,"name":"RunMicrotasks","ph":"X","pid":98676,"tdur":996049,"tid":775,"ts":260761325228,"tts":244595}, + {"args":{"microtask_count":3},"cat":"v8.execute","dur":103,"name":"RunMicrotas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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf/Z"},"cat":"disabled-by-default-devtools.screenshot","id":"0x1","name":"Screenshot","ph":"O","pid":98662,"tid":775,"ts":260758704433}, + {"args":{"sync_id":"__lighthouseTimespanStart__"},"cat":"__metadata","name":"clock_sync","ph":"c","pid":98662,"tid":775,"ts":260759206050,"tts":491817}, + {"args":{"number":16},"cat":"__metadata","name":"num_cpus","ph":"M","pid":98662,"tid":0,"ts":260762832144}, + {"args":{"number":16},"cat":"__metadata","name":"num_cpus","ph":"M","pid":98673,"tid":0,"ts":260762832156}, + {"args":{"number":16},"cat":"__metadata","name":"num_cpus","ph":"M","pid":98676,"tid":0,"ts":260762832161}, + {"args":{"sort_index":-5},"cat":"__metadata","name":"process_sort_index","ph":"M","pid":98676,"tid":775,"ts":260762832168}, + {"args":{"sort_index":-6},"cat":"__metadata","name":"process_sort_index","ph":"M","pid":98662,"tid":63747,"ts":260762832171}, + {"args":{"labels":"Example Domain"},"cat":"__metadata","name":"process_labels","ph":"M","pid":98676,"tid":775,"ts":260762832171}, + {"args":{"sort_index":-1},"cat":"__metadata","name":"thread_sort_index","ph":"M","pid":98676,"tid":775,"ts":260762832174}, + {"args":{"sort_index":-1},"cat":"__metadata","name":"process_sort_index","ph":"M","pid":98673,"tid":32259,"ts":260762832180} + ] +} \ No newline at end of file diff --git a/lighthouse-core/test/lib/tracehouse/trace-processor-test.js b/lighthouse-core/test/lib/tracehouse/trace-processor-test.js index 27c26fc5a4b0..87805df17ec5 100644 --- a/lighthouse-core/test/lib/tracehouse/trace-processor-test.js +++ b/lighthouse-core/test/lib/tracehouse/trace-processor-test.js @@ -17,6 +17,7 @@ const noTracingStartedTrace = require('../../fixtures/traces/no-tracingstarted-m const preactTrace = require('../../fixtures/traces/preactjs.com_ts_of_undefined.json'); const noFMPtrace = require('../../fixtures/traces/no_fmp_event.json'); const noFCPtrace = require('../../fixtures/traces/airhorner_no_fcp.json'); +const timespanTrace = require('../../fixtures/traces/timespan-trace-m91.json'); const noNavStartTrace = require('../../fixtures/traces/no_navstart_event.json'); const backgroundTabTrace = require('../../fixtures/traces/backgrounded-tab-missing-paints.json'); const lcpTrace = require('../../fixtures/traces/lcp-m78.json'); @@ -421,6 +422,16 @@ describe('TraceProcessor', () => { expect(trace.timestamps.timeOrigin).toEqual(713037332092); }); + + it('supports lighthouseMarker', () => { + const trace = TraceProcessor.processTrace(timespanTrace); + + expect(trace.timings).toMatchObject({ + traceEnd: 3626.13, + }); + + expect(trace.timestamps.timeOrigin).toEqual(260759206050); + }); }); describe('.processNavigation()', () => { diff --git a/types/externs.d.ts b/types/externs.d.ts index 09ad3f31e737..86c13994ffba 100644 --- a/types/externs.d.ts +++ b/types/externs.d.ts @@ -317,6 +317,7 @@ declare global { args: { fileName?: string; snapshot?: string; + sync_id?: string; beginData?: { frame?: string; startLine?: number;