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

Enable cloning in memory to speed up rive load when using runtime asset swapping #434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tguerin
Copy link
Contributor

@tguerin tguerin commented Nov 20, 2024

When using AssetLoader for runtime asset swapping, there is no straightforward way to reuse a RiveFile. Each time it's needed, it must be re-imported. While debugging performance, I noticed a significant amount of time was spent in the _readRuntimeObject method, leading to inefficiencies.

To address this, I implemented a caching mechanism to store RiveFile objects and enable cloning them directly in memory. This eliminates the need for repetitive re-imports and significantly reduces loading overhead.

This change resulted in a substantial improvement in loading times, with a performance boost of 4x to 10x depending on the use case.

What do you think about this approach? Are there any additional considerations or potential pitfalls I should address?

@HayesGordon
Copy link
Contributor

This is great, @tguerin; we'll get this reviewed as soon as possible.

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