I am developing an iP * game and I am using UIKit and OpenGL ES 2.0. UIKit elements are displayed on top of the OpenGL view and occupy a significant (arbitrary) amount of screen space. I must admit that Apple did an excellent job, and the frame rate in the game is always 60 FPS.
To come to this conclusion, I did a lot of tests regarding performance:
- I added a lot of static (non-moving) UIViews over the OpenGL view - OK!
- I animated the same UIViews using custom code (I changed the center property in the drawFrame method of my game) - OK !.
- I have added many OpenGL ES elements under UIViews - OK!
- I added a lot of moving elements of OpenGL ES under UIViews - OK!
So now I want to use the Core Animation Framework to animate UIKit elements. I use
[UIView animateWithDuration:delay:options:animations:completion:]
to complete the animation (I am targeting iOS 4 or later).
The problem is that the frame rate has this <strong> strange behavior: sometimes I get 60 frames per second with many many animated UIKit elements (30 elements are ok for me) and in some cases the frame rate is obviously lower than 60 frames per second even with a single animated UIKit element, but I can't measure it with the tools! Let me explain in more detail: when I open the Tools and control the main animation and / or the OpenGL driver, I always get 60 frames per second. But obviously this is not the case, I can see that OpenGL animations can move much slower than the corresponding UIKit animations from above. If I remove the UIKit elements from the view, the frame rate will return to normal. A similar situation with the one I describe here occurs in any OpenGL ES game, when the user changes the volume of the device during the game. When the transparent view showing the current volume starts to disappear, and until it completely disappears, the frame rate drops sharply, but in the tools (I also did this test) it stuck at 60 frames per second!
So to summarize: sometimes I get real 60 frames per second with block animations without ups and downs to run, and sometimes I get fake 60 frames per second without ups and downs.
Do you have any solution? All tests were conducted on the iPad 2 and iPhone 3GS with iOS 5.1.
iphone uikit animation opengl-es quartz-graphics
Summon
source share