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.
Related
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.
I just want to say thanks in advance for anyone you can provide some help on this we're completely stuck at the moment.
Project Scenario : -> 2D side scrolling game with simple 2d sprites -> Camera is orthographic and stays in its place (camera doesn't move) -> My Character (A camel) is also static and does not move. -> The sprites (Platforms) move from right to left (movement done by script) -> Project Video is uploaded here (running on iphone5). It clearly shows the small hiccups and jerks.
Issue : The game works very smoothly on Android devices and Unity Editor (no spikes on the Unity profiler as well) But, when i run it on iOS devices (iphone5, iphon5s) the motion of my sprites is jerky. Like it will move smoothly for like 1 second and then a small hiccup/jerk of a split second occurs. This results in lag and lagging motion of the game which is very annoying as i am unable to get the right quality for iOS.
Things i have tried : -> I have studied many possible solutions on various threads and forums but none issue seems to be working for me :-( -> I have tried different scripting techniques like use Lerp function for movement, tried putting the code in LateUpdate and also FixedUpdate. -> I also turned off vSync in project Quality settings but no luck :-( -> I also tried the movement without the script by making an animation of the sprites to move from right to left. -> I tried making the project from the latest Unity 5.1 as well but still the same lag :-( -> I tried reducing the sprite sizes to very low (low quality pixels) but still issue prevailed. -> I also tried to change the camera to perspective view to see if it reduces the jerk or not
I am sure lots of other people around must have faced this issue while making a 2D game of such sort. I hope someone must have overcome the issue and can please help me with this. This has been an issue with me for long now ...
I would really appreciate any help ... any new technique in unity or any better optimised logic of making such a 2D game in Unity. Thanks.
Looking forward to everyones input.
YOUTUBE LINK TO VIDEO FOR REFERENCE - https://www.youtube.com/watch?v=cnST1QzoDw4
I am creating this sort of first person shooter game for the iPhone 6 Plus, but when I introduce any lights to the scene, the frame rate goes from an already barely acceptable 12fps to an absolutely unplayable 2fps. Also, introducing a particle system with more than ten particles in it takes the frame rate to 9fps. I have already made it so that it adds all the walls and doors to a map node, and then flattens it using flattenedClone and adds that. I am unsure what else I can do without switching to Metal. But I am also wondering about this because if SceneKit were so slow, why would it even exist?
Problem solved: get a developer licence!
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!
I am building a cocos2d continuous running ios game, where a character is animated to run through a scene. The background, the grounds under the character's feet and a fence behind the running character move in the opposite direction to simulate forward motion. The character itself is animated to run in place. Occasionally additional sprites move by in the scene.
All my movement (except the in place animation of the character) happens in the update method.
I notice that all the moving parts stutter when additional sprites are moving past the scene. When there are no additional sprites, the stutter goes away.
I also notice that the stutter is almost imperceptible in the ipad 3 (ios 6.0.1), whereas it is most noticeable in the iphone 3gs (ios 6.0.1) and ipad 1 (ios 5.1.1), and moderately noticeable on the iphone 4 (ios 6.0.1).
I have no idea where to begin to address this - I tried removing the actual rendering of the additional sprites, and I also tried removing the fence behind the character - but neither change had any impact on the stutter.
Any suggestions?
Update: fixed it by running time profiler as #Fogmeister suggested below. Turns out I was doing disk i/o on every update to look up some state variables. I optimized that away and the stutter is gone on all devices. Thanks!
You need to identify what is taking up the time in the code and causing the stutter.
It seems like it is just an optimisation issue as you can see more stutter on older, slower devices and less on new more powerful devices.
Analyse the app using the Time Profiler instrument. This will tell you where the time is being spent and point you almost instantly to the function (if not the line) that is taking the time.
Once you've found that you can start optimising.
What is your code for the movement of the sprites? If you are updating the positions manually in the -(void) update:(ccTime) delta {} method make sure you are multiplying each movement by delta to account for any minute framerate fluctuations.