1

I'm trying to reduce the framerate to a maximum of 30 FPS. The official documentation says to use:

skView.frameInterval = 2;

I read through all the available documentations as well as every similar question asked here on stackoverflow or in other pages/blogs/etc. I tried it in so many ways but where ever I tried to set the property it did not affect the FPS.

I am not using any other timing mechanisms than those from SpriteKit. I am setting it up accordingly to the documentation and to the answers here on Stackoverflow.

I even started the basic SpriteKit template provided with Xcode and tried to set the frame rate property but even that did not work out.

Does anyone experience any similarities? Is there an alternative way to reduce max fps? What else can I try to reduce FPS?

BTW.: I am working on OS X and have a first-gen Retina Macbook Pro - Maybe it's a hardware issue?

EDIT:

I am not overriding the -(void)update: method - only -(void)didSimulatePhysics

This is what I do in a NSViewController Subclass which I set in Interface Builder. self.spriteKitView is an outlet to the NSView of my NSViewController-Subclass

-(void)setupSpriteKitView {

    self.spriteKitView.frameInterval = 2;
    self.spriteKitView.ignoresSiblingOrder = YES;
    self.spriteKitView.showsFPS = YES;
    self.spriteKitView.showsDrawCount = YES;
    self.spriteKitView.showsNodeCount = YES;
}

-(void)viewDidLoad {

    [super viewDidLoad];
    [self setupSpriteKitView];
    [self loadStartupScene];
}

I even tried to put this into my SKScene-Subclass, attach it as user-property inside Interface Builder to the SKView.

How I now it's not working? Both in my game and the Xcode template the debug output says 60 FPS. And even when reducing skView.frameInterval = 4 the animations stay smooth.

Simon Kemper
  • 635
  • 1
  • 7
  • 16
  • 1
    How do you know it's not working? Post the code snippet for your SKView. – sangony Jun 25 '15 at 14:24
  • @sangony Debug output says 60 fps all the time. Updated my question with snippets. – Simon Kemper Jun 25 '15 at 14:32
  • 1
    If that code is within an `SKView` subclass, then what is `self.spriteKitView`? – Droppy Jun 25 '15 at 14:32
  • No no. It's the code inside my NSViewController Subclass and self.spriteKitView is an outlet to the view of the ViewController - I'll add this info to the question! Sorry for that mistake! – Simon Kemper Jun 25 '15 at 14:35
  • @SimonKemper Try all this on empty project to see if it works (to try the isolate problem). – Whirlwind Jun 25 '15 at 14:36
  • @Whirlwind yes I thought about that too so I tried it with the basic Xcode template but behaviour is exactly the same! – Simon Kemper Jun 25 '15 at 14:38
  • @Droppy - Good point. Didn't see that in the comments. – sangony Jun 25 '15 at 15:31
  • @Droppy see the edited question above for details on what is `self.spriteKitView` – Simon Kemper Jun 25 '15 at 16:13
  • What version of OS X are you running? – Ben Kane Jun 25 '15 at 16:31
  • @BenKane latest. 10.10.3 – Simon Kemper Jun 25 '15 at 17:30
  • 1
    Sprite Kit FPS is a MESS on OS X. The FPS in full screen often drops, some devices like the Mac book air have a serious bug. Sometimes the FPS gets capped depending on the window size. All of my tickets that I submitted regarding FPS say they were fixed in Xcode 7/el capitan. I haven't had a chance to test Xcode 7 yet, but if you can you should try to see if your bug was fixed. – Epic Byte Jun 25 '15 at 21:03
  • @EpicByte think it's definitely like that! I sometimes also have the FPS drop in fullscreen and other problems like that above. So good ... Or bad ... To hear that I'm not the only one here. What's that bug on the MacBook Air your are talking about? Seems I should leave SpriteKit and switch back to cocos2d or so... But I do like it a lot ... Will test Xcode 7 / el capitan... – Simon Kemper Jun 25 '15 at 21:08
  • 1
    @SimonKemper You can see my post here on some workarounds to the full screen bug: http://stackoverflow.com/q/27758027/2158465 Hah the Mac book air for some reason caps the FPS when a certain number of draw calls are exceeded. The Mac book air also occasionally doesn't work with the full screen workaround I posted in the link. I would say stick with Sprite Kit. As long as you are not doing full screen it works fine (you can always go max window). As for your frameInterval problem may I ask why you are trying to limit it to 30. Imo 30 FPS looks really bad. If you are getting 60 stick with it! – Epic Byte Jun 25 '15 at 21:16
  • @EpicByte I agree it looks bad but prevents my MacBooks fans to speed up early something I really hate about the early retina devices ... That's all ... Btw since reducing my draw calls to a total of 6 (about 100 previously) I do not get that FPS bug anymore ... – Simon Kemper Jun 25 '15 at 21:23

1 Answers1

0

Ok! Since working hours on that figuring out what I am doing wrong I tested the Xcode SpriteKit template. Surprisingly even this Apple provided sample code does not react on the skView.frameInterval property.

So I was thinking of a hardware bug and searched the apple forums for that. What I found were a few people complaining about the same problem and surprisingly Apple does know about that FPS-Bug and will fix that in el capitan ... Hopefully ... I'm going to test the dev prerelease!

However, there are quite some more bugs in SpriteKit on os x! For example when switching a window into fullscreen the FPS drop sporadically by an undefined amount. It's a bit messed up!

EDIT:

Thanks to @EpicByte I found some reasons and answers. See his explanation in the comments above!

Simon Kemper
  • 635
  • 1
  • 7
  • 16