rive-flutter
rive-flutter copied to clipboard
[feature] rive cache implemented like flare cache
I believe this can be done, after all cache stores bytes and this what the RiveFile wants right? It would be nice if we can leverage root bundle and warmup rive files. I don't have metrics or example where I see loading slowness, now that we don't have rasters, the size of the same animation is 6kb vs the old one 275kb. It might come handy to preload multiple rive files.
asset_cache will work to cache the binary riv file
This wasn't implemented because we were lacking a core feature that prevented an efficient caching solution from working. Good news is we now have it, so a caching solution can be implemented. For reference: https://github.com/rive-app/rive-flutter/pull/109
Previously when you loaded a .riv file, the deserialized content would be modified by animations, meaning it couldn't be re-used if the file was shown in another part of the app. It would need to be reloaded from raw bytes which meant cycles would be wasted on deserialization and initialization which can be expensive on complicated files.
What that all means is that a caching solution for the raw bytes wasn't sufficient, we need to cache the deserialized file and its artboards. Then instance the artboards on demand when a part of the app needs them from the already initialized source.
We can now add Flutter caching to our roadmap, I'll keep this issue open and reference it as we make progress.
asset_cache will work to cache the binary riv file
How?
Related to: https://github.com/rive-app/rive-flutter/issues/68