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

ResizeObserver loop limit exceeded error while scrolling #112

Open
joekukish opened this issue Jan 21, 2022 · 3 comments
Open

ResizeObserver loop limit exceeded error while scrolling #112

joekukish opened this issue Jan 21, 2022 · 3 comments

Comments

@joekukish
Copy link
Contributor

joekukish commented Jan 21, 2022

Version

0.7.0-pre.2

Description

While migrating to the latest version of the virtualizer, I've noticed that an error with the ResizeObserver happens fairly often.

To reproduce:

  1. Go to https://polymerlabs.github.io/uni-virtualizer/scroll-to-index-lit-element/
  2. Open the console and type.
window.onerror = (e) => console.log(e);
  1. Scroll in the demo page.

Notice how the message ResizeObserver loop limit exceeded appears multiple times.

While doing the migration this error appears many times in the tests causing them to fail.

@joekukish joekukish changed the title ResizeObserver loop limit exceeded ResizeObserver loop limit exceeded error while scrolling Jan 21, 2022
@graynorton
Copy link
Contributor

Sorry for the slow response here.

I haven't had time to dig deeply, but I am quite confident that the ResizeObserver loop limit exceeded error message is benign in this case and can be ignored.

Virtualizer's ResizeObserver callback is invoked not only when existing DOM children resize, but also whenever virtualizer adds new physical children. In the latter case, the layout may then explicitly set the size of one of those just-created children, which would theoretically cause the RO to need to fire again within the same animation frame. I think it's in this case that the browser's loop-detection being triggered, but it's not a situation in which a loop will actually occur. Long-term, there may be a way for us to avoid the error, but I don't believe it's indicative of a real behavior or performance problem.

Various reading in and around this area:

https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
WICG/resize-observer#38
https://stackoverflow.com/questions/64238740/how-to-ignore-the-resizeobserver-loop-limit-exceeded-in-testcafe

@graynorton
Copy link
Contributor

Leaving the issue open for now, however, until we can take a deeper look.

@jpzwarte
Copy link

I managed to get rid of the error by wrapping the _childrenSizeChanged body in a requestAnimationFrame method.

Screenshot 2022-05-13 at 14 50 06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants