I have an OpenGL ES 1.1 project on iPhone, based heavily on the empty OpenGL ES application given here:
我在iPhone上有一个OpenGL ES 1.1项目,主要基于这里提供的空OpenGL ES应用程序:
http://iphonedevelopment.blogspot.com/2009/06/empty-opengl-es-application-project.html
http://iphonedevelopment.blogspot.com/2009/06/empty-opengl-es-application-project.html
I'm testing on a 3G (not 3GS) device, 8GB.
我在3G(不是3GS)设备上测试,8GB。
The paint loop in my app which does openGL operations is doing quite a lot each time it renders the screen. However, in situations with it doing the same thing each paint cycle, I'm seeing variable frame rates. I have set the NSTimer which fires the paint code to fire 30 times a second -- i.e. every 0.0333 of a second. The main problem is that whereas my actual paint code often takes approximately that amount of time to execute one paint (in terms of wall time), it varies, and sometimes it takes far longer, for no apparent reason. Using careful logging to report maximum time intervals when they occur, I can see that sometimes my paint has taken as long as 0.23 sec to complete - that's like 4FPS, which compared to 30FPS is like skipping 5 frames of animation/ user interaction, which isn't very acceptable.
在我的应用程序中做openGL操作的绘制循环每次渲染屏幕都会做很多事情。然而,在这种情况下,每个油漆周期都是一样的,我看到了可变的帧速率。我已经设置了一个NSTimer,它可以每秒钟发射30次油漆代码——也就是每0.0333秒。主要的问题是,虽然我实际的油漆代码执行一种油漆通常需要大约相同的时间(以墙的时间为标准),但是它是不同的,有时候它需要更长的时间,没有明显的原因。使用仔细的日志记录来报告发生时的最大时间间隔,我可以看到,有时我的绘制耗时长达0.23秒——这就像4FPS,与30FPS相比,这就像是跳过5帧动画/用户交互,这是不能接受的。
At first I suspected my paint loop was snagging on some lock (there aren't many in there, because the GL render stuff in on the main thread (which is necessary AFAIK), as is incoming event handling) but some logging with finer granularity revealed that, in one paint code execution cycle, a large time elapsing over a bit of code that was doing basically hardly anything, and certainly not a GL operation.
起初我怀疑我的油漆循环是妨碍一些锁(不多,因为在主线程的GL渲染的东西(这是必要的AFAIK),是传入的事件处理)但是一些日志记录与显示的时间粒度,在一个油漆代码执行周期,大量时间在流逝的代码基本上在做几乎任何东西,当然不是一个GL操作。
So it seems a bit like my GL drawing thread (i.e. the main thread) just takes longer sometimes for no good reason. I have comms in my application and I disabled comms to see if that was the problem -- but I still see some "spikes" in execution time of my painting, when it's doing the same painting each time.
因此,这看起来有点像我的GL绘图线程(即主线程),只是花了更长的时间,有时没有什么好理由。我在我的应用程序中使用了comms,我禁用了comms,看看这是否是问题所在——但是我仍然可以看到我的画在执行时出现一些“尖峰”,当它每次都在做同样的画时。
It's seems like another thread is just being switched to, mid-paint code, for ages, before returning to my paint code, on occaison.
这似乎是另一个线程正在被切换到,中漆代码,在回到我的油漆代码之前,在occaison上。
Any ideas with how to analyse further what is going on? I know NSTimers aren't perfect and aren't at a guaranteed frequency, but the main issue here is that my actual paint cycle sometimes just takes forever, presumably because some other thread gets switched to....
对于如何进一步分析正在发生的事情有什么想法吗?我知道NSTimers并不完美,不保证频率,但这里的主要问题是我实际油漆周期有时只需要永远,大概是因为其他线程会转向....
1 个解决方案
#1
0
Keep in mind that your application can seem to "hang" for no reason that has nothing to do with your "main loop". That's because you are multitasking... and in paticular, something as simple as your phone checking email can cause this sort of problem. One big cause, on the iPhone anyway, is when you move through different cell sites (like if you are on a subway or in a car) you can sometimes get spikes as it does... whatever it does.
请记住,您的应用程序似乎可以“挂起”,而这与您的“主循环”没有任何关系。那是因为你同时处理多项任务……而且,就像你的手机检查邮件一样简单的事情也会导致这种问题。无论如何,在iPhone上的一个重要原因是,当你通过不同的手机站点(比如你在地铁或汽车上)时,你有时会得到一些峰值。不管它。
If you are on an iPhone, try airplane mode and see if the problems go away.
如果你在iPhone上,试试飞机模式,看看问题是否会消失。
-- David
——大卫
#1
0
Keep in mind that your application can seem to "hang" for no reason that has nothing to do with your "main loop". That's because you are multitasking... and in paticular, something as simple as your phone checking email can cause this sort of problem. One big cause, on the iPhone anyway, is when you move through different cell sites (like if you are on a subway or in a car) you can sometimes get spikes as it does... whatever it does.
请记住,您的应用程序似乎可以“挂起”,而这与您的“主循环”没有任何关系。那是因为你同时处理多项任务……而且,就像你的手机检查邮件一样简单的事情也会导致这种问题。无论如何,在iPhone上的一个重要原因是,当你通过不同的手机站点(比如你在地铁或汽车上)时,你有时会得到一些峰值。不管它。
If you are on an iPhone, try airplane mode and see if the problems go away.
如果你在iPhone上,试试飞机模式,看看问题是否会消失。
-- David
——大卫