Godot Version
4.3.stable.official
Question
I’m developing a card game. All cards are already instantiated in the scene, but every time I deal a new card and it’s moved to the board, the FPS drops by ~10-20, until reaching 20 FPS for 12 cards on the board. See this chart of the FPS and object count:
Each FPS “spike” that goes back up to >100 is when I clean the board and start a new round. Spikes in the objects count are new elements, such as tweens, but these happen when cleaning the board. During a round the object count is stable.
The interesting thing that tells me this might not a problem with my code, is that after restarting the PC, I’m getting this behavior for the exact same play scenario (it’s automated so guaranteed no human interaction):
Something messes up Godot, maybe after the PC has gone to sleep and is awakened…? My biggest concern is that this behavior will show up in the final product, on the player’s PC.
If anyone has any thoughts about this, I’d love to hear. Thank you for helping!
Interesting Stuff:
- Godot 4.3.stable.official
- Windows 11 Home, version 23H2
- PC: MSI Katana GF66 12UC
- CPU: 12th Gen Intel Core i7-12700H, 2.70 GHz
- GPU: NVIDIA GeForce RTX 3050 Laptop, version 560.94
Seems like the object count is the same, if the FPS drop happens only on object load then it sounds like an i/o issue. Are you using a solid state drive? Is windows running a scan or update in the background? Check for the latter in the task manager next time this happens. You can somewhat program around slow i/o issues with threaded loads.
I’ll try to describe the flow of the game to make it clearer:
- Game starts, all cards are instantiated and added to the scene.
- Player deals a card, which entails just moving it on screen and some book-keeping (removing the card’s pointer from the deck, adding it to the board’s card array, etc.). No instantiating or freeing happens. At this stage the FPS drops.
- Player keeps dealing cards, each time causing the FPS to drop by additional ~10-20, until finishing the round.
- Player finishes the round, causing all board cards to be discarded (not freed, just moved out of screen and removed from the board’s array). At this stage the FPS goes back up.
And again, this behavior appears randomly, and is solved by restarting the entire PC. Restarting the game or Godot doesn’t cut it. I feel like this isn’t an I/O issue - maybe a GPU problem? But I will have a look at the task manager next time this happens.
Thank you for helping, I appreciate it.
I had the same issue. I’m working on a 3D game saved in drive D which isn’t an SSD. I tried moving it to my C: (SSD), and there are significantly fewer frame drops.
Interesting. I’m working on a laptop with a single SSD, so it’s probably not the culprit. I am starting to see a pattern and I think it’s related somehow to the Windows power management: I was working once on battery power, and had the FPS drop, and when I plugged the charger the FPS suddenly returned to normal.
Thanks!