Skip to content

Skip non-interaction event entries when computing INP#2456

Merged
soulgalore merged 1 commit intomainfrom
inp-interaction-id-filter
May 4, 2026
Merged

Skip non-interaction event entries when computing INP#2456
soulgalore merged 1 commit intomainfrom
inp-interaction-id-filter

Conversation

@soulgalore
Copy link
Copy Markdown
Member

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.

Change-Id: Ia574f1d734f9b7d5b5b32174c580c9effd43f629

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
@soulgalore soulgalore merged commit 43a7ff9 into main May 4, 2026
16 checks passed
@soulgalore soulgalore deleted the inp-interaction-id-filter branch May 4, 2026 06:35
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.

1 participant