-
Notifications
You must be signed in to change notification settings - Fork 142
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
Inflated LCP View timing when visibility change occurs during page load #1256
Comments
Screen recording of the issue reported by my teammate @dvndrsn Additional context - code snippets for the
|
For what it's worth, NewRelic appears to be aligning around the |
Hello, Thanks for raising this, we will look into it shortly. |
Hello, thanks for the thorough bug report! The Datadog RUM Browser SDK should indeed behave like the It seems that you are calling |
Nevermind, I found an obvious issue: #1259 |
Thanks again for the report. The mentioned PR should have fixed the issue. We'll make a release soon, probably tomorrow. Let us know if you still see something strange! |
Thanks for the quick response! We'll keep an eye out for the release |
Hey @BenoitZugmeyer, will this change be included in the 3.X series, or just 4.X? (We're currently in 3.X, delivered via CDN) |
I released the fix as part of v4.1.0. It won't be backported to 3.x as we don't usually maintain anterior versions. I encourage you to update to v4! |
DataDog Browser SDK with Real User Metrics (RUM) can potentially record inflated Largest Contentful Paint (LCP) values when a visibility change occurs during page load. When a user opens a long-loading website and then switches tabs, causing the original page to no longer be visible, PerformanceObserver will not report the LCP timing until the user switches back to the original tab (when the painting occurs).
The GoogleChrome/web-vitals reference implementation correctly ignores the LCP entries generated when the user switches back to the original tab if the page was not visible as it was loaded. The DataDog RUM client, however, does not ignore LCP entries that are generated when the tab is refocused. Inflated LCP values are passed through and reported to DataDog.
Both GoogleChrome/web-vitals and DataDog RUM correctly ignore LCP entries generated for pages that are opened and loaded entirely in the background (no visibility state change during load - always hidden).
There are ongoing discussions referencing this challenge in properly logging LCP in other libraries.
w3c/paint-timing#40
newrelic/newrelic-browser-agent#70
Here is the relevant section of the GoogleChrome/web-vitals implementation that ignores LCP events generated when the browser window is hidden:
https://github.com/GoogleChrome/web-vitals/blob/main/src/getLCP.ts#L40
https://github.com/GoogleChrome/web-vitals/blob/main/src/lib/getVisibilityWatcher.ts#L28
https://github.com/GoogleChrome/web-vitals/blob/main/src/lib/onHidden.ts#L33
Is there a workaround on the client side to avoid logging these inflated values or is a fix possible on the DataDog SDK side?
The text was updated successfully, but these errors were encountered: