iOS 核心动画:CATransaction / 插值变换矩阵的性能问题
我正在测试我的 iPhone 应用程序的性能:
// using CATransaction like this goes from 14fps to 19fps
[CATransaction begin];
[CATransaction setDisableActions: YES];
// NEG, as coord system is flipped/messed up
self.transform = CGAffineTransformMakeRotation(-thetaWheel);
[CATransaction commit];
问题:为什么禁用核心动画在新旧变换矩阵之间进行插值的默认行为会带来如此大的性能提升?
他们可能在做什么,计算成本如此之高?即使他们使用世界上最复杂的技术在两个矩阵之间进行插值,我也不敢相信这会达到 5fps?!
我无法想象这个过程除了 M_resultant = k*M_last + (1.-k)*M_target 之外还有什么
I am performance testing my iPhone app:
// using CATransaction like this goes from 14fps to 19fps
[CATransaction begin];
[CATransaction setDisableActions: YES];
// NEG, as coord system is flipped/messed up
self.transform = CGAffineTransformMakeRotation(-thetaWheel);
[CATransaction commit];
Question: why does disabling core animation's default behavior of interpolating between the old and the new transform matrix give such a performance boost?
What could they possibly be doing that could be so computationally expensive? Even if they are using the most elaborate technique in the world for interpolating between two matrices, I can't believe this would amount to 5fps?!
I can't imagine the process is anything other than M_resultant = k*M_last + (1.-k)*M_target
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在两个位置之间进行插值会创建 CAAnimations,该动画必须按帧应用并在渲染线程和主线程之间同步。
交易成本与您一次动画的层数有关;尝试分析您的应用程序以查看瓶颈是什么。
Interpolating between the two positions creates CAAnimations which must be applied per-frame and synchronized between the render thread and main thread.
The transaction cost would be relative to how many layers your'e animating at once; try profiling your app to see what the bottlenecks are.