Repository: airbnb/lottie-ios
File: Sources/Private/Experimental/ExperimentalAnimationLayer.swift (Swift)

Code before:
    animationProgressTracker.fromValue = 0
    animationProgressTracker.toValue = 1

    let timedProgressAnimation = animationProgressTracker.timed(with: context, for: self)
    timedProgressAnimation.delegate = currentAnimationConfiguration?.animationContext.closure
    add(timedProgressAnimation, forKey: #keyPath(animationProgress))
  }

}

// MARK: RootAnimationLayer

extension ExperimentalAnimationLayer: RootAnimationLayer {

  var primaryAnimationKey: AnimationKey {
    .specific(#keyPath(animationProgress))
  }

  var currentFrame: AnimationFrameTime {
    get {
      animation.frameTime(forProgress: (presentation() ?? self).animationProgress)
    }
    set {
      // We can display a specific frame of the animation by setting
      // `timeOffset` of this layer. This requires setting up the layer hierarchy
      // with a specific configuration (speed=0, etc) at least one. But if
      // the layer hierarchy is already set up correctly, we can update the
      // `timeOffset` very cheaply.
      let requiredTimingConfiguration = CAMediaTimingConfiguration(speed: 0)

      if
        currentAnimationConfiguration?.timingConfiguration != requiredTimingConfiguration
        || currentAnimationConfiguration?.animationContext.playFrom != animation.startFrame
        || currentAnimationConfiguration?.animationContext.playTo != animation.endFrame
      {
        setupAnimation(
          context: .init(playFrom: animation.startFrame, playTo: animation.endFrame, closure: nil),
          timingConfiguration: requiredTimingConfiguration)
      }

      timeOffset = animation.time(forFrame: newValue)
    }
  }

  var renderScale: CGFloat {
    get { 0 }
    set { LottieLogger.shared.assertionFailure("`renderScale` is currently unsupported") }
  }

  var respectAnimationFrameRate: Bool {
    get { false }

Review comment (suggestion):
```suggestion
      // with a specific configuration (speed=0, etc) at least once. But if
```

Code after:
    animationProgressTracker.fromValue = 0
    animationProgressTracker.toValue = 1

    let timedProgressAnimation = animationProgressTracker.timed(with: context, for: self)
    timedProgressAnimation.delegate = currentAnimationConfiguration?.animationContext.closure
    add(timedProgressAnimation, forKey: #keyPath(animationProgress))
  }

}

// MARK: RootAnimationLayer

extension ExperimentalAnimationLayer: RootAnimationLayer {

  var primaryAnimationKey: AnimationKey {
    .specific(#keyPath(animationProgress))
  }

  var currentFrame: AnimationFrameTime {
    get {
      animation.frameTime(forProgress: (presentation() ?? self).animationProgress)
    }
    set {
      // We can display a specific frame of the animation by setting
      // `timeOffset` of this layer. This requires setting up the layer hierarchy
      // with a specific configuration (speed=0, etc) at least once. But if
      // the layer hierarchy is already set up correctly, we can update the
      // `timeOffset` very cheaply.
      let requiredAnimationConfiguration = AnimationConfiguration(
        animationContext: AnimationContext(
          playFrom: animation.startFrame,
          playTo: animation.endFrame,
          closure: nil),
        timingConfiguration: CAMediaTimingConfiguration(speed: 0))

      if currentAnimationConfiguration != requiredAnimationConfiguration {
        setupAnimation(
          context: requiredAnimationConfiguration.animationContext,
          timingConfiguration: requiredAnimationConfiguration.timingConfiguration)
      }

      timeOffset = animation.time(forFrame: newValue)
    }
  }

  var renderScale: CGFloat {
    get { 0 }
    set { LottieLogger.shared.assertionFailure("`renderScale` is currently unsupported") }
  }

  var respectAnimationFrameRate: Bool {