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

Using GradientValueProvider triggers an assertion when Rendering Engine is set to Automatic #1854

Closed
opera-ddrechny opened this issue Dec 14, 2022 · 1 comment · Fixed by #2182

Comments

@opera-ddrechny
Copy link

Lottie 4.0.1

I have an animation that renders as expected in Lottie 4.0.1 with renderingEngine set to .automatic, but triggers an assertion as soon as I call setValueProvider with an instance of GradientValueProvider:

Lottie/ValueProviderStore.swift:22: Assertion failed: The Core Animation rendering engine doesn't support Value Providers that vend a closure, because that would require calling the closure on the main thread once per frame.

I can work around this by setting renderingEngine set to .mainThread, but as I understand .automatic option should be backward-compatible with 3.x. Of course ideally I'd like to use the Core Animation engine.

The animation file:

{"v":"5.7.4","fr":60,"ip":0,"op":68,"w":450,"h":450,"nm":"GX_fab_rings","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":".accent","cl":"accent","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":16,"s":[100]},{"i":{"x":[0.724],"y":[1]},"o":{"x":[0.305],"y":[0]},"t":32,"s":[80]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.42],"y":[0]},"t":52,"s":[80]},{"t":66,"s":[0]}],"ix":11},"r":{"a":0,"k":-45,"ix":10},"p":{"a":0,"k":[225,225,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.537,0.537,0.667],"y":[1.001,1.001,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":0,"s":[13.667,13.667,100]},{"i":{"x":[0.538,0.538,0.667],"y":[0.938,0.938,1]},"o":{"x":[0.586,0.586,0.333],"y":[0.015,0.015,0]},"t":16,"s":[90.667,90.667,100]},{"i":{"x":[0.472,0.472,0.667],"y":[1.057,1.057,1]},"o":{"x":[0.264,0.264,0.333],"y":[-0.013,-0.013,0]},"t":32,"s":[67.712,67.712,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":50,"s":[74.667,74.667,100]},{"i":{"x":[0.284,0.284,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":52,"s":[74.667,74.667,100]},{"t":66,"s":[5.667,5.667,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[450,450],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":1,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"bm":0,"g":{"p":3,"k":{"a":0,"k":[0,0.98,0.118,0.306,0.5,0.98,0.118,0.306,1,0.98,0.118,0.306,0,1,0.5,0.75,1,0.5],"ix":9}},"s":{"a":0,"k":[0,-180],"ix":5},"e":{"a":0,"k":[0,212],"ix":6},"t":1,"nm":"Gradient Fill 1","mn":"ADBE Vector Graphic - G-Fill","hd":false}],"ip":0,"op":68,"st":0,"bm":0}],"markers":[]}

The call:

let animation = LottieAnimationView(name: "GX_fab_rings")
animation.setValueProvider(GradientValueProvider([LottieColor(r: 0, g: 0, b: 0, a: 0),
                                                  LottieColor(r: 1, g: 1, b: 1, a: 0.5),
                                                  LottieColor(r: 1, g: 1, b: 1, a: 1)]),
                           keypath: AnimationKeypath(keypath: "**.Colors"))
@calda
Copy link
Member

calda commented Dec 16, 2022

Thanks for the report. This is currently unimplemented for the Core Animation rendering engine, but should be feasible to support. PRs are welcome if anyone in the community is interested in helping out!

In the meantime, continuing to use the main thread rendering engine for this use case is the best workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants