即使使用CADisplayLink,卡在40 fps? [英] Getting stuck at 40 fps even with using CADisplayLink?

查看:204
本文介绍了即使使用CADisplayLink,卡在40 fps?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

起初我使用了NSTimer并遇到了帧速率被卡在每秒40帧的问题。我已经阅读了有关使用CADisplayLink解决问题的信息。它似乎工作了一段时间,但最近,应用程序从60开始,然后一段时间(约5 - 20秒)应用程序开始以40 - 41 fps运行并卡在那里。而且我正在剔除,以便在物体不在视野时吸取的次数减少,但它仍然停留在那里。一个似乎可以解决问题片刻(大约10秒钟)的一种不寻常的方法是从iphone底部断开电线然后再连接它。显然,这并不理想,但只是想知道为什么会发生这种情况,为什么它会在某种程度上解决它,好像它会重置某些值或某些东西。任何帮助将不胜感激,谢谢。

At first I used NSTimer and ran into the problem of the frame rate being stuck at 40 frames per second. I've read about using CADisplayLink to fix the problem. It seemed to work for a while, but recently, the app starts at 60, then after a little while (about 5 - 20 seconds in) the app starts to run at 40 - 41 fps and gets stuck there. And I'm culling so that there's less draws when objects are out of view, but yet it stays stuck there. A unusual way that does seem to remedy the problem for a moment (about 10 seconds) is to disconnect the wire from the bottom of the iphone and then connect it again. Obviously, this is not ideal, but just wondering why does this happen and why does it somewhat fix it, as if it resets certain values or something. ANY help will be greatly appreciated, thanks.

推荐答案

您是否检查过是否实际丢帧?您是否正在使用CPU / GPU,只能在一秒钟内绘制40帧,或者是软件中某处出现的问题?

Have you checked to see whether you're actually dropping frames? Are you using the CPU/GPU to the extent that you can only draw 40 frames in a second, or is the problem somewhere in the software?

请记住,如果 CADisplayLink 无法触发屏幕刷新(由于主线程忙于处理绘制前一帧),因此它可能会跳过它,因为它不够时间来完成。因此,如果你的某些帧的绘制时间超过0.01666 ...秒,你将错过画画帧的时间间隔,并且减速可能会比它更糟糕。

Remember that if a CADisplayLink is unable to fire for a screen refresh (due to the main thread being busy doing things like drawing the previous frame) then it may skip it, as it won't have enough time to complete. So if some of your frames take more than 0.01666... seconds to draw, you'll miss the interval to draw the frames right after, and the slowdown may appear worse than it is.

还要记住,移动设备并不总是能够快速绘制所有内容。 iPhone 4中的A4处理器非常好,但是仍然需要每秒60次填充960x640屏幕像素。如果您的帧速率是40fps而不是60fps,绝大多数用户都不会注意到 - 人眼通常不会注意到抖动或屏幕延迟,直到你的速度提高到20fps左右。

Also remember that a mobile device is not always capable of drawing everything quickly. The A4 processor in an iPhone 4 is very good, but it's still a tall order to fill 960x640 screen pixels 60 times a second. The vast majority of your users will not notice if your frame rate is 40fps instead of 60fps--the human eye doesn't generally notice judder or screen lag until you're around 20fps and lower.

这篇关于即使使用CADisplayLink,卡在40 fps?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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