Lottie performs poorly in SwiftUI #2517
shreyas-bangera-swiggy-02
started this conversation in
General
Replies: 1 comment 1 reply
-
Can you share a complete sample project demonstrating the issue? e.g. an Xcode project that can be built and ran, and has performance problems. Including a comparison of the performant UIKit integration vs non-performant SwiftUI integration would be helpful. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which Version of Lottie are you using?
Lottie 4.5.0
I'm using a lottie in a collection view. When I use lottie in the UIKit context, i.e. using a UICollectionViewCell subclass via
uikitCellRegistration
as can be seen in the attached code, it performs well without any issues. If I try to add the SwiftUI variant added via UIHostingConfiguration(swiftuiCellRegistration
), it starts to stutter with high CPU usage & on occasion results in app termination with memory warning. Shared the code below to reproduce the same. This setup is just to put things into perspective.In a pure SwiftUI setup, using a container such
LazyVStack
orList
instead ofUICollectionView
, the same performance degradation can be observed.On doing an app profile, it revealed the cause of hangs to be animation layer creation. In SwiftUI case, it seems to be called repeatedly creating the overhead.
Please check this on priority as our app is heavily reliant on Lotties & this issue is a bottleneck for us to build anything on SwiftUI.
Similar issue was reported earlier as well without much traction
App profile screenshot:
Expected Behavior
Performance in UIKit:
uikit_variant.MP4
Actual Behavior
Performance in SwiftUI:
swiftui_variant.MP4
Animation JSON
sample_lottie.json
Beta Was this translation helpful? Give feedback.
All reactions