-
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(metrics): support CLS for all frames #11713
Conversation
*/ | ||
static async compute_(trace) { | ||
const cumulativeShift = trace.traceEvents | ||
.filter(e => e.name === 'LayoutShift' && e.args && e.args.data && e.args.data.score) |
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.
You can narrow the type by annotating the filter function to be a type guard. here's an example: https://github.com/GoogleChrome/lighthouse/pull/7817/files#diff-b66c6ac9b4b8c0726c736eb7479a9e4ff22c7b81bfa1b2b259c2cdfa220ea1f8R19
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.
oh nvm the type here is kinda complicated, a ts ignore on L19 is probably better
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.
if this weren't on trace events I would suggest the map
first and then a filter
which is much easier in jsdoc type land :)
on the functionality itself though, we should normally be excluding layout shifts with had_recent_input=true
, I don't expect it to have much effect but for comparison to the existing definition we should match it for now. also see fun stuff like #10960 :)
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.
totes forgot about the recent input thing. that was a rough bug
*/ | ||
static async compute_(trace) { | ||
const cumulativeShift = trace.traceEvents | ||
.filter(e => e.name === 'LayoutShift' && e.args && e.args.data && e.args.data.score) |
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.
if this weren't on trace events I would suggest the map
first and then a filter
which is much easier in jsdoc type land :)
on the functionality itself though, we should normally be excluding layout shifts with had_recent_input=true
, I don't expect it to have much effect but for comparison to the existing definition we should match it for now. also see fun stuff like #10960 :)
lighthouse-core/computed/metrics/cumulative-layout-shift-all-frames.js
Outdated
Show resolved
Hide resolved
lighthouse-core/test/fixtures/traces/frame-metrics-m89.devtools.log.json
Show resolved
Hide resolved
|
Part 1a (step 2?) of the Framehole implementation plan for CLS.
The
cumulative_score
arg inLayoutShift
trace events is computed per-frame. We could find the latestLayoutShift
event for each frame but it seemed simpler to compute our own cumulative score from every layout shift event.Leaving this as a draft for now, will change the merge into branch to
master
once #11701 lands.