-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
[ResizeSensor] cancelAnimationFrame for reset when detach is called to prevent infinite loop and memory leak #282
Conversation
In ResizeSensor, we use requestAnimationFrame for reset. However, if an element is added to DOM and removed from DOM very quickly (even before the first reset happens), the reset itself will stuck in an infinite loop. It also causes memory leak because the reset function holds the element forever.
Good catch, thanks! |
@marcj Would you please do a minor version update on NPM? The tests of my project are very unstable due to the bug. I am replying on this fix to save the whole tests. |
Sure, v1.2.2 is released. |
Awesome, it saves my life. Thank you. @marcj |
@marcj & @gaoruhao Version 1.2.2 broke our website resizing.
Shouldn't it instead be (notice the
|
Indeed, that's incorrect, good catch! But it shouldn't break anything since its additional code that due to the bug isn't executed at all. What errors do you get? |
@marcj We don't get script error but with this change, the ResizeSensor handler won't get called. Our html5 app is quite simple so I'd expect this problem to be for most of the people.
I had a quick look and narrowed the issue down to the below change: The lastAnimationFrame variable is used in reset function so something must have gone wrong there? |
@marcj Should I raise new issue for the above? |
I am also having the same issue as mKlus with v1.2.2. |
@mathias999us @mKlus Fixed in v1.2.3 |
I am still having this issue with reset getting into infinite loop. |
In ResizeSensor, we use requestAnimationFrame for reset. However, if an element is added to DOM and removed from DOM very quickly (even before the first reset happens), the reset itself will stuck in an infinite loop. It also causes memory leak because the reset function holds the element forever.