0

This is something I've been struggling with for a while now, and I'm really hoping someone can shed some light on the issue. Basically, I have a scene with a bunch of colliding SKPhysicsBodies. If I put the camera in the middle of the action on the very first frame of animation, the entire simulation runs at about 17fps indefinitely. However, if on the very first frame of animation I start the camera off-screen such that nothing (or very little) is drawn that first frame, and then move the camera to the middle of the action on the 2nd frame, then the simulation runs at 60fps.

The simulation is exactly the same in both cases. Nothing is different other than what sprites are culled on the very first frame, yet that seems to make all the difference for the rest of the simulation's performance.

This has proven 100% reproducible in every case I come up with, so in order to make sure that my game runs at 60fps, I have to "prime" the camera by starting it way, way off-screen, render a frame, and then move the camera to where I really want it to be. If I don't do that, the game runs at a cripplingly low frame rate and will never speed up.

Neeku
  • 3,646
  • 8
  • 33
  • 43
BGreenstone
  • 260
  • 1
  • 11
  • Try running time profiler on the app? – duci9y Jul 10 '14 at 14:52
  • What device are you testing on? What iOS version? Have you tried rebooting the device, deleting the app, clean build? What about release configuration? What Xcode version? If it's Xcode 6 / iOS 8 beta keep in mind this is beta software and such odd behavior can happen. Also wondering how you move the camera (given there's no actual "camera" in Sprite Kit or OpenGL). – CodeSmile Jul 10 '14 at 15:00
  • I'm mainly on an iPad 3, but also on an iPhone 5. It does it the same on every device, and yes I've rebooted a zillion times. It has been doing this on all iOS 8 betas, but I have never used SpriteKit on iOS 7, so I don't know if this is new or not. I move the camera either by manual touch control, or by SKActions to animate it into the scene. Doesn't matter which way. I did do the time profiler, and the delay was inside of SpriteKit. – BGreenstone Jul 10 '14 at 16:45
  • I have seen similar things with SKShapeNodes where if they were rendered more than 2000pixel off the center of the viewport the framerate would drop to 16/17fps. It might be that you have debugphysics set to yes, and it is the debugdrawing of shapes which is causing it. Anyway, if you are using skshapenodes, try to use skspritenodes instead. – Theis Egeberg Jul 11 '14 at 17:44
  • I don't have the debugPhysics on - actually, if I do it doesn't even draw it correctly because I'm scaling my WorldNode for my scrolling game, and that breaks the debug overlays. – BGreenstone Jul 12 '14 at 01:25

0 Answers0