Skip to content

Commit

Permalink
Update the bug information and code example (GoogleChrome#6923)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton authored Dec 1, 2021
1 parent 7dc4cf1 commit fa37b24
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/site/content/en/blog/responsiveness/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,22 @@ new PerformanceObserver((entries) => {
// Get the interaction for this entry, or create one if it doesn't exist.
let interaction = interactionMap.get(entry.interactionId);
if (!interaction) {
interaction = {entries: []};
interaction = {latency: 0, entries: []};
interactionMap.set(entry.interactionId, interaction);
}
interaction.entries.push(entry);

const latency = Math.max(entry.duration, interaction.latency || 0);
const latency = Math.max(entry.duration, interaction.latency);
worstLatency = Math.max(worstLatency, latency);

const budget = entry.name.includes('key') ? 50 : 100;
const latencyOverBudget = latency - budget;
const latencyOverBudget = Math.max(latency - budget, 0);
worstLatencyOverBudget =
Math.max(latencyOverBudget, worstLatencyOverBudget);

// If this event adds additional latency, update the total over budget.
const newLatency = latency - (interaction.latency || 0);
if (newLatency > 0) {
totalLatencyOverBudget += newLatency;
if (latencyOverBudget) {
const oldLatencyOverBudget = Math.max(interaction.latency - budget, 0);
totalLatencyOverBudget += latencyOverBudget - oldLatencyOverBudget;
}

// Set the latency on the interaction so future events can reference.
Expand All @@ -290,9 +289,9 @@ new PerformanceObserver((entries) => {
{% Aside 'caution' %}
There are currently [a few
bugs](https://bugs.chromium.org/p/chromium/issues/list?q=label:proj-responsiveness-bugs)
in Chrome that affect accuracy of the reported interaction timestamps. We are
working to fix these bugs as soon as possible, and we recommend developers
test these strategies in Chrome Canary to get the most accurate results.
in Chrome that affect accuracy of the reported interaction timestamps. These
bugs have been fixed in version 98, so we recommend developers test these
strategies in Chrome Canary to get the most accurate results.
{% endAside %}

## Feedback
Expand Down

0 comments on commit fa37b24

Please sign in to comment.