filepond
filepond copied to clipboard
Fix cpu performance issues
Heyo, first of all, I love this project, thanks for all the cool stuff!
@mayconfsousa and I were creating a file pond component for https://nullstack.app and I noticed some freezes in the browser when I inspected CPU usage it was very high, and I noticed it happens a lot more on my main pc that runs at 240hz.
Turns out it was requestAnimationFrame being continuously called and hoggin the CPU even when moving away from the page that had the component.
I changed the logic to tick only when the component is visible
before:
after:
Thanks! I'm not sure I could find the "visible" detection part, do you mean visible as "scrolled into view" or visible as "tab is active"?
I wonder if:
- The upload queue still works when the tab is inactive.
- The animations correctly/automatically deal with CSS changes (that's why the loop runs).
Heyo, for my use case by visible I, mean "not all instances were destroyed", so as long as it still has 1 instance alive somewhere it works fine, but once they are all removed it stops ticking. Please let me know if there are any edge cases as I am only using a very basic use case of "start upload on an admin page, and go do something else in another tab" and i based myself on the test suite
Thanks for clarifying, I'll go over the code as soon as possible and will merge if it looks okay. Probably end of February.
Thanks!
I'm hesitant to merge it because and older version of Pintura used the same painter to render view updates. So in theory when unloading FilePond the image editor could stop working as well.