Skip to main content
March 11, 2013
Answered

How to reduce suttering in Air for iOS GPU mode?

  • March 11, 2013
  • 4 replies
  • 1178 views

My game currently runs at 60FPS on iPad 2 and has no problem regarding rendering speed but I'm rather annoyed by constant stuttering which causes the game to stop for 0.1-0.5 sec  once in a while. The stuttering behavior is similar to when garbage collector is ran and I supposed it is casued by GPU memory swapping as my game uses lots of bitmapdata.

Problem is that my game transits one scene to another scene seamlessly without stopping animations in the game screen by letting old game scene sliding out of the screen and new scene sliding in. So there's no time to preload/precache graphics assets used in the new scene. After transitting different scenes a few times, the game starts stuttering when trying to show new images.

My game works fine without stuttering on old PCs but on iPad2 it is quite obvious. Could anyone tell me some tips to reduce stuttering when using Air for iOS? In the game, all vector graphics are pre-drawn to bitmapdata(so no vector graphics are shown) and the size of graphic assets each scene has is about 2048*1024 pixels. There are about 10 scenes. On top of that, there are common interface graphic assets which are used in all scenes and the size is about 30x 400*400 pixels.

I know the game uses quite a lot of graphic resources. Making the game preload the assets before transitting to a new scene will eliminate stutter but I'd still like to see if I can keep the seamless scene transition on iOS.

I'm currently using Air3.5 + Flash CS6.

* I mean preloading/precaching by actually displaying( addChild and visible=true)  them on stage and make time for GPU to cache. All the actual graphic data are already loaded.

This topic has been closed for replies.
Correct answer gtr

Have you tried playing with the StageQuality class? Setting to "low" solved my bumpy screen rotation/orientation problem...

4 replies

gtrCorrect answer
Inspiring
March 12, 2013

Have you tried playing with the StageQuality class? Setting to "low" solved my bumpy screen rotation/orientation problem...

March 17, 2013

I hadn't tried that since the game was running at 60 FPS and never felt it was neccesarry to reduce graphics quality but I just tried setting StageQuality to low and it seems like the stuttering has been reduced greatly. Thanks!

Colin Holgate
Inspiring
March 11, 2013

Some things that might help:

I've heard that textures are uploaded as square textures on iOS. I'm not certain that really happens, but if it does then having two 1024x1024 textures would be better than one 2048x1024, because that would end up actually taking 2048x2048.

Bitmaps are sent to the GPU when they first hit the stage, and it takes a significant amount of time for them to get there. If you are timeline animating a transition to the next scene, stagger the graphics that are going to be appearing next. That is, before you start to move on to the next area have the biggest bitmap of the next are already touching the edge of the stage. It can be invisible, or underneath another graphic, it will still get uploaded. But if you tween in all of the graphics exactly when they are needed, they will take a while to upload.

Dispose of the bitmaps that are no longer in the scene. I think your stuttering is because you're going into a new area that has a lot of new graphics, and the GPU still has the bitmaps from the current scene and the one before that, and so has to spend time freeing up the memory before taking the new bitmaps. If you had already disposed of them the GPU might not need to clear memory for you.

There is System.gc(). That will force the system to garbage collect, which you could do at moments that there isn't anything animating.

March 11, 2013

I've heard that textures are uploaded as square textures on iOS. I'm not certain that really happens, but if it does then having two 1024x1024 textures would be better than one 2048x1024, because that would end up actually taking 2048x2048.

I wasn't completely aware of that. Keeping image size within power of 2 makes sense. In a brief test I've done using bunch of 255x255 bitmap and 260x260x bitmap in my game I coudln't really notice difference but will be doing more testing later. I'm also thinking of trying Starling2D again as they might give me better control over GPU memory managing. Thanks for the tips.