-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce log volume from warning about After Effects expressions (#2196)
- Loading branch information
Showing
12 changed files
with
154 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Created by Cal Stephens on 9/19/23. | ||
// Copyright © 2023 Airbnb Inc. All rights reserved. | ||
|
||
import SnapshotTesting | ||
import UIKit | ||
import XCTest | ||
|
||
@testable import Lottie | ||
|
||
// MARK: - LoggingTests | ||
|
||
@MainActor | ||
final class LoggingTests: XCTestCase { | ||
|
||
// MARK: Internal | ||
|
||
func testAnimationWithNoIssues() async { | ||
await snapshotLoggedMessages( | ||
animationName: "LottieLogo1", | ||
configuration: LottieConfiguration(renderingEngine: .automatic)) | ||
} | ||
|
||
func testAutomaticFallbackToMainThreadRenderingEngine() async { | ||
// This animation is not supported by the Core Animation rendering engine | ||
// because it uses time remapping | ||
await snapshotLoggedMessages( | ||
animationName: "Boat_Loader", | ||
configuration: LottieConfiguration(renderingEngine: .automatic)) | ||
} | ||
|
||
func testCoreAnimationRenderingEngineUnsupportedAnimation() async { | ||
// This animation is not supported by the Core Animation rendering engine | ||
// because it uses time remapping | ||
await snapshotLoggedMessages( | ||
animationName: "Boat_Loader", | ||
configuration: LottieConfiguration(renderingEngine: .coreAnimation)) | ||
} | ||
|
||
func testExplicitMainThreadRenderingEngine() async { | ||
// This animation is not supported by the Core Animation rendering engine | ||
// because it uses time remapping. Manually specifying the Main Thread | ||
// rendering engine should silence the log messages. | ||
await snapshotLoggedMessages( | ||
animationName: "Boat_Loader", | ||
configuration: LottieConfiguration(renderingEngine: .mainThread)) | ||
} | ||
|
||
func testUnsupportedAfterEffectsExpressionsWarning() async { | ||
// This animation has unsupported After Effects expressions, which triggers a log message | ||
await snapshotLoggedMessages( | ||
animationName: "LottieFiles/growth", | ||
configuration: LottieConfiguration(renderingEngine: .automatic)) | ||
} | ||
|
||
// MARK: Private | ||
|
||
private func snapshotLoggedMessages( | ||
animationName: String, | ||
configuration: LottieConfiguration, | ||
function: String = #function, | ||
line: UInt = #line) | ||
async | ||
{ | ||
let loggedMessages = await loggedMessages(for: animationName, configuration: configuration) | ||
|
||
assertSnapshot( | ||
matching: loggedMessages.joined(separator: "\n"), | ||
as: .description, | ||
named: animationName, | ||
testName: function, | ||
line: line) | ||
} | ||
|
||
private func loggedMessages(for animationName: String, configuration: LottieConfiguration) async -> [String] { | ||
var logMessages = [String]() | ||
|
||
let logger = LottieLogger( | ||
assert: { condition, message, _, _ in | ||
if !condition() { | ||
logMessages.append("[assertionFailure] \(message())") | ||
} | ||
}, | ||
assertionFailure: { message, _, _ in | ||
logMessages.append("[assertionFailure] \(message())") | ||
}, | ||
warn: { message, _, _ in | ||
logMessages.append("[warning] \(message())") | ||
}, | ||
info: { message in | ||
logMessages.append("[info] \(message())") | ||
}) | ||
|
||
let animationView = await SnapshotConfiguration.makeAnimationView( | ||
for: animationName, | ||
configuration: configuration, | ||
logger: logger)! | ||
|
||
animationView.forceDisplayUpdate() | ||
|
||
if logMessages.isEmpty { | ||
return ["Animation setup did not emit any logs"] | ||
} | ||
|
||
return logMessages | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Tests/__Snapshots__/LoggingTests/testAnimationWithNoIssues.LottieLogo1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Animation setup did not emit any logs |
6 changes: 6 additions & 0 deletions
6
...Snapshots__/LoggingTests/testAutomaticFallbackToMainThreadRenderingEngine.Boat_Loader.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[warning] Encountered Core Animation compatibility issue while setting up animation: | ||
[Chest] The Core Animation rendering engine partially supports time remapping keyframes, but this is somewhat experimental and has some known issues. Since it doesn't work in all cases, we have to fall back to using the main thread engine when using `RenderingEngineOption.automatic`. | ||
This animation may have additional compatibility issues, but animation setup was cancelled early to avoid wasted work. | ||
|
||
Automatically falling back to Main Thread rendering engine. This fallback comes with some additional performance | ||
overhead, which can be reduced by manually specifying that this animation should always use the Main Thread engine. |
6 changes: 6 additions & 0 deletions
6
...shots__/LoggingTests/testCoreAnimationRenderingEngineUnsupportedAnimation.Boat_Loader.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[assertionFailure] Encountered Core Animation compatibility issues while setting up animation: | ||
[Chest] The Core Animation rendering engine partially supports time remapping keyframes, but this is somewhat experimental and has some known issues. Since it doesn't work in all cases, we have to fall back to using the main thread engine when using `RenderingEngineOption.automatic`. | ||
|
||
This animation cannot be rendered correctly by the Core Animation engine. | ||
To resolve this issue, you can use `RenderingEngineOption.automatic`, which automatically falls back | ||
to the Main Thread rendering engine when necessary, or just use `RenderingEngineOption.mainThread`. |
1 change: 1 addition & 0 deletions
1
Tests/__Snapshots__/LoggingTests/testExplicitMainThreadRenderingEngine.Boat_Loader.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Animation setup did not emit any logs |
1 change: 1 addition & 0 deletions
1
...shots__/LoggingTests/testUnsupportedAfterEffectsExpressionsWarning.LottieFiles-growth.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[info] `transform.rotation.z` animation for "men.man 1.hand 2.Transform" includes an After Effects expression (https://helpx.adobe.com/after-effects/using/expression-language.html), which is not supported by lottie-ios (expressions are only supported by lottie-web). This animation may not play correctly. |