Skip to content

Commit

Permalink
Fix layout animation regression introduced in 4.3.0 (#2194)
Browse files Browse the repository at this point in the history
  • Loading branch information
calda authored Sep 20, 2023
1 parent b1f170b commit 01a3ac1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ To install Lottie using [Swift Package Manager](https://github.com/apple/swift-p
or you can add the following dependency to your `Package.swift`:

```swift
.package(url: "https://github.com/airbnb/lottie-spm.git", from: "4.3.0")
.package(url: "https://github.com/airbnb/lottie-spm.git", from: "4.3.1")
```

When using Swift Package Manager we recommend using the [lottie-spm](https://github.com/airbnb/lottie-spm) repo instead of the main lottie-ios repo. The main git repository for [lottie-ios](https://github.com/airbnb/lottie-ios) is somewhat large (300+ MB), and Swift Package Manager always downloads the full repository with all git history. The [lottie-spm](https://github.com/airbnb/lottie-spm) repo is much smaller (less than 500kb), so can be downloaded much more quickly.
Expand Down
4 changes: 3 additions & 1 deletion Sources/Private/CoreAnimation/CoreAnimationLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ extension CoreAnimationLayer: RootAnimationLayer {
}

func forceDisplayUpdate() {
display()
// Unimplemented
// - We can't call `display()` here, because it would cause unexpected frame animations:
// https://github.com/airbnb/lottie-ios/issues/2193
}

func logHierarchyKeypaths() {
Expand Down
6 changes: 3 additions & 3 deletions Sources/Public/Animation/LottieAnimationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,9 @@ open class LottieAnimationView: LottieAnimationViewBase {

// MARK: Internal

// The backing CALayer for this animation view.
let lottieAnimationLayer: LottieAnimationLayer

var animationLayer: RootAnimationLayer? {
lottieAnimationLayer.rootAnimationLayer
}
Expand Down Expand Up @@ -1029,8 +1032,5 @@ open class LottieAnimationView: LottieAnimationViewBase {

// MARK: Private

// The backing CALayer for this animation view.
private let lottieAnimationLayer: LottieAnimationLayer

private let logger: LottieLogger
}
18 changes: 14 additions & 4 deletions Tests/TextProviderTests.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Created by Cal Stephens on 9/12/23.
// Copyright © 2023 Airbnb Inc. All rights reserved.

// Created by Cal Stephens on 5/2/22.
// Copyright © 2022 Airbnb Inc. All rights reserved.

import SnapshotTesting
import UIKit
import XCTest
Expand Down Expand Up @@ -79,7 +76,7 @@ final class TextProviderTests: XCTestCase {
configuration: configuration,
customSnapshotConfiguration: .customTextProvider(textProvider))!

animationView.forceDisplayUpdate()
animationView.renderContentsForUnitTests()

return textProvider.methodCalls
}
Expand Down Expand Up @@ -130,3 +127,16 @@ private final class LoggingAnimationKeypathTextProvider: AnimationKeypathTextPro
return nil
}
}

extension LottieAnimationView {
// Causes this `LottieAnimationView` to render its contents immediately
func renderContentsForUnitTests() {
if let mainThreadAnimationLayer = lottieAnimationLayer.animationLayer as? MainThreadAnimationLayer {
mainThreadAnimationLayer.forceDisplayUpdate()
} else if let coreAnimationLayer = lottieAnimationLayer.animationLayer as? CoreAnimationLayer {
// `forceDisplayUpdate()` is not implemented for `CoreAnimationLayer`, so instead we call
// `display()` to force it to render any pending animation configurations.
coreAnimationLayer.display()
}
}
}
2 changes: 1 addition & 1 deletion lottie-ios.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'lottie-ios'
s.version = '4.3.0'
s.version = '4.3.1'
s.summary = 'A library to render native animations from bodymovin json'

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lottie-ios",
"version": "4.3.0",
"version": "4.3.1",
"description": "Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with bodymovin and renders the vector animations natively on mobile and through React Native!",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 01a3ac1

Please sign in to comment.