Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tunetheweb
Copy link
Member

Fixes #492

Modals (alert(), confirm(), print()) do give feedback to the user, but also block the main thread so the event processing doesn't end when this shows. However, from an INP point of view, the feedback is given and so the duration is set to that timestamp.

I think it should be possible add a test case for this, but wanna agree on the change before going to that effort.

// mark event timing duration as that paint.
// See: https://github.com/GoogleChrome/web-vitals/issues/492
// So cap to the INP value.
const nextPaintTime = Math.min(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this change...

Looking at like 276 above, you are already including startTime + duration in the list of paint time candidates, which means its in the list of MAX and then also in the list of MIN. I think that means its always going to be picked?

(Note: I assume there is no difference between firstEntry.duration and metric.value but there can be)

Second, the comment anove is:

// Since entry durations are rounded to the nearest 8ms, we need to clamp
// the `nextPaintTime` value to be higher than the `processingEnd` or
// end time of any LoAF entry.

I think we are specifically looking for cases where startTime + duration is "accidentally" less than one of the alternative paintTimeCandidates (such as processingEnd) when we do rounding.

Now here by using startTime + duration when it is less than the alternatives, we are effectively just undoing that?

Might as well just delete this code instead? Or, selectively do it if its "less than 8ms off" or something?


Finally, also already capped the processingEnd time in this CL, so its also not useful to look at processingEnd as an alternative to paint time any more (it will always be smaller now).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now here by using startTime + duration when it is less than the alternatives, we are effectively just undoing that?

Urgh! I realised this earlier, and then completely forgot about it and committed it with further.

Might as well just delete this code instead?

I think we need to do something here, or we'll just move this incorrect breakdown to presentation delay.

Or, selectively do it if its "less than 8ms off" or something?

Yeah think we need something like this. Or if processingEnd is firstEntry.startTime + metric.value, then we can 0 out the presentation time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have another look not if you can @mmocny

Copy link
Member

@mmocny mmocny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some nit comments, but pre-approving.

Probably best to validate carefully...

@@ -239,10 +239,16 @@ const getIntersectingLoAFs = (

const attributeINP = (metric: INPMetric): INPMetricWithAttribution => {
const firstEntry = metric.entries[0];
const inpTime = firstEntry.startTime + metric.value;
Copy link
Member

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

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.
Copy link
Member

Choose a reason for hiding this comment

The 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)"

// 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);
Copy link
Member

Choose a reason for hiding this comment

The 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 endTime < processingEnd, and re-use that everywhere.

(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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Heads Up on Changes to INP Measurement When Interfered with JS Modal Dialogs
2 participants