Jam at 40 fps even when using CADisplayLink?

At first I used NSTimer and ran into a problem when the frame rate stuck at a speed of 40 frames per second. I read about using CADisplayLink to fix this problem. This seemed to work for a while, but recently the application starts at 60, and then after a while (after about 5-20 seconds) the application starts to work at a speed of 40 - 41 frames per second and gets stuck there. And I select so that there are fewer draws when objects were out of sight, but still remain there. An unusual way that seems to fix the problem for a moment (about 10 seconds) is to disconnect the wire from the bottom of the iphone and then reconnect it. Obviously, this is not ideal, but just wondering why this is happening and why it can be fixed a bit, as if it resets certain values ​​or something like that. ANY help would be greatly appreciated, thanks.

+4
source share
3 answers

Have you checked if you really drop frames? Are you using a processor / GPU to the extent that you can only display 40 frames per second, or is this a problem somewhere in the software?

Remember that if CADisplayLink cannot start to refresh the screen (due to the main thread busy doing things like drawing the previous frame), it may skip it because it will not have enough time to complete, therefore, if some of your frames take more than 0.01666 ... seconds to draw, you skip the interval for drawing frames right after that, and the slowdown may seem worse than it is.

Also remember that a mobile device is not always able to quickly draw everything. The A4 processor in the iPhone 4 is very good, but it still has a high fill order of 960x640 pixels 60 times per second. The vast majority of your users will not notice if your frame rate is 40 frames per second instead of 60 frames per second - the human eye usually does not notice the jitter or delay of the screen until you reach 20 frames per second or lower.

+3
source

I have the same problem in 3G. I simplified my application only to the FPS counter drawn above the empty (pink) backbuffer, and it was still 40 fps.

After some searches, I found a very similar problem being discussed in the cocos2d-iphone.org forum.

The solution was to disable the autorotation of the view controller. So I made my mustAutorotateToInterfaceOrientation to always return NO, and it worked (!!!). I had a stable 60 FPS. Then I returned my simple game graphics and it was stable at 60 FPS. But my game, which is expected to work in landscape mode, currently works in portrait mode by default.

I have no desire to write my own autorotation code, so I return to 40 frames per second. Does anyone know how to avoid this personnel reduction in autorotation?

+3
source

Same problem. I have a very simple kind of openGL (rotating cube), it starts at 60 frames per second, as soon as I start a difficult task to slow it down a bit, it never gets up to 60 frames per second, and its stick at 40 frames per second. I use CADisplayLink, and it just works in a test application, taking almost nothing to experiment with this problem: /

If anyone has a solution, I would be very grateful.

0
source

Source: https://habr.com/ru/post/1333948/


All Articles