Skip to content

Commit

Permalink
Fix issue where value providers could be ignored when falling back to…
Browse files Browse the repository at this point in the history
… main thread rendering engine (airbnb#2164)
  • Loading branch information
calda authored and Igor Moroz committed May 22, 2024
1 parent ccd3ffb commit b669c12
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 1 deletion.
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
}
}
.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.

0 comments on commit b669c12

Please sign in to comment.