filepond icon indicating copy to clipboard operation
filepond copied to clipboard

Fix cpu performance issues

Open Mortaro opened this issue 1 year ago • 5 comments

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: image

after: image

Mortaro avatar Feb 10 '23 21:02 Mortaro

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).

rikschennink avatar Feb 12 '23 17:02 rikschennink

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

Mortaro avatar Feb 16 '23 02:02 Mortaro

Thanks for clarifying, I'll go over the code as soon as possible and will merge if it looks okay. Probably end of February.

rikschennink avatar Feb 16 '23 08:02 rikschennink

Thanks!

Mortaro avatar Feb 16 '23 14:02 Mortaro

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.

rikschennink avatar Mar 01 '23 09:03 rikschennink