Quick answer: A ResizeObserver callback changed the size of an element it is observing, so the browser postponed one notification to the next frame and reported that on window. Nothing was lost. A few of these at startup or during a window resize are harmless. One per frame means a feedback loop: in a game, usually canvas sizing code that changes the layout it is measuring. Give the canvas a CSS size that does not depend on its width and height attributes, skip size changes that change nothing, and filter the leftovers out of your error handler.
This message tends to arrive from an error tracker, not from the console: the largest entry in the list, with no stack, no line number and a count in the thousands. The game seems fine. Sometimes it is fine, and the entry is noise from a callback that needed one extra frame to settle. Sometimes the same message is the only visible sign of a canvas that grows by a few pixels every frame. This guide explains what the browser is reporting, how to tell the two cases apart in a minute, the canvas layouts that cause a real loop, and how to fix and filter it.
- The exact error
- What the browser is telling you
- Harmless or a real loop
- How canvas sizing creates the loop
- Fix: make the canvas box independent of its attributes
- Fix: skip no-op changes and apply the size in the frame loop
- Filter it out of your error handler
- Confirm the fix
- What the Bugnet Web SDK does with this event
- Related guides
- Frequently asked questions
The exact error
ResizeObserver loop completed with undelivered notifications.
Current Chrome, Firefox and Safari all use this text, which comes from the ResizeObserver specification. Older Chrome versions reported the same event as:
ResizeObserver loop limit exceeded
It is delivered as an error event on window, and it is unusual among errors because nothing was thrown. There is no Error object and no stack. This is what a handler receives in current builds:
| Property | Chrome, Safari | Firefox |
|---|---|---|
event.message | "ResizeObserver loop completed with undelivered notifications." | The same |
event.filename | The page URL | "" |
event.lineno, event.colno | 0, 0 | 0, 0 |
event.error | null | undefined |
Chrome does not print the event in the DevTools console. You see it only where something listens for error events: window.onerror, an error reporting script, a test runner, or a dev-server overlay. That is why it appears to exist only in production.
What the browser is telling you
Once per frame, after layout, the browser collects every observed element whose size changed and calls the observers. A callback is allowed to change the page, so the browser lays out again and checks for new size changes. To guarantee that this ends, each round after the first only notifies elements that are deeper in the DOM tree than the shallowest element notified in the round before.
If a callback changes the size of an observed element that is not deeper (the element it was just called for, or one of its ancestors), that change cannot be delivered in the current frame. The browser then does two things. It fires this error event on window, and it delivers the skipped notification in the next frame. “Undelivered” means postponed by one frame.
So the message has one precise meaning: during this frame, a ResizeObserver callback resized something it observes at the same level or above. Whether that matters depends on whether it happens once or forever.
Harmless or a real loop
| Pattern | What is happening | Action |
|---|---|---|
| Once at startup, or once per window resize or orientation change | A callback adjusted its own target, and the layout settled on the next frame | Filter it. Fix it if cheap |
| Occasionally, from pages where an ad, consent banner or embedded widget is present | Someone else’s observer | Filter it |
| Every frame, including when nothing on screen is changing | A feedback loop: each callback causes the next size change | Fix it |
A real loop has symptoms beyond the message. The canvas or the page grows steadily, a scrollbar appears and lengthens, the layout flickers between two sizes, or the frame rate drops because the canvas buffer is reallocated and cleared every frame.
To find out which case you have, count the events. Paste this into the console of the running game, or add it to a debug build:
let resizeLoopErrors = 0;
window.addEventListener("error", (event) => {
if (event.message && event.message.startsWith("ResizeObserver loop")) {
resizeLoopErrors++;
}
});
setInterval(() => {
if (resizeLoopErrors > 0) {
console.log("ResizeObserver loop errors in the last second:", resizeLoopErrors);
}
resizeLoopErrors = 0;
}, 1000);
Leave the window alone. Silence means you are in one of the harmless rows. A steady number near the display’s refresh rate is a loop. Then log canvas.width and canvas.height once a second: in a loop, at least one of them keeps changing.
How canvas sizing creates the loop
A canvas has two sizes. The width and height attributes set the drawing buffer, in pixels. CSS sets the box the canvas occupies on the page. When no CSS size is given, the attributes decide the box as well, and that is the opening for a loop: code that sets the attributes from a measured size changes the size being measured.
This is a typical responsive setup that loops:
<div id="game-wrap">
<canvas id="game"></canvas>
</div>
#game-wrap { width: 100%; }
#game { width: 100%; }
const wrap = document.getElementById("game-wrap");
const canvas = document.getElementById("game");
new ResizeObserver((entries) => {
const rect = entries[0].contentRect;
const dpr = window.devicePixelRatio || 1;
canvas.width = Math.round(rect.width * dpr);
canvas.height = Math.round(rect.height * dpr);
}).observe(wrap);
The wrapper has no height of its own, so its height comes from the canvas. A canvas is an inline element by default and sits on the text baseline, which leaves a few pixels of space beneath it. The wrapper is therefore slightly taller than the canvas. The callback makes the canvas as tall as the wrapper, the wrapper grows by the gap, and the observer fires again. On a test page this layout grew by 4 pixels per frame, with the error on every frame, in Chrome, Firefox and Safari’s engine.
Two other versions of the same mistake:
- Observing the canvas itself with no CSS size. The callback reads the content size, multiplies by
devicePixelRatioand writes the attributes. On a screen with a ratio of 2, the canvas doubles every frame. - A scrollbar that toggles. The resized canvas makes the page tall enough to scroll, the scrollbar narrows the container, the callback shrinks the canvas, the scrollbar disappears, and the container widens again.
HUD code can do it without a canvas: a callback that changes font size or padding to fit text into a box changes the size of that box.
Fix: make the canvas box independent of its attributes
Let CSS alone decide how big the canvas is on the page. Then writing the attributes cannot move anything, and the loop has nothing to feed on. Give the wrapper a size that does not come from its content, and take the canvas out of the flow:
#game-wrap {
position: relative;
width: 100%;
aspect-ratio: 16 / 9; /* or height: 100vh for a full-window game */
}
#game {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
display: block removes the baseline gap. position: absolute removes the canvas from the wrapper’s height calculation altogether. For a game that fills the window, add overflow: hidden to body so no scrollbar can appear and change the available width.
With this CSS, observing the wrapper or the canvas gives the same result, because the canvas box is always the wrapper box. With the broken CSS, neither choice is safe. The CSS is the fix. The choice of target is secondary.
Fix: skip no-op changes and apply the size in the frame loop
Two changes to the code remove the remaining one-off errors and some wasted work.
First, never write the attributes when the value is unchanged. Assigning canvas.width clears the canvas and resets its drawing state even when the number is the same.
Second, do not resize inside the observer callback. Record the size there and apply it at the start of the next frame. The layout is then never changed in the middle of the observer’s delivery, and the buffer is resized immediately before you draw into it, which avoids a blank frame.
const canvas = document.getElementById("game");
let pendingSize = null;
const observer = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry.devicePixelContentBoxSize) {
const box = entry.devicePixelContentBoxSize[0];
pendingSize = { width: box.inlineSize, height: box.blockSize };
} else {
const box = entry.contentBoxSize[0];
const dpr = window.devicePixelRatio || 1;
pendingSize = {
width: Math.round(box.inlineSize * dpr),
height: Math.round(box.blockSize * dpr),
};
}
});
try {
observer.observe(canvas, { box: "device-pixel-content-box" });
} catch (err) {
observer.observe(canvas); // browsers without device-pixel-content-box
}
function applyPendingSize() {
if (!pendingSize) return;
const { width, height } = pendingSize;
pendingSize = null;
if (canvas.width === width && canvas.height === height) return;
canvas.width = width;
canvas.height = height;
onResize(width, height); // your code: gl.viewport, camera projection, UI layout
}
function frame(time) {
applyPendingSize();
update(time);
draw();
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
devicePixelContentBoxSize reports the canvas box in physical pixels, already rounded the way the browser rounds it, which contentRect multiplied by devicePixelRatio can miss by one pixel at fractional zoom levels. Chrome and Firefox support it. In the WebKit build tested for this guide, observe() with that box option throws a TypeError, which is what the try/catch handles.
One warning about deferring: it removes the error message whether or not the loop is real. With the broken CSS from the previous section, moving the resize into requestAnimationFrame produced zero errors and a canvas that still grew every frame. Apply the CSS fix first and treat the deferral as the second step.
Filter it out of your error handler
After the fixes, the events that remain come from code you do not control, and they carry nothing to debug. Count them and keep them out of the bug list. Matching on the first words covers both the current and the older wording:
let resizeLoopCount = 0;
window.addEventListener("error", (event) => {
if (event.message && event.message.startsWith("ResizeObserver loop")) {
resizeLoopCount++;
return;
}
sendReport(event.error || new Error(event.message));
});
If a reporting script you did not write installs its own listener, yours cannot return on its behalf. Listeners on the same target run in the order they were added, so register a filter before that script starts and stop the event there:
window.addEventListener("error", (event) => {
if (event.message && event.message.startsWith("ResizeObserver loop")) {
event.stopImmediatePropagation();
}
});
Send resizeLoopCount with your session data if you can. A count that jumps after a release is the cheapest regression test for a layout loop you will get. The general handler setup is covered in window.onerror vs unhandledrejection.
Confirm the fix
- Run the counter from earlier with the window idle. It should print nothing.
- Resize the window, toggle fullscreen and rotate a phone. At most a line or two should appear, and
canvas.widthshould settle at once. - Change the browser zoom and, if you have two monitors with different scaling, drag the window between them. Both change
devicePixelRatio, and the buffer size should follow. - Check that the picture is sharp:
canvas.widthdivided bycanvas.clientWidthshould be close todevicePixelRatio. - Repeat in Firefox and Safari, and inside the portal’s iframe if the game is embedded.
What the Bugnet Web SDK does with this event
The Bugnet Web SDK adds an error listener on window in Bugnet.init(), so it receives this event like any other. The current SDK recognizes both wordings of the message and drops the event before anything is filed: no report is created, and the session is not marked as crashed. Real errors on the same page are still filed.
An older copy of bugnet-sdk.js does not have that list. It files the event as [Error] ResizeObserver loop completed with undelivered notifications. with category crash and priority critical, once per session, and marks the session as crashed for the crash-free session figure although the game kept running. Those reports stack into one entry with an occurrence count, and on the free plan they come out of the same total of up to 100 as real bugs. If you see that entry in your project, download the SDK again. Until you can ship the update, the second snippet in the filter section does the same job: add that listener before you call Bugnet.init() and the SDK never sees the event.
Skipping the report does not fix a loop that keeps resizing the canvas, so apply the fix above first. For other messages you have decided are noise, pass ignoreErrors to Bugnet.init(). A string matches anywhere in the message and a regular expression is tested against it:
Bugnet.init({
apiKey: "YOUR_API_KEY",
ignoreErrors: ["Extension context invalidated", /^AbortError\b/]
});
Do not turn off autoCaptureErrors for this. It silences every real error along with the noise. Setup details are in the SDK docs.
Related guides
- window.onerror vs unhandledrejection: Catching Every JavaScript Error in an HTML5 Game
- What Does “Script error.” Mean in a Web Game? (and How to Get the Real Error)
- How to Fix Blurry Pixel Art in a Web Game Without image-rendering: pixelated
- How to Fix a “WebGL context lost” Error in a Web Game
- How to Fix “Uncaught TypeError: Cannot read properties of undefined” in a Web Game
Frequently asked questions
What does ResizeObserver loop completed with undelivered notifications mean?
A ResizeObserver callback changed the size of an observed element at the same depth or higher in the page, so the browser could not deliver that change in the same frame. It reports this as an error event on window and delivers the notification on the next frame. No exception was thrown and nothing was lost.
Is ResizeObserver loop limit exceeded the same error?
Yes. That is the wording older Chrome versions used for the same event. Current Chrome, Firefox and Safari all use ResizeObserver loop completed with undelivered notifications, which is the text in the specification.
Can I ignore the ResizeObserver loop error?
If it fires once at startup or once per window resize, yes: filter it out of your error reports. If it fires every frame while nothing is changing, it is a feedback loop that keeps resizing your canvas or layout, and it needs a fix.
Why does my canvas keep growing when I resize it with ResizeObserver?
The canvas has no CSS size of its own, so its width and height attributes decide its size on the page. The callback sets the attributes from the measured size, which makes the measured element bigger, which calls the callback again. Give the canvas a CSS size that does not depend on its attributes, for example position absolute and 100 percent of a wrapper with a fixed aspect ratio.
Why is there no stack trace for this error?
The browser creates the error event itself, with a message and no Error object. In Chrome and Safari the file name is the page URL and the line is 0, and in Firefox the file name is empty. Chrome does not print it in the console, so it normally shows up only in error trackers and test tools.
Count the events with the window idle: silence means noise you can filter, a steady stream means your sizing code is resizing what it measures. Fix the CSS so the canvas attributes cannot affect layout before you defer or filter anything.