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: 🐛 memory leak when creating LottieRenderer #102

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

theashraf
Copy link
Member

No description provided.

Copy link

changeset-bot bot commented Mar 19, 2024

⚠️ No Changeset found

Latest commit: e895589

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

@@ -31,10 +31,14 @@ pub struct LottieRenderer {

impl LottieRenderer {
pub fn new() -> Self {
let thorvg_canvas = Canvas::new(TvgEngine::TvgEngineSw, 0);
let mut thorvg_canvas = Canvas::new(TvgEngine::TvgEngineSw, 0);
Copy link
Member

@hermet hermet Mar 20, 2024

Choose a reason for hiding this comment

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

Maybe you can remove these dummy instances, you can set an LottieRenderer initialization flag (bool) to quickly bypass the calls for the other requested methods. The initialization toggle should be assigned within the load_data() method.

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, you can reuse the background and animation with calling clear(false) in the load method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great suggestion @hermet!

I was planning to reuse the same instances to avoid new mem allocation on load, i added this temp workaround for testing.

@theashraf theashraf self-assigned this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants