Skip to content

Unable to reach the end of the animation when setting .currentProgress with .coreAnimation engine #2209

@m-yeroshenko

Description

@m-yeroshenko

Hi everyone!

First of all, thanks for such a great library for dealing with animations.
I am sorry to say that I'm having an issue when using the latest version 4.3.3 (actually, it is also present on 4.3.0).

So, I have a few animation JSONs and have to control their progress with the SwiftUI.Slider view.
When using the .mainThread rendering engine everything is fine, but once I switch to the .coreAnimation I cannot reach the animation's latest "frame".

I would appreciate any help with this.

Which Version of Lottie are you using?

Lottie 4.3.3

.mainThread behavior

Screen.Recording.2023-10-12.at.10.02.06.mov

.coreAnimation behavior

Screen.Recording.2023-10-12.at.10.01.02.mov

Animation JSON

animation.json

Code to reproduce the behavior

import Lottie
import SwiftUI

struct SwiftUIView: View {
  @State
  private var currentProgress: Double = .zero

  let jsonURL = Bundle.main.url(
    forResource: "animation",
    withExtension: "json"
  )

  var body: some View {
    if let jsonURL {
      VStack {
        LottieView {
          await LottieAnimation.loadedFrom(url: jsonURL)
        }
        .configuration(.init(renderingEngine: .mainThread))
        // .configuration(.init(renderingEngine: .coreAnimation))
        .resizable()
        .currentProgress(currentProgress)
        Slider(value: $currentProgress, in: 0 ... 1.01)
      }
    }
  }
}

#Preview {
  SwiftUIView()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions