Skip to content
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

Browser errors with ResizeObserver #134

Closed
LeonEck opened this issue Sep 3, 2022 · 0 comments · Fixed by #131
Closed

Browser errors with ResizeObserver #134

LeonEck opened this issue Sep 3, 2022 · 0 comments · Fixed by #131
Assignees
Labels
bug Something isn't working

Comments

@LeonEck
Copy link
Owner

LeonEck commented Sep 3, 2022

Browser errors with ResizeObserver

Reproduction

Open https://stackblitz.com/edit/resizeobserver-bug?file=index.html and focus the input. The error messages will be added to the DOM bellow the input.

Description

When an autocomplete is attached to an input which width changes frequently (like in an animation), browsers throw errors originating in ResizeObserver. Chrome and Firefox do not display these errors in the console. Only Safari shows them. You have to listen to the onerror event to surface these errors. Tools like Cypress and monitoring tools for JS errors notice these errors as an unhandled exception.

  • Error message in Chrome: ResizeObserver loop limit exceeded
  • Error message in Firefox and Safari: ResizeObserver loop completed with undelivered notifications.

Even though these errors are raised, the overlay is correctly positioned, sized, and works just fine.

Research about the error messages

Research conclusion regarding error messages

There appears to be a consensus that these errors can be safely ignored. But at the same time this is very annoying since this process of ignoring it must be configured for all kinds of tools. Therefore it should still be desirable to prevent these errors from appearing.

Research into possible fixes

A suggestion mentioned when researching the error messages is to use requestAnimationFrame: https://stackoverflow.com/a/58701523

Based on the above linked answer this library updated its implementation: nolimits4web/swiper@0567641

Using requestAnimationFrame was also suggested for floating-ui but rejected: floating-ui/floating-ui#1740 (comment)

Nevertheless floating-ui has an option on autoUpdate to use animationFrame: https://floating-ui.com/docs/autoupdate#animationframe

Conclusion

I will activate animationFrame in the autoUpdate call. If this goes well and there is no negative feedback after a release, this implementation will remain in the lib. If something breaks or negative feedback is reported, I would consider either reverting (and recommending to ignore the errors) or implement an API option to toggle between the two implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant