Replies: 2 comments 5 replies
-
I would submit a PR but I fear I haven't read enough code to understand fully how CA mode works compared to Main Thread. I can't decide if animation should be removed first or the completion closure on the context should be called directly before setting the context to |
Beta Was this translation helpful? Give feedback.
-
Are you attempting to play multiple animations consecutively in a single run loop cycle? The Core Animation rendering engine always batches animation setup to the next runloop cycle. This makes it if multiple playback state are triggered sequentially in a single block of code, only one will actually be built and rendered. This is a pretty big performance improvement. With the Core Animation rendering engine in particular, it's expensive to build a new animation from scratch (which has to happen any time the playback state changes). One really common examples is that when initializing a I'm guessing that, since the animation setup is batched, only the last animation you apply is actually getting played, and the rest are basically getting cancelled before being played. |
Beta Was this translation helpful? Give feedback.
-
Which Version of Lottie are you using?
Lottie 4.4.0 (CocoaPods)
Expected Behavior
I'm expecting
completion
closure to be called in CA mode like in Main Thread mode.Actual Behavior
When I
play(…)
two animations on the sameAnimationView
(nowLottieAnimationView
) consecutively,completion
is called for both plays in Main Thread mode, but the behavior changes in the new CA mode.I think the first completion closure is discarded incorrectly here by
removeCurrentAnimationIfNecessary()
, which simply sets the currentAnimationContext
holding the closure tonil
:where the previous animation has not come to a full stop, triggering
CAAnimationDelegate
to ultimately call the completion closure in the previousAnimationContext
.In Main Thread mode,
removeCurrentAnimationIfNecessary()
first callsremoveAnimation(forKey:)
, which according to documentation does triggerCAAnimationDelegate
callbacks.Beta Was this translation helpful? Give feedback.
All reactions