Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(largest-contentful-paint): add new metric #9706

Merged
merged 54 commits into from
Oct 2, 2019
Merged

core(largest-contentful-paint): add new metric #9706

merged 54 commits into from
Oct 2, 2019

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Sep 20, 2019

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great first pass

lighthouse-core/lib/tracehouse/trace-processor.js Outdated Show resolved Hide resolved
for (let i = frameEvents.length - 1; i >= 0; i--) {
const e = frameEvents[i];
if (e.ts <= navigationStart.ts) break;
if (e.name === 'largestContentfulPaint::Invalidate') break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test for this case?

i'd like to base the test from a real trace.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get a single comment above each if case space shuttle style? in my first read I missed that we were counting backwards and was very confused :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to test cases for these :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm luckily i just made a huge corpus of new traces.

Copy link
Collaborator Author

@connorjclark connorjclark Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran it on a bunch of traces
(i also put a log at if (e.name === 'largestContentfulPaint::Invalidate')):

find dist/collect-lantern-traces -name '*trace.json' | xargs -I{} node -e "\
    const path = '{}'; \
    console.log(path); \
    const trace = JSON.parse(require('fs').readFileSync(path, 'utf-8')); \
    // wpt traces start with an empty event ...
    trace.traceEvents = trace.traceEvents.filter(e => Object.keys(e).length > 0); \
    const traceOfTab = require('./lighthouse-core/lib/tracehouse/trace-processor.js').computeTraceOfTab(trace); \
    console.log(traceOfTab.timings.largestContentfulPaint)";

and I never hit the log point.

In fact, only two of these collected traces have largestContentfulPaint::Invalidate.

  1. https---www-huffpost-com--mobile-unthrottled-4-trace.json - it's not from the main frame, so we ignore it.
  2. https---www-reddit-com--mobile-wpt-2-trace.json - after a short gap, it's followed by a largestContentfulPaint::Candidate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that some basic test cases can also be constructed by e.g. create-test-trace.js (and then adding LCP events), or lack of LCP can be found with existing traces :) This should make testing at least some of this more lightweight.

It's obviously still good to find a real trace as you're doing to make sure the tests match what happens in reality (especially with cases like invalidation)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO a real trace test for this does not need to be blocking landing (create-test-trace.js is nice :)), though if we wanted to add a flag that indicates if we fell into the invalidate path so we can examine frequency in HTTPArchive it wouldn't be the worst idea :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would still love some of those space shuttle comments though :D

]
}
"scoreDisplayMode": "error",
"errorMessage": "Something went wrong with recording the trace over your page load. Please run Lighthouse again. (NO_FMP)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that isn't supposed to happen.. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the wrong error code, should have been NO_LCP here (since the sample artifacts have not been updated yet).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated just the traces now ...

connorjclark and others added 2 commits September 20, 2019 13:51
Co-Authored-By: Paul Irish <paulirish@google.com>
@@ -9,8 +9,8 @@ const PageDependencyGraph = require('../../computed/page-dependency-graph.js');
const BaseNode = require('../../lib/dependency-graph/base-node.js');
const NetworkRequest = require('../../lib/network-request.js');

const sampleTrace = require('../fixtures/traces/progressive-app-m60.json');
const sampleDevtoolsLog = require('../fixtures/traces/progressive-app-m60.devtools.log.json');
const sampleTrace = require('../fixtures/traces/progressive-app-m79.json');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I have generate this trace/logs in a different way than just running on https://pwa.rocks/ w/ default options? A lot of the numbers that changed with -u seem too different.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the trace that was recorded before used devtools throttling, see my other thoughts on using a new trace though :)

@vercel vercel bot temporarily deployed to staging October 1, 2019 22:02 Inactive
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two last things :)

lighthouse-core/audits/metrics.js Outdated Show resolved Hide resolved
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
@vercel vercel bot temporarily deployed to staging October 1, 2019 22:52 Inactive
…-test.js

Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🐘🖼 🚢

@@ -115,7 +120,7 @@ class Metrics extends Audit {
const details = {
type: 'debugdata',
// TODO: Consider not nesting metrics under `items`.
items: [metrics],
items: [metrics, {lcpInvalidated: traceOfTab.lcpInvalidated}],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should be observedLcpInvalidated or something but I can't imagine it ever mattering (and maybe like fmpFellBack it'll eventually just go unused in the artifacts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants