Sprite Kit game laggy in simulator with Xcode 7 / Swift 2 - sprite-kit

After upgrading to Xcode 7 with Swift 2, my Sprite Kit project is very laggy on the simulator.
It previously would get 60 fps, and now it maxes out at 15 fps. (If I remove all textures, it goes up to 60, but even adding a single screen-sized texture drops it all the way down to 15 again.)
I've tried running in release mode as well as debug, and it makes no difference.
It's still smooth on the device.
Has anybody else had this issue? Any fixes? It just makes it hard to test.

The simulator will almost always have lag due to the fact that your computer is emulating the device (so yes I have had your issue). It is not really a problem with your App (unless you changed something massive in your App during the upgrade). I cannot speak to why the frame rate dropped on the sim from the upgrade (probably something not optimized yet, plus more features in iOS 9 slowing down the sim), but as long as it is good on the device, you should be good.
If you elaborate on what your setup is (what device(s) you have, and computer hardware), and what you are releasing to, I can provide more accurate information.
Another thing that may help is restarting the computer, that always seems to help when Xcode gets funny.

Related

SpriteKit scene with low fps on start

My problem is that my GameScene starts with about double the nodes and draws count and 40 fps for several seconds. This problem appears only on my iPad (mini retina) while on my iPhone (5) the game runs smoothly from the start although the nodes are still a lot more than what it should be
This 40fps problem is an issue within the iOS frameworks. It's created by some kind of throttling (by iOS).
Perhaps this throttling was designed to give a more consistent experience for an app struggling to maintain 60fps. But nobody knows.
Apple has never commented on it.
It became prevalent throughout the rollout of iOS 9 in Scene Kit, Sprite Kit and Metal. But has been seen within OpenGL ES locked projects, too.
However it was noticed in previous versions of iOS, too. Particularly within apps/games using CADisplayLink.
//Don't worry about those asking for code, you're right in your assumption that something is wrong that's not pertinent to your code.
Here's a deeper examination of a similar issue (probably from the same route cause) within Scene Kit: Inconsistent SceneKit framerate
Also got a problem with low FPS at the start (when using spritekit and uikit together )
I used xib with SKView and for me the solution was to add a dependency to the scene in the 'attribute inspector'
like at the picture below:

OpenGL ES sprites no longer render after updating to iOS 7.1

I am using a simple 2D sprite class based on this tutorial to render PNG bitmaps to the screen:
http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1
Everything worked fine on both my iPhone 4S running iOS 6.1 and my iPhone 5S running iOS 7. Since I updated to iOS 7.1, and on my MacBook Air updated to Mavericks and XCode 5.1, sprites no longer appear on the screen (I just get an empty white screen, which is the color I cleared the background to). When I build the app using XCode 5.1 and run on my iPhone 4S again, it still works.
Does anyone know what could be causing this? Has anyone run into this issue? I am having trouble getting to the source of the problem due to my lack of understanding of OpenGL ES among other things. :) My sprite class is exactly the same as the one in the tutorial.
Let me know if more details/code snippets are required.
I'm not even going to look at the sample code since it doesn't sound like it's the same as your current code. (You said 'based on'.) But I'll tell you how to find your problem.
First, clear to something other than white (like red) as a test.
If the screen turns red you at least know that your view and context and open gl in general is working. That knocks out a lot of possible culprits.
Second.. use the debug tools and chances are it will take you right to your problem. You have to run on a tethered device though and not the sim. Run your app...
Click on FPS in the debug navigator. Then click analyze and be patient. It will take a one frame snapshot of whats happening in open gl. It has to do a bunch of stuff to make that happen and it takes about 30 seconds. But then you'll have an interactive thing that shows you the frame and will let you step through processes and see what code is making that happen, and the frame as it draws each element. It's super cool actually. And probably it will show you an error message (in red).
My guess is that it's no longer loading your sprite images. Something probably changed between 6 and 7 or the versions of Xcode or of OSX. In that case the screen is blank because they're not loaded and therefore not being drawn.
EDIT:
I think the analysis will help find your problem. But to offer more possibilities, in my experience when nothing is drawing it's often one of these things:
An overall OpenGL issue - set your clear color to red or blue to test.
Shader didn't compile - always output shader compile errors so you know.
Bad Shader math or logic - use gl_FragColor = vec4(0.0,0.0,1.0,1.0) or some contrasting color to test. Can you see your structures?
Program isn't getting an attribute. Did you remember glEnableVertexAttribArray
Program isn't getting a uniform. Use the Analyze feature above to check the uniform values to make sure they made it to the shader.
(i'll add more if I think of them)
When stuff does

Animations Lagging When Publishing from Flash CS6 To iPhone 4

I recently created an app in flash cs6 to be used on my iPhone 4.
The app doesnt need to work through the app store its just a tech demo but when i put the app on my device all the animations become really slow/choppy.
My iPhones up to date and im using air3.2 (i did try updating to air 3.7 but then my application just became a white screen)
I have also tried cacheing all the movie clips as bitmaps bit it doesnt seem to make a difference.
(the app works fine inside the flash simulator)
please help?!
There could be a few reasons why this is happening,as I am taking a punt here as you havent gave much information on what your doing.
but your frame rate may have effect.. how are you creating your tweens?timeline animation or tween scripts.I found tween scripting works better as its distance over time opposed to distance over frames.
Also depending on your animation, images sizes, event listeners etc..
You need to take inconsideration your device itself and the resources it has available, free memory or actual storage available.
The reason it will work freely on your PC would be due to the fact of less limitations, your pc has more to computes and resources to throw at your application .
Add this line to your code to check your memory:
import flash.filesystem.File;
this.addEventListener(Event.ENTER_FRAME,performMemTest);
function performMemTest(e:Event):void {
trace(System.totalMemory);
}
I have read anywhere around 14MB++you may experience problems.

Does CGContextRotateCTM rotate on different rotational speeds on simulator and device?

I have a project where it rotates 2 spindles 360 degrees both at different speeds over time. I have noticed that it runs well on simulator but when I test it on a device it is significantly slower. The timing taken to make the first 3 full rotations on the simulator and the device are:
On Simulator: 7.0, 7.2, 7.2
On Device: 19.3, 19.5, 19.7
Essentially the project works but I'd like to find out why there is such a big difference between device and simulator and I thought CGContextRotateCTM might be the source.
Sounds right.
Don't forget, when you run the simulator, you are actually compiling native code to run on your native x86 hardware. Assuming your Mac runs faster than the 800MHz ARM chip in the iPhone - no surprise it will run faster in the simulator.
If you need deterministic timing in your application, your going to need more work to achieve that. This is where people use things like the UIView animation timing, NSTimer calls, or cocos2d inter-frame timers to give deterministic time to their animation calls.
If you don't - when the next gen device comes out with a faster CPU - your app will again be messed up.
Remember when they used to have "Turbo" buttons on PCs to deal with this?! :-O

Accuracy of OpenGL ES Instrument

I'm developing a game for the iPhone. I've decided that 30FPS is plenty so I've written some code that only allows the App to present the render buffer every 1/30 of a second. When I tried to verify this with Instruments I got varying information.
On an iPod Touch (2009 edition, 32G) it reports 30 FPS for Core Animation Frames Per Second.
On an iPhone 3G I get wildly varying results. And not just less than 30 FPS. I see >30 FPS on a regular basis. It actually seems to hang closer to 36-39.
To investigate this anomaly I added my own FPS to the app and update it once per second. I stays right at 29 FPS on both devices.
So, does anyone have any suggestions as to what might be going on? I expect Instruments to be accurate so it really concerns me that it appears inaccurate. It makes me think I have a bug somewhere, but I sure can't find it.
Are you using CADisplayLink? This might give you a little bit more precision on your main loop.