-
-
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
Fix Swift performance issues. Remove renderScale and contentsScale #1328
Conversation
lottie-swift/src/Private/LayerContainers/CompLayers/TextCompositionLayer.swift
Outdated
Show resolved
Hide resolved
@buba447 Seems like @JoeSzymanski found the issue for the performance regression. We are unsure about the best way to tackle this. I could not distinguish regular Lottie animations on a pixel level when removing contentsScale (Which is not what I would have expected, so I am wondering whether I overlooked something 😅 ). Only TextLayers become blurry, which is why I removed screenScale everywhere except for TextLayers. Joes approach was to make renderScale publicly available. #1327 |
According to the docs, there is no need to change this value for layers backing views. https://developer.apple.com/documentation/quartzcore/calayer/1410746-contentsscale
|
This is working great for me. I had severe performance issues in loading and playback that went away completely after using this PR. Much thanks! |
Nice catch here! Just a few comments to clean this up so we can get it merged. The original purpose of the |
@buba447 Great suggestions. Looks much cleaner now 😊 |
👋 This commit introduces a visual regression and should be reverted.
@absolute-heike was on the right track initially. With retina assets on gradients we are definitely seeing scaling artifacts that makes smooth circles blurry. I think the linked PR that allows clients to opt-out of the render scale is a much better solution: #1327 so devs can get the precise performance metrics they prefer and understand the tradeoffs. The docs here are a little confusing, but it's differentiating between layer backed views and created sublayers. Only layer backed views are automatically set to the correct contentScale. Since lottie animations are all sublayers, then all layers are no longer scaled for retina devices. This means all bitmaps are now 4x or 9x smaller on retina screens, so of course there will be less CPU utilization. For performance, we've seen success by setting some layers to |
Any thoughts on @marksands comment? @buba447 |
Fix Swift performance issues. Remove renderScale and contentsScale
Fix Swift performance issues. Remove renderScale and contentsScale
Related to #1325 #895 #1060 #1314 (and possibly others)
lottie-swift sets
layer.contentsScale
on every sublayer. ObjC didn't do that and this seems to explain the performance regression from 2.x to 3.x. Removing that code, I haven't found any regressions whatsoever while at the same time fixing the performance issues.Profiling these changes gave the following insights: