1

I've found a strange behaviour on the Xcode 6 iOS Simulator.

Even with just a menu showing in my GameScene, the Simulator FPS area really low at around 20 FPS.

Are there any known issues, which could cause this issue? Also when I start my game itself, it drops from around 30FPS to 19 FPS immediately.

Here my code which is loaded at startup:

 override func didMoveToView(view: SKView) {
        var sud:NSUserDefaults = NSUserDefaults.standardUserDefaults()

        if(sud.valueForKey("highscores") != nil){
            highScores = sud.valueForKey("highscores") as [Int]
        }else{
            highScores = [0, 0]
            sud.setValue(highScores, forKey: "highscores")
        }

        createColors()
        createStartMenu()  
    }


func createColors(){
        colorArray = [
            ColorClass(name: "greenSea", color: greenSea),
            ColorClass(name: "emerald", color: emerald),
            ColorClass(name: "peterRiver", color:peterRiver),
            ColorClass(name: "amethyst", color:amethyst),
            ColorClass(name: "wetAsphalt", color:wetAsphalt),
            ColorClass(name: "sunFlower", color:sunFlower),
            ColorClass(name: "carrot", color:carrot),
            ColorClass(name: "pumpkin", color:pumpkin),
            ColorClass(name: "alizarin", color:alizarin),
            ColorClass(name: "pomeGranate", color:pomeGranate),
            ColorClass(name: "clouds", color:clouds),
            ColorClass(name: "asbestos", color:asbestos)]

    }

func setSceneBackground(){
    var background = SKSpriteNode(color: myBackgroundcolor, size: CGSizeMake(self.frame.width, self.frame.height))
    background.position = CGPointMake(self.frame.width/2, self.frame.height/2)
    self.addChild(background)
}



  func createStartMenu(){
        self.removeAllChildren()
        setSceneBackground()
        reset()

        var background = SKSpriteNode(color: myBackgroundcolor, size: CGSizeMake(self.frame.width/1.2, self.frame.height/1.5))

        background.position = CGPointMake(self.frame.width/2, self.frame.height/2)

        var buttonSize:CGSize = CGSizeMake(background.size.width - 20, background.size.height/4 - 15)
        background.setScale(0)

        var alizarin = UIColor(rgba: "#e74c3c")
        playLevelsButton = SKSpriteNode(color: alizarin, size: buttonSize)
        playLevelsButton.position.y = buttonSize.height + buttonSize.height/2 + 15

        var fontSize = buttonSize.height/2

        playLevelLabel = SKLabelNode()
        playLevelLabel.fontSize = fontSize
        playLevelLabel.text = "Easy"
        playLevelLabel.name = "playLevelLabel"
        playLevelLabel.fontName = myFont
        playLevelLabel.zPosition = 1
        playLevelLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Center
        playLevelsButton.addChild(playLevelLabel)

        var carrot = UIColor(rgba: "#e67e22")
        playMoreDifficultButton = SKSpriteNode(color: carrot, size: buttonSize)
        playMoreDifficultButton.position.y = buttonSize.height/2 + 5

        playMoreDifficultLabel = SKLabelNode()
        playMoreDifficultLabel.text = "Difficult"
        playMoreDifficultLabel.fontName = myFont
        playMoreDifficultLabel.fontSize = fontSize
        playMoreDifficultLabel.name = "playMoreDifficultLabel"
        playMoreDifficultLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Center
        playMoreDifficultButton.addChild(playMoreDifficultLabel)

        var sunFlower = UIColor(rgba: "#f1c40f")
        howToPlayButton = SKSpriteNode(color: sunFlower, size: buttonSize)
        howToPlayButton.position.y = -buttonSize.height/2 - 5

        howToPlayLabel = SKLabelNode()
        howToPlayLabel.text = "How To Play"
        howToPlayLabel.fontSize = fontSize
        howToPlayLabel.fontName = myFont
        howToPlayLabel.name = "howToPlayLabel"
        howToPlayLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Center
        howToPlayButton.addChild(howToPlayLabel)

        var emerald = UIColor(rgba: "#2ecc71")
        highScoreButton = SKSpriteNode(color: emerald, size: buttonSize)
        highScoreButton.position.y = -buttonSize.height - buttonSize.height/2 - 15

        highScoreLabel = SKLabelNode()
        highScoreLabel.text = "Highscore"
        highScoreLabel.fontSize = fontSize
        highScoreLabel.fontName = myFont
        highScoreLabel.name = "highScoreLabel"
        highScoreLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Center
        highScoreButton.addChild(highScoreLabel)

        //Names
        playLevelsButton.name = "playLevels"
        playMoreDifficultButton.name = "playMoreDifficult"
        howToPlayButton.name = "howToPlay"
        highScoreButton.name = "highScore"

        background.addChild(playLevelsButton)
        background.addChild(playMoreDifficultButton)
        background.addChild(howToPlayButton)
        background.addChild(highScoreButton)
        self.addChild(background)
        background.runAction(SKAction.scaleTo(1, duration: 0.3))
    }

 func reset(){
        correctColors = []
        tileArray = []
        tempArray = []
        amountCorrect = 0
        tapped = 0
        gameStarted = false
        maxTime = nil
        timeStamp = 0
        tileFrameSize = nil

        searchColor = nil

        tileColors = []

    }
Christian
  • 22,585
  • 9
  • 80
  • 106
  • 1
    XCode 9. I have FPS = 1, I open DEBUG > Open System Log and see tons of messages like that: "com.apple.CoreSimulator.SimDevice.B9A5D2AF-5251-4F7A-8D00-DAF75203390A[49490] (com.apple.videosubscriptionsd): Service only ran for 0 seconds. Pushing respawn out by 10 seconds." – Mike Keskinov Sep 26 '17 at 17:02

2 Answers2

8

SpriteKit uses OpenGL ES for GPU-accelerated rendering on a device. In the iOS Simulator, OpenGL ES support is provided by a software renderer. As such, any use of OpenGL ES — whether by itself or via SpriteKit or SceneKit — has very different performance characteristics on the simulator versus on an actual device.

Never rely on the iOS Simulator for performance measures, especially when anything GPU-related is involved.

rickster
  • 124,678
  • 26
  • 272
  • 326
1

There is a known issue with Sprite Kit Simulator... it is misleading. My game runs 60FPS on a device and 30FPS max in the simulator.

People will play your game on a device, not in the simulator so test accordingly.

meisenman
  • 1,818
  • 1
  • 15
  • 25