I've noticed significant fps drops (framerate drops between 5-10fps), when unpausing the view in SpriteKit. I tried this with empty project (Spritekit game template). Here is the code:
if(!self.view.paused){
self.view.paused = YES;
NSLog(@"Paused");
}else{
NSLog(@"Unpaused");
self.view.paused = NO;
}
If I pause the scene, everything works as expected and frames are steady at 60fps. I am testing this on device.
if(!self.paused){
self.paused = YES;
NSLog(@"Paused");
}else{
NSLog(@"Unpaused");
self.paused = NO;
}
This can make a problem with gameplay when unpausing because some frames will be skipped... Any thoughts what's going on ?
I'm assuming it is dropping temporarily after the un-pause? Or is it always low fps after un-pausing. Is this only happening on iOS 8 or iOS 9. Can you try iOS 9? I'm convinced this might be occurring because after un-pausing it takes Sprite-Kit a little to "warm-up" the rendering cycle. You can try profiling in instruments and see what is happening.
As for a solution, you can try lowering the
speed
of yourSKPhysicsWorld
temporarily after un-pausing so the physics don't jump because Sprite Kit has a variable time step and unfortunately that can't be changed. If it's the actions that are jumping, you can try lowering thespeed
of yourSKScene
. Ideally you should probably do both.Additionally, if you only need to worry about actions, you can try only pausing your scene instead of your SKView (but keep in mind your update method will run). Or try temporarily pausing your scene then un-pausing it after un-pausing the SKView.
Other than this, there is really not much else you can do to fix this other than try to prepare for the dropped frames. Definitely report it to Apple if you haven't already.
Below is the class reference for all of these properties.
SKView-paused
SKScene - speed
SKScene - paused
SKPhysicsWorld - speed