-
Notifications
You must be signed in to change notification settings - Fork 1.2k
useResizeObserver not preventing Resize Observer errors in some situations #1924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Reproduced the error locally, will have to investigate to see if the solution in the blog you linked has any unforeseen side effects EDIT: Another possible solution is to wrap https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/utils/src/useResizeObserver.ts#L29-L33 in a requestAnimationFrame as suggested in the same stackoverflow post |
@LFDanLu is this still being investigated? We're seeing this in sentry.io after this PR was merged getsentry/sentry#32061 |
@dashed thanks for the reminder, this must have fell off my radar. I'll see if I can get this into one of our upcoming sprints but would welcome a PR! Just to note, my concerns were mainly centered around any odd flickering that may occur with adding a requestAnimationFrame. If any flickering was noticed, I was leaning towards trying to swallow this error/prevent it from causing noise since seems to be a benign error. |
See #4204 |
I've taken more time to look into this. Everyone who is on a newer version of React Spectrum can no longer reproduce. I believe this message was specific to our TableView and was telling us about a mistake in our code which we corrected across these PRs For future reference, if you're using our hook The mentioned solutions were all ways of hiding the loop. It is better not to hide this so we can all fix our code. This is what happened in 3474, though it may not look like we fixed a direct dom manipulation from the code changes because that code was hidden behind a few other layers of code. I am going to close this now. |
We've found someone able to reproduce again, reopening for more investigation |
I have a minimal reproduction https://codesandbox.io/s/clever-hodgkin-ygvn7r?file=/src/App.js Open in Safari it's due to this line
commenting it out fixes the error Note, this is actually a pretty new issue, we had and have fixed the issue with TableView showing this error. Potential solution to try: UPDATE: I can no longer reproduce this issue in React 18 (Combobox specifically) in the latest version (3.32.2) |
Looks like this is still happening for the TableView in React 17/16 specifically. Try https://reactspectrum.blob.core.windows.net/reactspectrum/14553eb3181befc00e81883864743b323491ce3a/storybook-16/index.html?path=/story/tableview--resize-test&providerSwitcher-express=false and https://reactspectrum.blob.core.windows.net/reactspectrum/14553eb3181befc00e81883864743b323491ce3a/storybook-17/index.html?path=/story/tableview--resize-test&providerSwitcher-express=false and check the console upon resizing the browser window in such a way that the TableView shrinks. |
Some additional info: this only started happening in React 17/16 from this PR. Before this, we didn't receive the Storybooks for testing, to reproduce simply open the javascript console and add a error listener via working case from the commit before: https://reactspectrum.blob.core.windows.net/reactspectrum/91515d24149449ffea8099f5c06eb588bd6b6c15/storybook-17/iframe.html?scrolling=false&strict=false&args=&providerSwitcher-locale=&providerSwitcher-theme=&providerSwitcher-scale=&providerSwitcher-express=false&id=tableview--static&viewMode=story |
🐛 Bug Report
In some situations, spectrum components that use
useResizeObserver
throw errors such asResizeObserver loop limit exceeded
to be thrown in Chrome and
ResizeObserver loop completed with undelivered notifications.
in Firefox.
Generally these errors are benign and can be swallowed. However, Safari's CORS policy throws anonymous script errors and swallowing all script errors in Safari is a less than ideal solution.
🤔 Expected Behavior
useResizeObserver should not be causing Resize Observers to throw errors.
😯 Current Behavior
💁 Possible Solution
Resize Observers generally throw these errors to prevent infinite loops as detailed here:
https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
But these errors are preventable using the approach detailed in this article:
https://blog.elantha.com/resizeobserver-loop-limit-exceeded/
🔦 Context
💻 Code Sample
🌍 Your Environment
🧢 Your Company/Team
Adobe / Marketo
Marketo
🕷 Tracking Issue (optional)
The text was updated successfully, but these errors were encountered: