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

Fix cpu performance issues #893

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Mortaro
Copy link

@Mortaro Mortaro commented Feb 10, 2023

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

@rikschennink
Copy link
Collaborator

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

@Mortaro
Copy link
Author

Mortaro commented Feb 16, 2023

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

@rikschennink
Copy link
Collaborator

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

@Mortaro
Copy link
Author

Mortaro commented Feb 16, 2023

Thanks!

@rikschennink
Copy link
Collaborator

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.

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

Successfully merging this pull request may close these issues.

2 participants