Skip to content

Commit

Permalink
core: Support traces with TracingStartedInBrowser event
Browse files Browse the repository at this point in the history
Since version 67 Chrome uses a new schema to describe page frame tree.
The tree is encoded within TracingStartedInBrowser trace event.
The patch makes lighthouse to support the new event.
Legacy TracingStartedInPage event is going to the removed soon.
  • Loading branch information
a1ph committed Jun 4, 2018
1 parent d63f491 commit 5b1793d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lighthouse-core/gather/computed/trace-of-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class TraceOfTab extends ComputedArtifact {
const keyEvents = trace.traceEvents
.filter(e => {
return e.cat.includes('blink.user_timing') ||
e.cat.includes('loading') ||
e.cat.includes('devtools.timeline') ||
e.cat === '__metadata';
e.cat.includes('loading') ||
e.cat.includes('devtools.timeline') ||
e.cat === '__metadata';
})
// @ts-ignore - stableSort added to Array by WebInspector.
.stableSort((event0, event1) => event0.ts - event1.ts);
Expand All @@ -55,10 +55,9 @@ class TraceOfTab extends ComputedArtifact {
/** @type {LH.TraceEvent|undefined} */
let startedInPageEvt;
const startedInBrowserEvt = keyEvents.find(e => e.name === 'TracingStartedInBrowser');
// `persistentIds` is a signal that the frame data will be attached, prefer it when available.
if (startedInBrowserEvt && startedInBrowserEvt.args.data &&
startedInBrowserEvt.args.data.persistentIds) {
const mainFrame = (startedInBrowserEvt.args.data.frames || []).find(frame => !frame.parent);
startedInBrowserEvt.args.data.frames) {
const mainFrame = startedInBrowserEvt.args.data.frames.find(frame => !frame.parent);
const pid = mainFrame && mainFrame.processId;
const threadNameEvt = keyEvents.find(e => e.pid === pid && e.ph === 'M' &&
e.cat === '__metadata' && e.name === 'thread_name' && e.args.name === 'CrRendererMain');
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/test/gather/computed/trace-of-tab-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ describe('Trace of Tab computed artifact:', () => {
'name': 'TracingStartedInBrowser',
'args': {'data': {
'frameTreeNodeId': 1,
'persistentIds': true,
'frames': [{
'frame': 'B192D1F3355A6F961EC8F0B01623C1FB',
'url': 'http://www.example.com/',
Expand Down
1 change: 0 additions & 1 deletion typings/externs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ declare global {
args: {
data?: {
name?: string;
persistentIds?: boolean;
frames?: {
frame: string;
parent?: string;
Expand Down

0 comments on commit 5b1793d

Please sign in to comment.