-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
There was a problem hiding this 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/computed/metrics/lantern-largest-contentful-paint.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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
https---www-huffpost-com--mobile-unthrottled-4-trace.json
- it's not from the main frame, so we ignore it.https---www-reddit-com--mobile-wpt-2-trace.json
- after a short gap, it's followed by alargestContentfulPaint::Candidate
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to https://chromium-review.googlesource.com/c/chromium/src/+/1745433/19#message-435ee4e2ea3f8d117b90bbc4f00c4f4486928eba
These pages have image animated carousel that makes LCP generates both candidate and invalidate events - http://www.jd.com/ , http://www.kakao.com/, http://www.dnevnik.ru/, http://www.united.com/
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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)" |
There was a problem hiding this comment.
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.. :)
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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 ...
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'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
There was a problem hiding this 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/test/computed/metrics/largest-contentful-paint-test.js
Outdated
Show resolved
Hide resolved
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
…-test.js Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
There was a problem hiding this 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}], |
There was a problem hiding this comment.
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)
https://web.dev/largest-contentful-paint