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

Timespan incorrectly captures CLS from user input #14396

Open
2 tasks done
ramironieto opened this issue Sep 19, 2022 · 8 comments
Open
2 tasks done

Timespan incorrectly captures CLS from user input #14396

ramironieto opened this issue Sep 19, 2022 · 8 comments

Comments

@ramironieto
Copy link

FAQ

URL

https://web.dev/

What happened?

When running lighthouse on timespan mode and resizing a page it shows high CLS.

What did you expect?

it should be low as it is within the time window of a user-initiated layout shift, and the resizing is done by the user.

What have you tried?

No response

How were you running Lighthouse?

Chrome DevTools

Lighthouse Version

9.6.2

Chrome Version

105.0.0.0

Node Version

No response

OS

Mac

Relevant log output

No response

@adamraine
Copy link
Member

How are you resizing the page? With DevTools open and Lighthouse running I am unable to resize the page manually.

@adamraine
Copy link
Member

Never-mind, I needed to resize the window not just the inspector pane. I can repro this.

@adamraine
Copy link
Member

We ignore the had_recent_input flag for the first set of layout shifts

// Chromium will set `had_recent_input` if there was recent user input, which
// skips shift events from contributing to CLS. This flag is also set when
// Lighthouse changes the emulation size. This results in the first few shift
// events having `had_recent_input` set, so ignore it for those events.
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1094974.
let ignoreHadRecentInput = true;

Instead of the current implementation, maybe we should do this for any layout shifts that occur within the first X ms of the trace starting.

@connorjclark
Copy link
Collaborator

connorjclark commented Sep 20, 2022

isn't that when (real, bad) shifting is most likely to happen?

Ideally the resize events that happen when a window is resized should be marked as "input" for purposes of CLS.

@adamraine
Copy link
Member

isn't that when (real, bad) shifting is most likely to happen?

Yeah, that's why we want to ignore had_recent_input for those events. I'm proposing this logic will stay the same for LS events within the first 500ms of tracing.

If every LS event is triggered by some user input then the current logic will count them all.

@connorjclark
Copy link
Collaborator

connorjclark commented Sep 20, 2022

Ah, right. The negation here tripped me up. But why would a manual resize be limited to just the first X ms? You can resize a the windows during devtools LH audit anytime.

@adamraine
Copy link
Member

But why would a manual resize be limited to just the first X ms?

We are concerned with the Lighthouse emulation resize at the start of the run being treated as a user input by LS events. Any LS event with had_recent_input = true within the first 500ms of tracing could have been set with had_recent_input = true because of the Lighthouse emulation resize.

LS events only look for user input in a 500ms window before the LS. This is where the 500ms figure comes from.

@adamraine
Copy link
Member

@adamraine adamraine changed the title High CLS on page resize Timespan incorrectly captures CLS from user input Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants