Skip to content

Running many animations on timer when the tab is in background causes a memory leak #9865

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

Open
angryziber opened this issue Dec 8, 2023 · 4 comments
Labels
awaiting submitter needs a reproduction, or clarification transition/animation

Comments

@angryziber
Copy link

Describe the bug

Probably because Chrome throttles timers/rendering when tab is not active.

Reproduction

Run many e.g. flip animations when the browser tab is not active and it eventually crashes.

Probably all animation functions should check for
document.visibilityState === 'visible' before they are run, this will save CPU and memory when tabs are not active.

Logs

No response

System Info

Chrome 120

Severity

annoyance

@angryziber angryziber changed the title Running many animations on timer when the tab is in background causes a memoty leak Running many animations on timer when the tab is in background causes a memory leak Dec 8, 2023
@trueadm
Copy link
Contributor

trueadm commented Dec 8, 2023

Is this for Svelte 4 or Svelte 5?

@angryziber
Copy link
Author

Svelte 4

@angryziber
Copy link
Author

We are using the following workaround now:

export const flipIfVisible: typeof flip = (...args) => (document.visibilityState === 'visible' ? flip(...args) : {});

@dummdidumm
Copy link
Member

Could you check if this still happens in Svelte 5?

@dummdidumm dummdidumm added awaiting submitter needs a reproduction, or clarification transition/animation labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter needs a reproduction, or clarification transition/animation
Projects
None yet
Development

No branches or pull requests

3 participants