bvaughn / react-virtualized-auto-sizer

Standalone version of the AutoSizer component from react-virtualized

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ResizeObserver loop limit exceeded

Grief opened this issue · comments

commented

After updating from 1.0.11 to 1.0.12 the following code
window.addEventListener("error", (e) => {...} started to receive the error ResizeObserver loop limit exceeded continuously.

That happens in chromium-based browsers only

Share a repro and I'll take a look.

commented

@bvaughn git clone https://github.com/Grief/bug.git && cd bug && npm install && npm start

I recorded a Replay of the repro you shared:
https://app.replay.io/recording/05679afd-311d-44cb-b68d-ea892a14b368

I don't understand why this is considered an error. It looks like ResizeObserver is only being instantiated twice (because of "strict effects" mode) and the first one is properly disconnected. Seems expected to me?

The resize handler does get called multiple times (4) which might be unexpected? The dimensions when it's called are:

  • 151 x 151
  • 151 x 151
  • 150 x 150
  • 151 x 151

Doing a bit of research on this error and found this explanation:

I believe this error is the same as the one listed here as part of the ResizeObserver spec. Chromium based browsers seem to use a different error message than that exact one, but in Firefox the error message is the same.

This error is emitted if a resize event happens and the browser is unable to notify all the listeners within that frame. In our app this happens because we update some fairly global React state directly from the react-resize-detector callback, which triggered several React components to re-render at once. Because React re-renders synchronously, this delayed the browser’s paint until a frame or two later, causing this error.

I’m not sure if the browser eventually does notify all the listeners and this warning just means there was a dropped frame, or if some of them just get skipped for that event? If it’s the former then this is potentially an error that is safe to ignore, if it’s the latter than probably not.

That makes sense.

Seems like resolving it would be a matter of debouncing the setState call.

Fixed in 12ddd48; tested with your repro and verified that the error alert is no longer shown.

Fix published in v1.0.14

Thanks for the repro!

commented

@bvaughn Thank you very much for such a quick fix! World will be much better if all the devs would react so fast