-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Core Animation rendering engine doesn't support text providers #1722
Comments
@calda , hey! |
Probably just needs to be implemented -- I don't have immediate plans to work on this but PRs are always welcome! |
Okay! I might try it, but maybe you could give some advice on where to start. |
Here's the text layer implementation used by the Core Animation rendering engine: https://github.com/airbnb/lottie-ios/blob/master/Sources/Private/CoreAnimation/Layers/TextLayer.swift#L51 What text providers does your animation use? The best way to set this up and start experimenting is to:
|
About the text providers:
Just that, if I understand you correctly |
Oh sorry, I was confused and thought you were talking about text animators. I forgot about custom text providers. For those, we'd need to add the We'd also need a test case that exercises this functionality, by hardcoding a custom text provider for a specific test case like we do here for testing image providers. |
Okay, I will try it out and hopefully open a PR with some ideas soon. |
@calda Actually sorry, could you please say a bit more. 🙌🏼 I understood that we need to do the following:
*Do I understand correctly that we should do it in the var hasCustomTextValue: Bool = false
func configureRenderLayer(with context: LayerContext) throws {
...
_ = context.textProvider.textLayers.map { [unowned self] layer in
guard layer.keypathLayer != nil else { return }
self.hasCustomTextValue = true
}
...
} **And the part about overriding the setupAnimations is not clear as well, to be honest. override func setupAnimations(context: LayerAnimationContext) throws {
try super.setupAnimations(context: context)
context.currentKeypath // <---- THIS VALUE?
} And which layer ps. Thanks a lot for supporting, really hard to grasp the idea by using this library on a high level before! 🙏🏼 |
yes, something like: override func setupAnimations(context: LayerAnimationContext) throws {
try super.setupAnimations(context: context)
if let customText = context.textProvider.text(for: context.currentKeypath) {
renderLayer.text = customText
} else {
// currently in `func configureRenderLayer`, but we have to move it to this method now
renderLayer.text = try textLayerModel.text.exactlyOneKeyframe(context: context, description: "text layer text").text
}
} |
Hm I think I understand the idea with |
I think you'll need to add the |
I am trying to use the Lottie animation with some text providers. I am trying to have TextAnimation.
However, the animations take too much memory (not necceseraliy the one in the example), and it would be great if it would be possible to use the core engine.
Do we know when it will be included? 🙏🏼
However, thank you for constantly improving Lottie; the project is incredible!
Which Version of Lottie are you using?
Lottie 3.4.2
Expected Behavior
I would expect to be able to use the text animations with the new engine because it would improve the performance of the app dramatically.
Actual Behavior
The app gets crashed with this message:
Thread 1: Fatal error: The Core Animation rendering engine currently doesn't support
textProviders")
Animation JSON
An example of a text animation:
{"v":"5.9.6","fr":25,"ip":0,"op":125,"w":600,"h":600,"nm":"Position","ddd":0,"assets":[],"fonts":{"list":[{"origin":0,"fPath":"","fClass":"","fFamily":"Blogger Sans","fWeight":"","fStyle":"Bold","fName":"BloggerSans-Bold","ascent":72.8127343747765}]},"layers":[{"ddd":0,"ind":1,"ty":5,"nm":"Animation text layer","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.13},"t":0,"s":[297.387,665.7,0],"to":[0,-60.95,0],"ti":[0,60.95,0]},{"i":{"x":0.999,"y":0.999},"o":{"x":0.167,"y":0.167},"t":23,"s":[297.387,300,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.999,"y":1},"o":{"x":0.993,"y":0},"t":100,"s":[297.387,300,0],"to":[0,-54.2,0],"ti":[0,54.2,0]},{"t":124,"s":[297.387,-25.2,0]}],"ix":2,"l":2},"a":{"a":0,"k":[106.325,-9.295,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"t":{"d":{"k":[{"s":{"sz":[601.23486328125,330.854888916016],"ps":[-192.50129699707,-43.9063301086426],"s":33.4000015258789,"f":"BloggerSans-Bold","t":"Animation text layer","ca":0,"j":2,"tr":0,"lh":40.0800018310547,"ls":0,"fc":[0.208,0.482,0.949]},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":0,"op":125,"st":0,"ct":1,"bm":0}],"markers":[]}
The text was updated successfully, but these errors were encountered: