Game is taking very long time to load

Hello, I’ve been making a top-down Zelda style game. Loading the game to test it is getting slower and slower. It now takes about a minute to load. Is this normal? I’m fairly new to the program.

You mean the game-preview in GD or exported to itch.io, etc.?

I mean the game preview I guess. The thing it takes you to when you press the play button in GD.

I don’t think I have an action that continuously creates an object. But I do have lots of scene variables and global variables. Could that be the issue?

And I didn’t use any physics as far as I know.

Not sure if variables are the problem because I have a game with a lot of variables and it loads in approx 10 - 15 seconds (it’s a large game)

Could it be too many global objects?

Okay. I don’t know your game and system, but a minute doesn’t sound normal.
I have 10 scenes, ~20 global objects, 800 images and it takes <10 seconds.
Maybe you can delete a few things to test where the problem is.

I don’t think variables could be a problem. Do you use large images? (>1000 pixels)

Yes, some of them are many pixels. A lot of them are made in boxes that are 64 pixels wide and 64 pixels high and sometimes the boxes are filled in with a color. I made some floors images that would have far more than 1000 pixels but they are just in my resources. They aren’t actually in the scenes, so I’m not sure if that would affect the loading time. So far I have 26 scenes. I have 117 global objects and almost 100 global variables.

What if you try doing a copy and eliminate the other scenes?

Neither your pictures, scenes or variables amounts should affect the performance that way.

If that behavior started after some change in the events, then the problem is in the events.

For further help it would be useful to know the specs of your computer and the events of your game.

I recently had a very similar problem with the game I’m developing. After some changes in the events the game started taking up to 45 seconds to load and showing a noticeable FPS drop. To solve it I used the profiler/debugger bundled in GDevelop, that way I found the sections of the events that caused the problem and optimized some routines. The problem was with a massive amount of object timers and a massive amount of collision detections per frame, so I had to get creative to do the same things (more or less) in a different way. But I have to say, it was relatively easy to found the problem because I have my events classified in event sheets and event groups.

Good thread. I’m running into issues with the loading taking about 45-60 seconds to preview. I will run an extensive debug today and see if there is anything I find. My suspicion is a large number of global objects or some major issues with event triggers.

Update, I’ve essentially tried everything. Cut down heavily on timers, optimized PNGS, optimized events (which helped performance insanely well), cutting out external events, etc. Seems to make no difference in loading time. That must mean that slow loading times are caused by a large number of objects. I have over 100 global objects which could be the issue.

Update: I opened developer tools while loading the game and what is causes the long load time is an insanely long list of errors. None of these errors actually show up as incorrect within the GD client, so I am not sure where they are originating from.

I’m attempting to use the dev tools to pinpoint the source of the problem but this seems like it’s next to impossible. Edit: I found some of them, but most of them are these strange things like below. Also the same errors are repeated over and over and over.

aaa

Anyone have any ideas?

That indicates you have variables, actions, or expressions being used that has the wrong type of data.

E.g. you are using an expression that requires a string, but are just passing 6. You need to use “6” to have it count as a string. Or if you are pulling from a variable that is just 6, you need to wrap it in a ToString or use VariableString.

Or the inverse. You are passing “6” to an expression that needs just 6.

Hey Johnny did you find a way to pinpoint which actions/conditions those errors were related to? lol I’m struggling with this issue as well it seems, and I’ve been looking and looking, and just don’t see any expressions that are missing numbers or text. And apparently there’s almost 1 THOUSAND expressions that are having this issue so I’m baffled. It seems to mainly just affect how long it takes to load a preview I think? Rather than the actual loading time of the game, at least.
Capture

Clicking on the link on the right (59.bb9b06a4) should go directly to the line of code that’s missing the data. It will be in javascript but may have some variable or object names that make it more familiar.

Yo, so apparently (I only looked over this for about ten minutes last night), these errors are being duplicated multiple times as if the system is checking for them and reporting them at least 3-4 times, but it could be more. So I will have an in depth look today and see what I can find and report back.

Do you also have slow loading times?

Also dunno if this helps, but I’m going through the errors in order and from what I can tell, it’s checking them in the order of top to down in the GD client, so they are roughly in order. I.e., the errors seem to be appearing in my external events, in order, from top to down, so this is how I’m hunting down the problems.

In your code it looks like it was expecting an input, but you might have accidentally left it blank. It looks like I was putting one too many " on some color hexes, causing problems. Once I pinpoint where those color hex errors were appearing, then I narrow down where the other issues were appearing in between.

You can kind of see here.