How to improve Lottie loading performance (load 23 Lotties in a collection stack views)

846 Views Asked by At

I faced a several problem to load a collection of Lottie animations. I explain my code. I have a storyboard which contains 24 views. In my view controller, It's referenced as a collection of IBoutlet with AnimationView as type like this @IBOutlet var lottieCollectionViews: [AnimationView]!

I have to load one Lottie (json of 80ko) per view, so I configured my code like this :

DispatchQueue.global(qos: .userInteractive).async {
            for n in 0...23 {
                let animation = Animation.named("box"+(n+1).description)
                DispatchQueue.main.async {
                    self.lottieCollectionViews[n].animation = animation
                }
            }
            
        }

But, I have memory issue with older iPhone (7 or SE) and it takes around 5/7sec to load. How can I improve the loading?

Thank you so much.

0

There are 0 best solutions below