Huge spike in profiler causing longer than usual load time

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By anonymous2394

I’ve been having an issue where my game would take about a minute to load even though my game (with ResourceLoader.load_interactive) only takes about 5-10 seconds to get to 98%. When the game gets to 98%, the window freezes for about an additional 45 seconds before the game is displayed. Whenever I view the profiler, there is always this huge spike where the process time would be 44-48 seconds long. I know for a fact that this is the cause of the extra load time for the game to launch but I cannot for the life of me figure out what is in that process time. Is it only the _process function? Or does it include _physics_process too? If there are any details you’d like me to tell you or images you’d like to see, let me know and I’ll provide them. I really want to get to the bottom of this because waiting 44-48 seconds for a single process frame to finish (at least, this is my understanding of it) is far from acceptable. Also, this is driving me crazy and I really want to resolve this issue.

Idk if this would help but I have 1 player with a small _process function (2 lines) and a rather lengthy _physics_process function (66 lines). I also have 10 enemies, each with a relatively short _process function (11 lines). If you want the code for the player’s physics process function, I can post it.

Background information: The game I have is a 3D game. It’s in the style of an open world game. I’m using GridMaps for the ground (if that makes any difference). Also, in the mesh library, I’ve attached various .tres textures to the objects to give them texture.

Side note for the player’s physics function (and this project in general): the project started as a group project but now that I’m finished with that class (video game dev) and we don’t need to work on it as a group anymore, I’m working on it all by myself just for fun. As such, I didn’t create the physics process function for the player, someone else did. I also haven’t optimized the code yet since I’m trying to figure out what exactly I should focus on to improve the load time.

Side note for the image below: Although it says frame 247, making it seem like the screenshot was taken during gameplay, I didn’t clear the profiler before I ran the game again. The profiler data was taken while the game was loading the main scene using ResourceLoader.load_interactive

https://imgur.com/a/ARVOqW9