-
Notifications
You must be signed in to change notification settings - Fork 9.6k
core(lantern): compute LCP as FCP when they occur within the same frame #16782
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
base: main
Are you sure you want to change the base?
Conversation
|
I tried my best to measure the impact across the board, but I ran into one Lighthouse peculiarity that I couldn’t overcome. From the link above:
Would appreciate some tips if you know what’s causing this / how to solve this! (Pre-warming the browser where you open it ahead of time and load Ah, and, yes, let me know what the next best steps are / how I can help to get this merged :) |
Full comment
Yeah no you’re right! TBH I was going forward off @paulirish’s “we should be fine”. But FCP and LCP having the same timestamp on an unthrottled connection is not a strong assumption. Ultimately, what I’m trying to solve here is cases like this one or this one, where (upon a manual trace) it’s clear FCP and LCP refer to the same element and should be the same no matter what. Looking at all the pages I collected for the tests, it looks like this mainly affects text-first pages. So I wonder if we can make the heuristic more sound if we focus on text only? E.g.:
For the context, I think it’s unlikely we’ll get to “100% accurate” with these heuristics – but my thinking here is “we already aren’t accurate today, can we make this more accurate even if it’s not perfect”? That said, if none of these look sound, happy to close this and move to the next improvement! Curious what you think :) |
|
@brendankenny kind follow-up re: the above q! curious about your thoughts (not necessarily the final answer). also happy to gchat (ivan at 3perf dot com) if it’s easier. thank you :) |
|
Catching up here. This seems like a sensible change, given we account for more than just "same ts" (for the reasons Brendan pointed out). Same time + same node id seems sufficient to me, and has the benefit of being simple to understand. Would that still resolve the majority cases you tested against? |
|
Thank you for catching up! I think checking for node ID won’t be helpful, for two reasons: It doesn’t address what Brendan pointed outBrendan describes the following scenario:
This is a trivial example that breaks the heuristic implemented in this PR. The code here will see that unthrottled LCP is equal to FCP, and it will simulate the throttled LCP as also being equal to FCP, even though that’s not right. Comparing node IDs doesn’t actually helpThe other issue (as I realized earlier) is that comparing node IDs is useless. For LCP, there’s a clear way to link it to a node ID: look at the paint → find the biggest text or image node → take its id. That’s what Chrome does. But how do you do it for FCP?
So, adding the ¹ — or, in practice, Hence, we have three routes:
(If this is still confusing, lmk! It’s 4 am here :D so maybe I’m not explaining this well.) |
|
To make it really clear what the issue is, the biggest example is Wikipedia. You can see how the LCP element gets rendered in the very first paint, and there’s no network or CPU delay (it’s plain HTML with a system font), and yet the simulated LCP still ends up much higher than FCP:
|



Summary
This PR implements the first change discussed in #16539. When real-world FCP and LCP are the same, we assume they originated from the same element (that’s roughly how it works inside Chromium), and we make the simulated LCP also equal the simulated FCP.
This leads to some sites getting better (and hopefully fairer) scores. How many sites are affected, and how better are the scores? See https://observablehq.com/d/f62cde3eb2ec3e76 for a study across ~350 sites.
Related Issues/PRs
#16539