Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix layout animation regression introduced in 4.3.0 #2194

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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