Replies: 4 comments
-
Guys, I wrote an AnimationImageProvider subclass that loads all the images on separate thread (slightly more efficient than standard FilepathAnimationProvider) and notifies end with a callback. Also it maintains cache for each animation and global cache separately (to flush on memory warning for example). It seems to be reliable and tested on extra huge 4k animations with tens of png's. The one disadvantage is that it assumes all images in the same folder. For example, if you export with AfterEffects plugin - it's not a problem, it puts all images under same folder by default, but I don't know if it's a rule for all possible exporters. API is as simple as that:
If you wish I can post it here, probably anyone faced the same issue. Also, maybe you may wish to include it along with standard ImageProviders? |
Beta Was this translation helpful? Give feedback.
-
Hey @iago849, I am facing the same issue with one of my projects. can you post the subclass you created? Thanks. |
Beta Was this translation helpful? Give feedback.
-
@nithindampetla sure here it is (you can change log to standard print)
|
Beta Was this translation helpful? Give feedback.
-
Here's the usage example
|
Beta Was this translation helpful? Give feedback.
-
Check these before submitting:
This issue is a:
Which Version of Lottie are you using?
Lottie 3.0
What Platform are you on?
What Language are you in?
Expected Behavior
reloadImages method of LayerImageProvider class loading images in main thread. I have lot of PNG's so it takes relatively huge amount of time. I cannot subclass anything (all important classes are marked as final).
So when I assign an animation object to animation view
self.animationView?.animation = animation
it leads to asking the sceneImageProvider for images. But reading and uncompressing PNGs is a very consuming operation. Could you make an advice how I can move it to separate thread? Or the way my custom AnimationImageProvider subclass can get list of images to load them to memory on separate thread, and then assign animation object to animation view when it will have some cache.
Thanks in advance!
Actual Behavior
Beta Was this translation helpful? Give feedback.
All reactions