My game app is running slow on my iOS device - ios

I've been encountering some problems when testing my app from XCode to my iOS 6.1.6 iPod touch 32GB. For my game, images frequently fall and I am not sure if that is the problem. Someone told me that my app could be running slow because I have too much memory on my iPod, but I already cleared most of my memory.
My question is, how can I make my app run fast on my device?
It runs really smooth on my iOS Simulator but it's terrible after 5 seconds when tested on my device.
The code that makes my images fall is like this
imageView1.center = CGPointMake(imageView1.center.x+pos.x,imageView1.center.y+pos.y);
imageView2.center = CGPointMake(imageView2.center.x+pos.x,imageView2.center.y+pos.y);
imageView3.center = CGPointMake(imageView3.center.x+pos.x,imageView3.center.y+pos.y);
imageView4.center = CGPointMake(imageView4.center.x+pos.x,imageView4.center.y+pos.y);
pos = CGPointMake(0.0, 3.0);
I also have a timer set at 0.03.
Also, when every image falls, when it hits the bottom, a new image is made out of random. It's a loop.

Any UIKit operations frequently occur take a load on your iPods processor. Your mac CPU is so much faster and you've got a ton of more ram so that's why it works on the simulator. You could try reducing the frame rate (the timer interval) and see if that solves the problem. I'd suggest you stay away from UIKit for making games and instead use the new iOS 7 framework, SpriteKit. (A google search will find the documentation) Frameworks like SpriteKit or Cocos2d are slightly more difficult to learn, but they have engines optimized for running games and using your iPods gpu. How complex is your game? If it's more than just one screen with moving objects I'd consider rewriting the entire thing in SpriteKit. Sorry to let you down on your first game but UIKit is nearly never the way to go when making games. Good luck!

Related

Preloading assets in AR with SceneKit

In our AR app and appclip made with SceneKit, we experience very significant drops in framerate when we make our 3D content appear at different steps of the experience. We have conducted our tests on an iPhone X (iOS 15.2.1), on an iPhone 12 Pro (iOS 14), and on an iPad Pro 2020 (iPad OS 14.8.1).
For now, all of our 3D objects are in our Main Scene. Those which are supposed to appear at some point in the experience have their opacity set to 0.01 at the beginning and then fade in with a SCNAction (the reason why we tried setting their opacity to 0.01 at the start was to make sure that these objects are rendered from the start of the experience).
However, if the objects all have their opacity set to 1 from the start of the experience, we do not experience any fps drop.
It is worth noting that the fps drops only happen the first time the app is opened. If I close it and re-open it, then it unfolds without any freeze.
What would be the best way to load (or pre-load) these 3D elements to avoid these freezes?
I have been told the prepareObject:shouldAbortBlock: and the prepareObjects:withCompletionHandler methods could solve our problem.
In our case the SceneView is an ARCNView, so we can't seem to access the SCNSceneRenderer methods. We have only managed to implement the "Prepare" method to preload our assets:
https://developer.apple.com/documentation/scenekit/scnscenerenderer/1523375-prepare
It seems to be doing something because we get a significantly longer freeze at the start of the experience, however, we still experience the same fps drops during the experience when our objects appear for the first time.
Is there any documentation on how to use the prepareObject:shouldAbortBlock: and the prepareObjects:withCompletionHandler methods in an ARCNView?

iOS games with random frame drops (including my game)

I'm almost finishing my iOS game written in Swift + SpriteKit.
It's a quite simple game, 30-32 nodes at max. Only 1 thing has physics. The rest is a few animated clouds (around 6). The CPU usage is around 2-3% and max RAM usage of 75-80MB.
Including that I also get frame drops when changing from one scene to another. Why that could be?
(I'm pre-loading all the textures and sounds during game init, and not on the scenes)
When I use the simulator for 5S up to 6S Plus, I don't see any frame drop in there. So that's weird. Looks like it's not my game but my iPhone 6S?
Now, I do also have other games installed on the same device from different developers, and I frequently get random frame drops too. Lags for 2-3 seconds and then comes back to 60fps.
Does anyone know if this is something that's happening after an X iOS update ? or I was even thinking this my be some kind of background service running that's killing my phone. Call it facebook, whatsapp, messenger, etc.
Is there any way I could possibly check on what's going on?
Was this caused by the way that newer versions of SpriteKit are defaulting to Metal render mode as compared to OpenGL mode? For example, do your problems go away when PrefersOpenGL=YES is added to Info.plist? I covered a bit of this performance issue in my blog post about a SpriteKit repeat shader. Note that you should only be testing on an actual iOS device, not the simulator.

performance test for my game on various devices

How does someone check if an Apple device is suitable for playing a game a developed. I realised that in some cases, the devices that are 3 years old have too humble performance and my games have a lag because of that. Is there a test I can run to determine if my app can be played on for example iPad3 or iphone 5.
The only way to tell is to run it on that device. Apple has made a few of these options better by allowing you to test things with Xcode server, unfortunately most of the time it has to be done manually.
It's also worth noting that you could optimize for older devices by making changes to the game such as lowering textures, particle effects, shaders and more.

Game has random timings for hard lags

So we've built a game where the player is jumping (on-tap) and needs to go thru moving obstacles (from the right to the left and vice versa) without hitting them.
We had everything clear and no lags and lately we've started to see some random "lags attacks", so you can jump like 500 times without any lags, while sometimes you can start the game and experience lags straight away.
I'm assuming that this has nothing to do with how we draw our obstacles nor with how we handle the graphics overall but with some background process going on.
Language and Engine: Objective-C, Cocos2d with Chipmunk.
Currently running the game thru: TestFlight.
Tested devices: 3 different iPhone's 5
EDIT:
So we've tried disabling all the external libraries and SDK's, Lags are still there.

performance issues with air app on iphone 4

Currently I am working on an Air app for iOS and Android. Air 3.5 is targeted.
Performance on iPhone 4 / 4s has been acceptable overall, after a lot of optimising: gpu rendering, StageQuality.LOW, avoiding vectors as much as possible etc. I really put a lot of effort in boosting performance.
Still, every once in a while, the app becomes very slow. There is no precise point in time or action or combination of actions after which this occurs. Sometimes, it doesn't occur for days. But when it occurs, only killing the app and launching it again helps, because the app stays slow after that. So I am not talking about minor hiccups that
The problem occurs only on (some) iPhones 4 and 4s. Not on iPad 3,4, iPhone 5, any Android device...
Has anyone had similar experiences and pointers as to where a solution might be found?
What happens when gpu memory fills up? Or device memory? Could this be involved?
Please don't expect Adobe Air to have performance as Native Apps. I am developing App with Adobe Air as well.
By the sound of your development experience. I think it's to do with memory issue, because the performance is not too bad at the begging stage, but it gets bad overtime (so u have to kill the app). I suggest you looking into memory leaking issue.
Hopefully my experience can help you.
I had a similar problem where sometime during gameplay the framerate would drop from 30fps to an unrecoverable 12fps. At first I thought I was running out of GPU memory and it was falling back on rendering with CPU.
Using Adobe Scout I found that when this occurred, the rendering time was ridiculousness high.
Updating to Air 3.8, I fixed the problem by limiting the amount of bitmaps that were being rendered and in memory at once. I would only create new instances of backgrounds for appropriate levels, and then flagging them for garbage collection when the level ended, waiting a few seconds and then moving to the next level.
What might solve your problem is if you reduce the amount of textures you have in memory at one time, only showing the ones you need to. If you want to swap out active textures for new ones, set all the objects with that texture data to null:
testMovieClip = null;
and remove all listeners from it so that garbage collection will pick it up.
Next, you can force garbage collection with AIR:
System.gc();
Instantiate the new texture you want to render a few frames after calling gc. Monitor resources with Scout and the iOS companion app to confirm that it's working.
You could also try to detect when the framerate drops, and set some objects to null then force garbage collection. In my case, if I moved my game to an empty frame for a few seconds with garbage collection, the framerate would recover and the game would resume rendering with GPU.
Hope this helps!

Resources