web-vitals icon indicating copy to clipboard operation
web-vitals copied to clipboard

LCP is incorrect if image fails Timing-Allow-Origin check

Open mmocny opened this issue 4 years ago • 3 comments

I was recently surprised to find a mismatch between LCP reported by DevTools timeline and Web Vitals extension. It looks like the cause is simply because the Web Platform api cannot always report the renderTime of image elements which do not pass Timing Allow Origin check for Cross Origin requests.

One easy way to check when this is the case is to check if the renderTime property of the Entry is 0.

If that happens, I think the recorded LCP value is likely not accurate. (In one case I was looking at, it was off by 1.2seconds).

I wonder if it is worth at least warning the developer in such cases?

mmocny avatar Apr 23 '21 19:04 mmocny

@mmocny what do you think about this as a solution? https://github.com/GoogleChrome/web-vitals/issues/155

philipwalton avatar May 28 '21 20:05 philipwalton

When I filed this, my primary concern was as a developer testing, and a debug version of the library for such use cases is absolutely perfect for me.

The other aspect of this is developers reporting to RUM and then being surprised by mismatches with i.e. CrUX. I think that is addressed fine by documentation (and proactive education?) and needn't be a warning.

That said -- I don't think a debug version is super critical as we have increasingly many developer tools for CWV (such as the web-vitals overlap option in DevTools). I would use it if it were available!

mmocny avatar May 31 '21 16:05 mmocny

Added a link to my article in #327 and going to close this with that. We can track the debug version in #155

tunetheweb avatar Mar 06 '23 18:03 tunetheweb