fix: show CLS metric when value is 0 - #4797
Conversation
When Chrome's Layout Instability API observer never fires (no layout shifts on the page), cumulativeLayoutShift stays undefined. The aggregator skipped it entirely, so no stats were generated and the template never rendered the CLS section. Fix: default to 0 in the aggregator when pageinfo exists but CLS is undefined, and relax the template guards so they render for any pageinfo (not just when CLS !== undefined). Fixes sitespeedio#4547
c0e1100 to
9f73149
Compare
|
The Would it be possible to re-trigger the CI checks for this PR? Happy to rebase if needed. Thanks! |
|
The one failing check ( It passes on If you'd like fork PRs to show green, gating that job on the secret being present (e.g. |
|
Hi maintainers — gentle ping on this PR. It fixes CLS metric display when value is 0. All CI checks pass and the PR is mergeable. Would appreciate a review when you have a moment. Thanks! |
|
Sorry for being late on this. Had a quick check, this will set CLS to 0 for browsers that do not calculate/supports it? |
|
I'm thinking like this, maybe this is a bug in Browsertime when we get the metric? |
|
Thanks @soulgalore — good catch, I dug into the Browsertime source before replying. 1. Browsers that don't support CLS: yes, as written this patch would report 0 for them — that's a flaw. Browsertime's CLS collector ( 2. Your Browsertime hunch: I think you're right. Since upstream Browsertime already returns So I'll pull the blanket default-to-0 from this PR as it stands — it papers over the supported/unsupported distinction. If you can still reproduce CLS going missing on an actual Chrome run, it's worth chasing in Browsertime; if the original report came from a non-Chromium browser, the current behaviour is correct and this PR can be closed. Happy to go either way — just say which. |
Description
When Chrome's Layout Instability API observer never fires (no layout shifts on the page), \cumulativeLayoutShift\ stays \undefined. The aggregator skipped it entirely, so no stats were generated and the template never rendered the CLS section — making it look like the metric was missing.
Root cause
In \�rowsertimeAggregator.js, the guard !== undefined\ prevented pushing a 0 value when the observer never fired. The Pug templates had matching guards that hid the entire CLS section.
Fix