Does GDevelop keep any information between two previews?

Hi all,
I encounter a strange problem.
For an unknown reason, launching a preview in my project causes GDevelop to crash, without even loading the preview loading bar. I did several tests to know if anything in my code causes a bug. Like a wrong expression or an endless loop. I couldn’t find such thing. But I encountered a strange situation that made me think the problem is not necessarily in my code. Here it is:

  • I launch a preview of my project.
  • the preview opens and loads fine
  • I close the preview.
  • Without touching anything else, I launch a new preview.
  • The preview doesn’t load and crashes GDevelop.

Here what is displayed:

So I’m a bit hopeless, since I wouldn’t know what kind of comparative tests I could make to find a bug, since with the same code, one preview works, and the second doesn’t.

Except all of your suggestions, I would have two more accurate questions:

  • 1 - what exactly does GDevelop when launching a preview, before the loading bar?

And the most important in my case:

  • 2 - does GDevelop keep any information between the first preview and the second? What is different that could cause my bug?

If any idea, thanks a lot!

(I’m using the latest version, 5.1.155, on mac, and problem is the same on PC with version 5.1.151)

It might be a Mac issue but sometimes on my PC, when I launch a preview, several things might happen…

  1. The preview works fine.

  2. The preview loads and the sound fx are audible but the window is blacked out completely so the preview can’t be played.

  3. The preview loads but it runs extremely slowly as if it’s in super slow motion.

For 2, I usually just close the preview and reload it. Often fixes the problem.
For 3, I have to close Gdevelop and restart it. Usually it’s a memory issue. So I have to clear my memory first (I use the program Wise Memory Optimizer).

So my best guess in your case is that it’s a memory issue where your memory isn’t being freed up between the first time you test the preview and the second time. Try checking your memory usage between previews and maybe get a freeware memory optimizer to experiment with between previews.

1 Like

Hi, thanks a lot for your reply.
Actually my problem is the same on PC
I have to say I know nothing about memory usage, but I’ll try to take a look at this.
I’ll try to investigate my issue further. Since my computer knowledge is limited to GDevelop algorithm, I’m lost when the problem seems to be outside the GD algorithm.
Thanks a lot for your suggestion!

1 Like

Hi there,
Did you look at the consoles? ctrl-shift-i.

1 Like

Hi,
You’re right, that should have been the first thing to do. Apologies.
So I just did. I share my screenshots, hoping someone can give me a hint about where the errors come from.

Here is what my console shows:


The first bunch of error that are not red, « You must enter a variable name. in (scenevar)», do not seem to be the fatal error, since I get the same in another version of my project that works fine.

Here are the details of the 3 red errors unwrapped.

1st:

2nd:

3rd:

The link on the right side of the console go to this:

Sorry if I share too much screenshots. I cannot tell what is important or not…

Are you using very large images, by any chance? (>2000px)

I wouldn’t be so sure. Why not fix them?

1 Like

Thank you,
Actually I had 3 sprites larger than 2000px.
I’ve deleted them.
Now only remain 3 small sprites.

The red error remains similar with « error caught while launching preview, this should never happen. RuntimeError: memory access out of bounds »


Yes that is true.

So I focused on this error : « error: “You must enter a variable name.” in: “” (scenevar) »
I narrowed the error down, and finally got it in a brand new project, with one scene and one event that causes this error.
The error comes from the action ‘Load text from’.
I do have a file called perso.txt in my documents folder, the debugger even shows the variable ‘aaa’ with the text from my file, well loaded.

Here is the screenshot of the scene event, and of the console. The console shows one « issue » that I opened, I don’t know if it’s important.

So those variable name errors came from another project, you don’t get them in your ‘faulty’ project?
Do you get the same crash/preview issue in any other project?

You could try to duplicate your project, and delete scenes until the issue vanishes, to know where to look for.

1 Like

after narrowing down, I ended up creating a new project with only one event, the one I showed before. So this variable name error seems to be an error specific to this event. Maybe it’s only on my computer? For confirmation one should try this alone event on another computer to know if it’s a general error?

For my projects, I developped very big external events that I use a bit as extensions. Some of my old projects had this crashing error as well, and it seems to come from this external events. So I remade from scratch this external events, more clean. Now the problem occures again, and, again, it comes from these remade external events.

Yes I have to try it. But it won’t be easy, because one external event cannot be deleted without affecting the others. They are nested and one needs the next one to work properly. Anyway I have to try narrowing this error.

By the way, do you have any idea of what ‘kind of error’ can it be, according to the red titles of the errors : “memory access out of bounds”, “offset is out of bounds” ?

I use sometimes GlobalVariables without declaring them in the Game Settings>GlobalVariable interface. Is that a problem? (all of my variables, scene or global, are created directly by the events code) I’ve always done like that and it had never caused a crash, but I ask, by chance.

No, not declaring variables ahead shouldn’t cause any trouble.
Even if you don’t do it properly, it breaks the variables but not the software itself, AFAIK.
I think “memory access out of bounds” means too much memory has been requested, like when trying to load an image too big, or if there’s some memory leak… :person_shrugging:

How many levels of nesting do you have with external events?
I remember we came across a limit a long time ago, maybe a similar issue here?

1 Like

Good :))

There are 10 levels of nested External Events.

That’s interesting. Thanks a lot.

BTW Variables themselves may have 8 levels of depth and the debugger displays « Max depth reached » but I read somewhere on the forum that it was not a problem, it’s just the debugger’s display.

Thanks a lot for your time and knowledge @Gruk ! I’m a bit less lost, and I know I can orient my tests toward this “memory access out of bound” problem…

Indeed…
Well, you could try that in a dummy project, see if GDevelop handles it. The complexity of the events shouldn’t matter, just the number of levels of nesting.

How big is your project, in megabytes?

1 Like

I tried on a dummy project, and the number of nesting (11 in my test) doesn’t affect the preview.


So I have narrowed down my error, and the error seems to come from the number of times an event is used in the scene.

I have an event, let’s call it event A. It contains External Events nested in each other.

If I write 17 times (or less) event A in a row, it works fine.
Beyond 18 times, it crashes when launching preview.
Note: Every time I add an event A, my project file (.json) size increases.

I tried the « Repeat x times » event to check if the error is the same. And the error disappears.
If I use the « Repeat x times » event and put inside my event A, I can repeat it even 100 times it works fine.
Note: Whatever is the value of x in the « Repeat x times » event, the size of my project file remains the same.

So we could think the error comes from the size of the .json file that would be too big… My json file is 1.1 Mo. I tested to create a very big GDevelop project, way bigger than 1.1 Mo, (filled with basic conditions and actions) and the preview launches fine, so I would not think it’s only the size of the file that crashes my main project.

So, now that my error is a bit more narrowed down, I have a question:
When launching a preview, what is the difference between, x times the event A in a row, and event A repeated x time (with the repeat event) ? Except for the size of the .json project file.

If anyone knows, I guess it could be helpful to understand this error… Thanks!

1 Like

Hmm… External events nested in each other? :thinking:
That sounds like a possible infinite loop. Can you share a screenshot or elaborate?

Can you tell us more about event A? Is that any action or a specific one? If so, which?

If you’re able to reproduce the issue in a dummy project and share it, it would surely help.

Don’t worry about the size of that json, I’ve seen much bigger :sweat_smile:
image

1 Like

Hi, sorry, I had no time to work more on my error these days.

Oh yes indeed!

Here is the schema of my nested external event. Each letter is a different External Event. For example C contains E, D, and I. There should not be any infinite loop.

Event A is the External Event A on the schema. It’s the top external event that contains, nested inside, the other ones. I use these external events as a function. I enter in a variable “ENTRY” a string, that is my order to the external events, an order to check and/or write over global variables (the game datas) according to some conditions.
So these external events deal a lot with values and strings comparaisons, text manipulation, copy a data base from one variable to another using « convert JSON string » action, etc…

Basically in my project I needed to make it easier for me to check and write on the game datas, quickly with one variable ENTRY, followed by the External Event (A). The external event modifies datas, and give out to me its results. So I use it exactly like a function. That’s why I intended to use it many times in my project scene. It works well once, it works well twice, but it seems like using it too many times crashes GDevelop.

So far I couldn’t narrow down one specific piece of events that causes the crash. It looks more like it is a matter of quantity… Maybe the preview loads too much texts into variables and that cause a memory crash?…

I have an idea that could solve the problem:
I’ve observed that Event A inside a Repeat 100 times event works fine, but many Events A one by one causes the error.

Are functions called dynamically by the preview? Or functions are, just like External Events, written one by one when the preview is launched?
If functions are called dynamically, I could make my external events a function.

Whenever I get time, I try to narrow down more the error and get a dummy project.

1 Like

Hi @Gruk ,
I’ve solved my problem. Thanks a lot for your help. :grin:
I replaced all of my external events by functions. the system is exactly the same but with functions, nested in the same way. Now it seems to work fine.

I have no idea what was the problem with external events. I couldn’t narrow down any specific issue.
All my debugging tests just gave me the impression that with external events, by adding them too many times in my scene, the preview code was too big for the memory to load it…
I guess functions work in a different way…

1 Like