I’ve been using the profiler to identify areas of my project that need improvement. One issue that I have found is that whenever I run a scene, there is a massive frame spike at the start that then immediately falls back down to below the Physics Frame Time.
When you say “run a scene” do you mean any scene you load, or when you load a new level, or what? And what does the code look like that’s running the scene? When are you loading it and what are you doing to load it?
So far I have been running my scenes using the “Play Scene” button in the editor. Whenever I run a scene using that method, I encounter this spike. There is currently no logic for transitioning between scenes, as I have not made any others that will be transitioned to. Not sure if that is what you’re asking for.
That’s exactly what I’m asking. Your initial post made it seem - to me at least - that you were seeing and actual framerate spike in the middle of your game.
This also was misleading. It led me to believe that you had run more than one scene and seen this issue - again, while the game was running.
What you are saying is that when you start your game in the editor, and it starts in debug mode, that before the game actually starts, there’s a frame rate spike. My response is: It doesn’t matter.
Here is why.
You are testing something that will never happen in production.
When you hit that play button in the editor there’s a lot you can test. But if you want to test the end-user experience you should be doing that with an exported version of your game. There are lots of reasons that it could be spiking.
You are running it in the editor, and all the debug tools have to attach - including the monitors your are using. It’s possible that’s what’s spiking it in the beginning.
Your scene is too big. Since the entire scene gets loaded at the start, the only way around this is to make the Main scene smaller and load things piece-by-piece. That’s generally why you can’t skip splash screens. The game loads those then loads everything else while those are playing.
Godot just does that when it first starts. (I have no idea if this is true, but it’s possible.)
The question is: Do you as a user see this framerate hit in the game?
If the answer is no, then you probably want to just move on because you’re probably spending time future-proofing.
If the answer is yes, then you should export your game with debug off and see if it still happens.
If it still happens, then it’s probably time to compile your own leaner version of Godot and strip out things you don’t need. Here’s a really good article on that:
Here’s the official Godot documentation on that:
Upon re-reading your latest reply you say that this happens with every scene, and at the same time you only have one scene. So I’m kind of confused. Which is it? If this is something you see when you run say an empty Node then it’s probably either a Godot thing, or a Godot editor thing. It’s also probably not something to worry about. Especially if you can’t see its effects in-game.
Anyway, I hope that gives you some directions to look. If those don’t help, more information would be good - like what problem caused you to go down this road in the first place.
Based on this, the spike is probably something I should not currently worry about. It doesn’t affect the scene when run in debug mode. I will note to keep an eye out for this issue when running an exported version of the game. Thanks for the help.
Sorry for being misleading here. I have multiple scenes. I am working on a combat system for a tactics RPG. Various scenes handle different elements of the combat. They all come together in an “Encounter” scene. Most of the time I am running the “Encounter” scene when testing.
I initially came across this issue when I was trying to identify a noticeable stutter when displaying player movement range. I ran the profiler and noticed this spike.