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 issue where value providers could be ignored when falling back to main thread rendering engine #2164

Merged
merged 4 commits into from
Sep 8, 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
7 changes: 7 additions & 0 deletions Example/Example/AnimationPreviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ struct AnimationPreviewView: View {
animationPlaying = false
}
}
.configure { animationView in
DispatchQueue.main.async {
currentRenderingEngine = animationView.currentRenderingEngine
}
Comment on lines +64 to +66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a comment about what this is for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which part? tracking the current rendering engine in an @State property?

}
.getRealtimeAnimationProgress(animationPlaying ? $sliderValue : nil)

Spacer()
Expand Down Expand Up @@ -94,6 +99,7 @@ struct AnimationPreviewView: View {
updateIndex()
}
.toolbar {
Text((currentRenderingEngine ?? .coreAnimation).description)
optionsMenu
}
}
Expand All @@ -111,6 +117,7 @@ struct AnimationPreviewView: View {
@State private var loopMode: LottieLoopMode = .loop
@State private var playFromProgress: AnimationProgressTime = 0
@State private var playToProgress: AnimationProgressTime = 1
@State private var currentRenderingEngine: RenderingEngine?

private var playbackMode: LottiePlaybackMode {
if animationPlaying {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Public/Animation/LottieAnimationLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,10 @@ public class LottieAnimationLayer: CALayer {

animationLayer.lottieAnimationLayer = self

for (keypath, valueProvider) in valueProviders {
animationLayer.setValueProvider(valueProvider, keypath: keypath)
}

animationLayerDidLoad?(self, renderingEngine)

animationLayer.renderScale = screenScale
Expand Down
10 changes: 9 additions & 1 deletion Tests/SnapshotConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ extension SnapshotConfiguration {
// Test cases for `RenderingEngineOption.automatic`
"9squares_AlBoardman": .useAutomaticRenderingEngine, // Supports the Core Animation engine
"LottieFiles/shop": .useAutomaticRenderingEngine, // Throws a compatibility error in `init`
"TypeFace/G": .useAutomaticRenderingEngine, // Throws a compatibility error in `display()`
"TypeFace/G": { // Throws a compatibility error in `display()`
var configuration = SnapshotConfiguration.useAutomaticRenderingEngine
configuration.customValueProviders = [
"G 2.Ellipse 1.Stroke 1.Color": ColorValueProvider(.red),
"G Outlines 3.G.Fill 1.Color": ColorValueProvider(.red),
"Shape Layer 18.Shape 1.Stroke 2.Color": ColorValueProvider(.red),
]
return configuration
}(),
]
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading