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: improved memory profile for transitions/animations #12796

Merged
merged 2 commits into from
Aug 11, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Aug 11, 2024

Fixes #12719.

12759 previously would null the effect on animation. I thought it wasn't necessary, but clearly it still is (I removed transitions from my example and forgot to put them back in, oops). I think we should flag this with Chromium folks as it seems odd that we need to do this – having it makes no difference in Firefox.

I also noticed that the catch function retains the animation in Firefox. I don't think we even need it anymore, so that fixes the memory leak in Firefox. Strangely, this doesn't seem to affect Chromium.

Lastly, clearing on_finish and on_abort seems to help the memory profile in Firefox and Chromium. Given we do it in deactivate, it makes sense to do in abort too.

Copy link

changeset-bot bot commented Aug 11, 2024

🦋 Changeset detected

Latest commit: b568ad3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

animation.cancel();
}
})
.catch((e) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catch is necessary to prevent an unhandled rejection when a transition is aborted:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, I remember now. That sucks :/ can't think of why it causes FF to leak. I've tried making the animation undefined inside it but that doesn't help.

@Rich-Harris Rich-Harris merged commit 97c0150 into main Aug 11, 2024
9 checks passed
@Rich-Harris Rich-Harris deleted the more-transition-memory-leaks branch August 11, 2024 10:58
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.

Svelte 5 memory leak after transitions
2 participants