Performance issues

Hi everyone

I am building a Game using SpriteKit, this game is like Mario Run and has short levels (120 at the moment) and here is how it is organized :


I do try to fix performance issues When I load a level (sks file) for the first time it takes 5 to 8 seconds and during that time the LevelScene is unresponsive. After that the levels load much faster (around 1 second) but its still quiet long for me.

I did move the method who load the scene in a singleton and put that instance in a background Thread in my LevelScene in the method who creates the popup for my level ,even if now I don’t have the freeze of 5 seconds anymore I do have 2 concerns :
-I am pretty sure that’s not how that issue should be fixed
-I still have 1 second freeze each time I load a level , how can I fix it ?

I tough about adding a black node with an animation to hide the freeze but Whatever I add nothing appears.

Does anyone has suggestion?

Hey @nehemie! I’m not too familiar with SpriteKit itself so maybe somebody else might be able to help you better however I did want to check if you have looked into the root cause of the performance issues, particularly the initial ~5s load issue?

You could look at using Instruments to do this (we have a tutorial here: and it might give you some clues as to why things are taking so long that might help you figure out ways of working around or improving the load time.

Hope it helps :slight_smile:

I didn’t see that tutorial ,this should help me , thanks @liamnichols

1 Like

After reading the instruments tutorial, I used Time Profiler and here is What I have :

So I significantly dropped the number of levels in my project ,to 100 I do have 36 now . It takes now a second to load the level but I still have the freeze.

Would the size of the .sks be the reason of the freeze (~450ko per sks)?
I do have a TileMap of 300 columns and 15 rows on some levels ,is using references instead would improve performance ?
Can I make this method faster?
Is Scene Transition can just be made in Main Thread?

It sounds like you have the layouts for all the levels in your game in a single sks file? That sounds like the root cause of the problem, you should only want to load the data for a single level at a time, to reduce the memory footprint of your app.

Also, many games pre-load assets when the game launches. You will notice that first thing that you see after the splash screen for a lot of games is loading bar. This is when the game will load all of the assets that it needs in to memory. Even if it takes a few seconds, it means uninterrupted gameplay after that.

Hi steveb, thanks for your help, “file” is the argument of my method, it’s a String who gives me the .sks file for the level I want .

e.g. “file” would be a String with the value “Level_2-1” and it will return the file Level_2-1.sks

I did convert to reference all my actions in my action editor view and deleted useless TileMap Node, files are now around 160ko and I don’t have any freeze anymore .

This topic was automatically closed after 166 days. New replies are no longer allowed.