Game Preview taking a long time to load

I didn’t want to bump and older post about this, so I made a new topic.

Basically, when I click the Preview button to test something out in my game, it takes over 30 seconds to load the game preview. This is a low resolution, retro game with sprites mostly being 16x16px and 32x32px. Regardless of what scene I try to preview, the preview takes just as long to load. For example, the Pause Screen scene, which has very few objects compared to a gameplay scene, takes the same time to load as any other scene.

When I look at the console as the preview is loading, I get what looks like this:

A lot of variable-related errors are being run through, but I get no errors in the editor as I declare them. Despite what the errors are saying, I have no variables (object, scene, or global) which are the wrong data type. I’ve confirmed this.

I do include multiple external event sheets at the beginning of every “gameplay” scene (for the Player Controller, among other events which are used in every scene). I’m wondering if this is a problem?

Once the preview does load, the game works perfectly fine and runs at a steady 60 FPS. It’s just the loading of the preview that seems to take too long.

Has anyone else experienced this, and if so, have you found anything that you were able to do or optimize which reduced the preview load time? I have about 100 global objects in my game, but like I said, none of them are of too high a resolution.

I’ve also gone through the Resources tab and removed any unused objects from there, but the long preview load times persist.

What should I try to get the preview load time to be more efficient?

EDIT: I’ve also tried disabling the events for including external event sheets in the scenes, but the long preview load times still persist even after this.

Can you expand the part in red background? It says that HTML is conflicting with the button class.

I can’t seem to recreate that part in red showing up in the console again. That seems to be related to something I already fixed in the meantime, but yet, the preview is still taking a long time to load, and it seems mostly due to all those “variable errors”.

Try deleting and re-creating the SpellActivated.SwordBeam variable.
It says that the variable is not found.

Since that variable was for testing something, I just deleted it and the code that was using it. Nothing changed. A lot of the “variable errors” in the console are saying that I have a lot of text (string) variables which don’t have any value assigned to them. But why would that be an error? I want them declared as an empty string “”, which I will change with events in the code.

And another “variable not found” error that I’m getting multiple times when I try to load a specific scene is a scene variable “ActivatedBarrierPedestal”, which is only declared in two scenes and not even relevant to the scene I’m trying to preview. So why would that be considered an error, and why would it be checking for that scene variable when previewing a scene that it isn’t delcared in? It’s declared in the scene that the external event sheet using it is linked to. Why is that causing a hang up?

Here’s another screenshot of that empty string variable error repeating several times while the preview is loading:

Any ideas on how to address this?

I don’t know. I haven’t encountered this. Is this a cloud-based project?

No, I’m running everything locally on my PC.

Can you check how it reacts if you don’t leave the variables empty?

I’ve tried declaring ActivatedBarrierPedestal (scene variable used in 2 scenes, which has the events that use it in an external event sheet which is included in all gameplay scenes). So although the events referencing this variable are present in an external event sheet that is included in most scenes, the scene variable is declared in the scene which the external event sheet is based on. I hope that makes sense.

As for how it reacts when I don’t leave them empty, I’ve tried declaring the ActivatedBarrierPedestal scene text (string) variable as 0, “0”, Null, “Null” and the error messages still pop up during scene preview loading. It still says the variable is not found (multiple times in the console) and that it is empty (also multiple times in the console). Like I said, all these errors are what is taking place while the preview is loading, which leads me to believe they’re what is making the preview take so long to start. But what I’m supposed to do about any of it, I have no idea. Nothing I’m trying is working.

Maybe the engine can’t declare a variable. I’ll think of a solution.

To add to this, I even created a completely empty scene and tried launching a preview of it to see if it would perhaps load quickly. While it loads a little bit faster than the gameplay scenes, it still takes almost 30 seconds to load the preview of a completely empty scene with no objects placed on scene, no events in its event sheet, and no external events linked to it. The only thing this empty scene has that the other scenes have are all the same global objects in the objects panel, which is obviously expected.

EDIT: I also opened up some very small test projects I was playing around with years ago to learn GDevelop. They have many fewer global objects, but their code is certainly not as optimized since I didn’t know what I was doing then. However, their previews load within 3 to 5 seconds. So what could it be? Could it be the close to 100 global objects I have in my current game causing the slow preview loading? If so, what am I supposed to do for enemy objects which are used in almost every scene? Copy and paste them and their code about 100 different times then have to do that again if I ever make any changes to the objects or their code???

Can you share the source code on github gist? It’s possible that the variables in the source code are not declared. I can create variables directly through the source code (not through the engine) if they are not present. This is unlikely, but it is possible.
(It is preferable to send me a link to the source code in person).

Or via itch.io (using a password-protected link)

I could do that. Let me know how to send something to you on either of those places, since I’m not familiar with doing it.

Upon further investigation on my end, I started trying some things. One thing I forgot to mention is that not only do I have quite a few global objects, but I also use about 15 global groups. 10 of those global groups are for different kinds of enemies. About 4 of this 10 global enemies groups have several global objects in them. The reason I thought about this is that when I go to add a new enemy object to all 4 of these groups, it makes GDevelop hang up for about the same amount of time as it does when launching a preview.

What I tried was copying my game project, opening the copy and deleting off all the global groups just to see if it made a difference. Lo and behold, after getting rid of these big global groups with several global objects in each of them, the preview launch time has been reduced from about 40 seconds to 20 seconds in most cases. Any thoughts on this? Are global groups with several objects in them problematic in this sense?

This is also possible.
By the way!!! I remembered that I had one project that took more than a minute to load because of an extension. I removed the extension, but it remained in the source code. This could also be the reason.

It’s funny you mention extensions…because I deleted/removed the extension “IsOnScreen” months ago, but it still seems like it is in the source code when I look through what the console is saying. How would I get this extension out of the source code?