Skip non-interaction event entries when computing INP#2456
Merged
soulgalore merged 1 commit intomainfrom May 4, 2026
Merged
Conversation
The two INP scripts (interactionToNextPaint.js and interactionToNextPaintInfo.js) walk the buffered `event` and `first-input` PerformanceObserver records, but unlike web-vitals' upstream `lib/interactions.ts` they don't filter to entries with `interactionId > 0`. The browser only assigns a non-zero interactionId to events that are part of a discrete user interaction (a click's pointerdown/up, keydown/up, etc.); a bare `pointerover` from a stationary OS cursor that happens to be over content as it paints gets `interactionId === 0`. Without that guard automated runs regularly report INP from the cursor passing under freshly-rendered content during navigation. The hover entries land under `longestInteractionMap[0]`, are treated as a single "interaction" with ever-growing latency, and when no real user interaction happens during the iteration that synthetic value is what gets returned. The DevTools-trace variant of this code (`lib/chrome/webdriver/devtools/inp.js`) already has the `entry.interactionId > 0` guard, so the rest of the codebase already treats it as the right shape. Add `if (!entry.interactionId) continue;` at the top of the processing loop in both scripts to match web-vitals. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: Ia574f1d734f9b7d5b5b32174c580c9effd43f629
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The two INP scripts (interactionToNextPaint.js and interactionToNextPaintInfo.js) walk the buffered
eventandfirst-inputPerformanceObserver records, but unlike web-vitals' upstreamlib/interactions.tsthey don't filter to entries withinteractionId > 0. The browser only assigns a non-zero interactionId to events that are part of a discrete user interaction (a click's pointerdown/up, keydown/up, etc.); a barepointeroverfrom a stationary OS cursor that happens to be over content as it paints getsinteractionId === 0.Without that guard automated runs regularly report INP from the cursor passing under freshly-rendered content during navigation. The hover entries land under
longestInteractionMap[0], are treated as a single "interaction" with ever-growing latency, and when no real user interaction happens during the iteration that synthetic value is what gets returned. The DevTools-trace variant of this code (lib/chrome/webdriver/devtools/inp.js) already has theentry.interactionId > 0guard, so the rest of the codebase already treats it as the right shape.Add
if (!entry.interactionId) continue;at the top of the processing loop in both scripts to match web-vitals.Change-Id: Ia574f1d734f9b7d5b5b32174c580c9effd43f629