Implement PerformanceEventTiming.interactionId (needed for INP, i.e. "interaction-to-next-paint")
Categories
(Core :: DOM: Performance APIs, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox138 | --- | fixed |
People
(Reporter: sefeng211, Assigned: canova)
References
Details
(Keywords: dev-doc-complete)
Attachments
(4 external files)
Updated•1 year ago
|
| Assignee | ||
Comment 1•1 year ago
|
||
This patch tries to follow the spec as much as possible. But unfortunately this
wasn't enough to pass all the web-platform tests and there were some issues
in the spec logic.
I'm adding the fixes to various issues in the following patches, to easily see
what needs to be updated in the spec. Please see the following patches.
Spec: https://www.w3.org/TR/event-timing/#sec-computing-interactionid
| Assignee | ||
Comment 2•1 year ago
|
||
| Assignee | ||
Comment 3•1 year ago
|
||
| Assignee | ||
Comment 4•1 year ago
|
||
| Reporter | ||
Updated•1 year ago
|
| Assignee | ||
Comment 5•1 year ago
|
||
Update on the work:
I experimented with implementing the interactionId. After directly following the spec, it didn't work correctly and had some issues. That's why I had to change the algorithm to make it work. But this means that the spec is incorrect/inaccurate. I have filed various issues in the spec to address these:
- https://github.com/w3c/event-timing/issues/145
- https://github.com/w3c/event-timing/issues/146
- https://github.com/w3c/event-timing/issues/147
And from bug 1948647:
| Assignee | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 6•1 year ago
|
||
Filed another spec bug about the keypress event: https://github.com/w3c/event-timing/issues/149
Updated•1 year ago
|
Comment 7•1 year ago
|
||
This should be documented at https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Experimental_features.
I'm just wondering why the fine-grained pref name dom.performance.event_timing.enable_interactionid is chosen. Shouldn't this be behind a more general dom.performance.interaction_to_next_paint.enabled pref? Or is this specific API meant to ship independently from the rest of the INP implementation?
Sebastian
| Assignee | ||
Comment 8•1 year ago
|
||
"Interaction to Next Paint" metric is not part of the W3C Event Timing spec. INP is computed by using PerformanceEventTiming.interactionId. So once this interactionId is landed, libraries like Core Web Vitals will be able to calculate the INP value.
If you are curious, this is a simplified version of how INP is calculated:
let maxDurations = {};
new PerformanceObserver(list => {
for (let entry of list.getEntries()) {
if (entry.interactionId > 0) {
let id = entry.interactionId;
if (!maxDurations[id]) {
maxDurations[id] = entry.duration;
} else {
maxDurations[id] = Math.max(maxDurations[id], entry.duration);
}
}
}
}).observe({ type: 'event', buffered: true, durationThreshold: 16 }) ;
// Then aggregate `maxDurations` and report to analytics.
As you can see, we use entry.interactionId to calculate INP. Since we are not implementing the "Interaction to Next Paint" metric directly inside Firefox, it doesn't make sense to name the pref that way.
Comment 10•1 year ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/37a93b5fec30
https://hg.mozilla.org/mozilla-central/rev/385377fb3e05
https://hg.mozilla.org/mozilla-central/rev/f34b842adbcf
https://hg.mozilla.org/mozilla-central/rev/3f9fd0de6a6c
Comment 11•1 year ago
|
||
MDN FF138 work for this tracked in https://github.com/mdn/content/issues/38885 - essentially addition of flag to compatibility data and info to the experimental features page.
Description
•