Skip to content

[Masonry] Fix ResizeObserver loop limit exceeded error#37208

Merged
hbjORbj merged 4 commits intomui:masterfrom
hbjORbj:fix/masonry
Jun 20, 2023
Merged

[Masonry] Fix ResizeObserver loop limit exceeded error#37208
hbjORbj merged 4 commits intomui:masterfrom
hbjORbj:fix/masonry

Conversation

@hbjORbj
Copy link
Copy Markdown
Contributor

@hbjORbj hbjORbj commented May 8, 2023

Closes #36909

Problem

  • ResizeObserver loop limit exceeded error is thrown when dynamically updating masonry children or refreshing the browser.

Solution

  • According to some research, this error occurred because ResizeObserver couldn't deliver all observations within a single animation frame. By wrapping it in requestAnimationFrame, we can limit the execution to a single frame.

Before

before.mov

After

after.mov

https://codesandbox.io/s/exciting-brattain-p010gm?file=/demo.tsx:0-1249

@mui-bot
Copy link
Copy Markdown

mui-bot commented May 8, 2023

Netlify deploy preview

https://deploy-preview-37208--material-ui.netlify.app/

Bundle size report

Details of bundle changes

Generated by 🚫 dangerJS against dd50f6b

@hbjORbj hbjORbj added package: lab Specific to the lab. type: regression A bug, but worse, it used to behave as expected. scope: masonry Changes related to the masonry. labels May 8, 2023
@hbjORbj hbjORbj requested a review from mnajdova May 8, 2023 14:13
@hbjORbj hbjORbj self-assigned this May 8, 2023
Copy link
Copy Markdown
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left just one comment for clarifying the need for the new line added.

Comment thread packages/mui-lab/src/Masonry/Masonry.js
@SanNic20
Copy link
Copy Markdown

SanNic20 commented Jun 7, 2023

@mnajdova : when will it be deployed?

Co-authored-by: Marija Najdova <mnajdova@gmail.com>
Signed-off-by: Diego Andai <diego@mui.com>
@DiegoAndai
Copy link
Copy Markdown
Member

@hbjORbj may we merge this one? 😊

@hbjORbj hbjORbj merged commit 6c93a3b into mui:master Jun 20, 2023
@hbjORbj
Copy link
Copy Markdown
Contributor Author

hbjORbj commented Jun 20, 2023

@SanNic20 This will be deployed on upcoming Monday.

@ZeeshanTamboli ZeeshanTamboli mentioned this pull request Jun 27, 2023
@aakif-quayyum
Copy link
Copy Markdown

Was this implemented as I am still receiving the error (ResizeObserver loop limit exceeded)?

@DiegoAndai
Copy link
Copy Markdown
Member

Hey @aakif-quayyum sorry for this, the error should be fixed in @mui/lab version 5.0.0-alpha.135. Could you try it out in that version and let me know if it's actually fixed?

@aakif-quayyum
Copy link
Copy Markdown

Yes, @DiegoAndai following the release of @mui/lab version 5.0.0-alpha.135 I no longer experieance this error, thanks a lot!

@kanon551
Copy link
Copy Markdown

kanon551 commented Jul 5, 2023

Working Fine now Thanks Guys. npm install @mui/lab@5.0.0-alpha.135
I had similar issue, While i had pagination implemented. Everytime when i click on next page to render the cards this ResizeObser Loop exceded error occured. It was very frustating. Now its working fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: lab Specific to the lab. scope: masonry Changes related to the masonry. type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Masonry] ResizeObserver loop limit exceeded

7 participants