iOS核心动画:CATransaction/内插变换矩阵的性能问题 [英] iOS Core-Animation: Performance issues with CATransaction / Interpolating transform matrices

查看:262
本文介绍了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

解决方案

在两个位置之间进行插值会创建CAAnimations,必须逐帧应用该CAAnimation,并且必须在渲染线程和主线程之间同步.

交易费用与您一次动画的层数有关;尝试对您的应用程序进行性能分析,以了解瓶颈所在.

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

解决方案

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.

这篇关于iOS核心动画:CATransaction/内插变换矩阵的性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆