diff --git a/Example/Example/AnimationPreviewView.swift b/Example/Example/AnimationPreviewView.swift index 0791ee6937..da91276e56 100644 --- a/Example/Example/AnimationPreviewView.swift +++ b/Example/Example/AnimationPreviewView.swift @@ -52,6 +52,7 @@ struct AnimationPreviewView: View { } .configuration(LottieConfiguration(renderingEngine: renderingEngine)) .imageProvider(.exampleAppSampleImages) + .logger(.printToConsole) .resizable() .reloadAnimationTrigger(currentURLIndex, showPlaceholder: false) .playbackMode(playbackMode) diff --git a/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift b/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift index 0449d574df..6f33082151 100644 --- a/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift +++ b/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift @@ -41,7 +41,8 @@ final class ShapeLayer: BaseCompositionLayer { if let repeater = shapeLayer.items.first(where: { $0 is Repeater }) as? Repeater { try setUpRepeater(repeater, context: context) } else { - try setupGroups(from: shapeLayer.items, parentGroup: nil, parentGroupPath: [], context: context) + let shapeItems = shapeLayer.items.map { ShapeItemLayer.Item(item: $0, groupPath: []) } + try setupGroups(from: shapeItems, parentGroup: nil, parentGroupPath: [], context: context) } } @@ -50,7 +51,8 @@ final class ShapeLayer: BaseCompositionLayer { let copyCount = Int(try repeater.copies.exactlyOneKeyframe(context: context, description: "repeater copies").value) for index in 0.. [GroupLayer] { - var (groupItems, otherItems) = items - .filter { !$0.hidden } - .grouped(by: { $0 is Group }) + var groupItems = items.compactMap { $0.item as? Group }.filter { !$0.hidden } + var otherItems = items.filter { !($0.item is Group) && !$0.item.hidden } // Handle the top-level `shapeLayer.items` array. This is typically just a single `Group`, // but in practice can be any combination of items. The implementation expects all path-drawing // shape items to be managed by a `GroupLayer`, so if there's a top-level path item we // have to create a placeholder group. - if parentGroup == nil, otherItems.contains(where: { $0.drawsCGPath }) { - groupItems = [Group(items: items, name: "")] + if parentGroup == nil, otherItems.contains(where: { $0.item.drawsCGPath }) { + groupItems = [Group(items: items.map { $0.item }, name: "")] otherItems = [] } // Any child items that wouldn't be included in a valid shape render group // need to be applied to child groups (otherwise they'd be silently ignored). let inheritedItemsForChildGroups = otherItems - .map { ShapeItemLayer.Item(item: $0, groupPath: parentGroupPath) } .shapeRenderGroups(groupHasChildGroupsToInheritUnusedItems: !groupItems.isEmpty) .unusedItems @@ -235,8 +235,6 @@ extension CALayer { let groupsInZAxisOrder = groupItems.reversed() return try groupsInZAxisOrder.compactMap { group in - guard let group = group as? Group else { return nil } - var pathForChildren = parentGroupPath if !group.name.isEmpty { pathForChildren.append(group.name) diff --git a/Sources/Public/Animation/LottieView.swift b/Sources/Public/Animation/LottieView.swift index 6917c00321..2cdd33d189 100644 --- a/Sources/Public/Animation/LottieView.swift +++ b/Sources/Public/Animation/LottieView.swift @@ -122,7 +122,8 @@ public struct LottieView: UIViewConfiguringSwiftUIView { imageProvider: imageProvider, textProvider: textProvider, fontProvider: fontProvider, - configuration: configuration) + configuration: configuration, + logger: logger) } .sizing(sizing) .configure { context in diff --git a/Tests/Samples/Issues/issue_2130.json b/Tests/Samples/Issues/issue_2130.json new file mode 100644 index 0000000000..921ed6fd1b --- /dev/null +++ b/Tests/Samples/Issues/issue_2130.json @@ -0,0 +1 @@ +{"v":"5.6.6","ip":0,"op":160,"fr":60,"w":70,"h":70,"assets":[],"layers":[{"ind":386,"nm":"surface1542","ao":0,"ip":0,"op":264,"st":0,"ty":4,"ks":{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[133.33,133.33]},"sk":{"k":0},"sa":{"k":0}},"shapes":[{"ty":"gr","hd":false,"nm":"surface1542","it":[{"ty":"gr","hd":false,"it":[{"ty":"sh","ks":{"k":{"i":[[0,0],[-1.24,0],[0,-1.24],[0,0],[0.92,-0.51],[0,0],[0.59,1.05],[-1.05,0.59],[0,0]],"o":[[0,-1.24],[1.24,0],[0,0],[0.32,0.96],[0,0],[-1.05,0.59],[-0.59,-1.04],[0,0],[0,0]],"v":[[24.75,12],[27,9.75],[29.25,12],[29.25,25.76],[28.25,28.32],[15.23,35.62],[12.27,34.78],[13.11,31.83],[24.75,25.3]],"c":true}}},{"ty":"sh","ks":{"k":{"i":[[0,0],[0,0.68],[0.69,0],[0,-0.69],[-0.68,0]],"o":[[0.69,0],[0,-0.69],[-0.68,0],[0,0.68],[0,0]],"v":[[26.84,27.82],[28.08,26.57],[26.84,25.33],[25.6,26.57],[26.84,27.82]],"c":true}}},{"ty":"fl","o":{"a":1,"k":[{"i":{"x":[0.67],"y":[1]},"o":{"x":[0.33],"y":[0]},"t":59,"s":[0]},{"t":109,"s":[100]}],"ix":5},"c":{"k":[0.29,0.75,0.69,1]}},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"gr","hd":false,"it":[{"ty":"sh","ks":{"k":{"i":[[0,0],[3.11,0],[0,3.11],[-3.11,0],[0,-3.11]],"o":[[0,3.11],[-3.11,0],[0,-3.11],[3.11,0],[0,0]],"v":[[32.25,26.62],[26.62,32.25],[21,26.62],[26.62,21],[32.25,26.62]],"c":false}}},{"ty":"fl","o":{"a":1,"k":[{"i":{"x":[0.67],"y":[1]},"o":{"x":[0.33],"y":[0]},"t":59,"s":[0]},{"t":109,"s":[30]}],"ix":5},"c":{"k":[0.29,0.75,0.69,1]}},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"gr","hd":false,"it":[{"ty":"sh","ks":{"k":{"i":[[0,0],[18.78,0],[0,18.78],[-18.78,0],[0,-18.78]],"o":[[0,18.78],[-18.78,0],[0,-18.78],[18.78,0],[0,0]],"v":[[69,35],[35,69],[1,35],[35,1],[69,35]],"c":false}}},{"ty":"st","lc":1,"lj":1,"ml":4,"o":{"k":100},"w":{"k":2},"c":{"k":[0.29,0.75,0.69,1]},"hd":false},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[75,75]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.27],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[0]},{"t":66,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"hd":false}]}],"meta":{"g":"LF SVG to Lottie"}} \ No newline at end of file diff --git a/Tests/__Snapshots__/AutomaticEngineTests/testAutomaticEngineDetection.Issues-issue_2130.txt b/Tests/__Snapshots__/AutomaticEngineTests/testAutomaticEngineDetection.Issues-issue_2130.txt new file mode 100644 index 0000000000..dde0c64d7a --- /dev/null +++ b/Tests/__Snapshots__/AutomaticEngineTests/testAutomaticEngineDetection.Issues-issue_2130.txt @@ -0,0 +1,4 @@ +Does not support Core Animation engine. Encountered compatibility issues: +[surface1542.Layer] The Core Animation rendering engine doesn't currently support applying trims to filled shapes (only stroked shapes). +[surface1542.Layer] The Core Animation rendering engine doesn't currently support applying trims to filled shapes (only stroked shapes). +[surface1542.Layer] The Core Animation rendering engine doesn't currently support applying trims to filled shapes (only stroked shapes). \ No newline at end of file diff --git a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-0.png b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-0.png new file mode 100644 index 0000000000..d1e889e182 Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-0.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-100.png b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-100.png new file mode 100644 index 0000000000..09fe9dcdaf Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-100.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-25.png b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-25.png new file mode 100644 index 0000000000..fa1e5c91a2 Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-25.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-50.png b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-50.png new file mode 100644 index 0000000000..853302accb Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-50.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-75.png b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-75.png new file mode 100644 index 0000000000..09fe9dcdaf Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.Issues-issue_2130-75.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-25.png b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-25.png index b686a8fa8c..2f5191435a 100644 Binary files a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-25.png and b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-25.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-50.png b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-50.png index 02fff3ad24..084e0f3055 100644 Binary files a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-50.png and b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-50.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-75.png b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-75.png index ff83337b07..82a8c4ca25 100644 Binary files a/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-75.png and b/Tests/__Snapshots__/SnapshotTests/testCoreAnimationRenderingEngine.TypeFace-T-75.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-0.png b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-0.png new file mode 100644 index 0000000000..d1e889e182 Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-0.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-100.png b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-100.png new file mode 100644 index 0000000000..e5b2e733ce Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-100.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-25.png b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-25.png new file mode 100644 index 0000000000..c39b506349 Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-25.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-50.png b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-50.png new file mode 100644 index 0000000000..036ad18d5e Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-50.png differ diff --git a/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-75.png b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-75.png new file mode 100644 index 0000000000..e5b2e733ce Binary files /dev/null and b/Tests/__Snapshots__/SnapshotTests/testMainThreadRenderingEngine.Issues-issue_2130-75.png differ