-
Notifications
You must be signed in to change notification settings - Fork 411
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
Cap INP breakdowns to INP duration #528
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,10 +239,16 @@ const getIntersectingLoAFs = ( | |
|
||
const attributeINP = (metric: INPMetric): INPMetricWithAttribution => { | ||
const firstEntry = metric.entries[0]; | ||
const inpTime = firstEntry.startTime + metric.value; | ||
const group = entryToEntriesGroupMap.get(firstEntry)!; | ||
|
||
const processingStart = firstEntry.processingStart; | ||
const processingEnd = group.processingEnd; | ||
// processingEnd can extend beyond duration for modals where we artificially | ||
// mark event timing duration as that paint. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: "as that paint" comment is confusing (there is no actual paint) Perhaps just "where duration ends at the time modal dialog started (and provided visual feedback)" |
||
// See: https://github.com/GoogleChrome/web-vitals/issues/492 | ||
// So cap to the INP value. | ||
const processingEnd = | ||
group.processingEnd >= inpTime ? inpTime : group.processingEnd; | ||
|
||
// Sort the entries in processing time order. | ||
const processedEventEntries = group.entries.sort((a, b) => { | ||
|
@@ -274,6 +280,10 @@ const attributeINP = (metric: INPMetric): INPMetricWithAttribution => { | |
); | ||
|
||
const nextPaintTime = Math.max.apply(Math, nextPaintTimeCandidates); | ||
// If processingEnd has been capped to inpTime then presentationDelay is 0 | ||
// Else use the nextPaintTime | ||
const presentationDelay = | ||
processingEnd == inpTime ? 0 : Math.max(nextPaintTime - processingEnd, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a fine temporary solution, but, consider just creating a variable such as "used_fallback_time", set up top when (The goal is to expose a clue to event timing for this value, eventually.) BTW the case where endTime is rounded to within 8ms of processingEnd is almost always another "used_fallback_time" example (i.e. when we actually dont have a paint) |
||
|
||
const attribution: INPAttribution = { | ||
interactionTarget: getSelector(interactionTargetElement), | ||
|
@@ -285,7 +295,7 @@ const attributeINP = (metric: INPMetric): INPMetricWithAttribution => { | |
longAnimationFrameEntries: longAnimationFrameEntries, | ||
inputDelay: processingStart - firstEntry.startTime, | ||
processingDuration: processingEnd - processingStart, | ||
presentationDelay: Math.max(nextPaintTime - processingEnd, 0), | ||
presentationDelay: presentationDelay, | ||
loadState: getLoadState(firstEntry.startTime), | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: just call it
endTime
or something