Huge problem with the Game engine - please help

Hi, I’m just finishing a game in GDevelop (2d), and when I try to play it from start to finish, the game engine chokes after about 40 minutes of gameplay if I transition from one level to another (if I play in the same level for 40 min it has no problem). It’s a dramatic frame drop - it’s basically unplayable, and you need to restart the app and then it works just fine (for about 40 min if I change levels).

If I open the app to play a level, then close it, play another level, it’s perfectly fine. But if I run the game from start to finish, it chokes, and it’s unplayable. It’s basically a broken game, I can’t publish it like this.

Do you guys know anything about it? Is it a memory leak, can I do something about it, or do I need to redo the whole game in a new engine?

It could be a multitude of things. Can you provide screen snips of the events that change scenes? Are there any events that create new objects? What about saving data? Do you have many for each loops? Are you using effects?

When you say transition from one level to another, is it the second level that affects performance? Or are there multiple scene changes before this happens?

Hi MrMen, thank you for reaching out!

I just managed to get the debugger going (it didn’t work because of the antivirus). Played it again, and the game chocked, around 90% of the effort was because of a few lines of code that moved the hitbox on the character’s position.

I fixed it (though it shouldn’t have been a problem), tried it again, it chocked around the same place in the game, on a different part of the code, that really made no sense - creating a weapon drop, but the event was not taking place, it just stumbled there while reading the code.

It looked kind of random, and illogical - they weren’t really problems - but both issues were in external events linked in different levels. I wrote the code mostly in external events, and linked parts of it / different mechanics, in levels according to what’s needed (level specific code was kept in the scene).

I guess I need to get the code out of the external events and paste it in every scene, and see if that makes any difference. If that doesn’t work, I’ll write about it here, and if you would like to take a look, maybe you could suggest something.

Thanks again for offering your help!

I took all the code from external events and placed it in the scene events, and I have the same problem. Around the same place in the game (more or less), the frame drops dramatically, and again the debugger points to a short code about dropping a weapon when you hit a box (code that works perfectly fine in the rest of the game). And also, now, the engine spends an important percentage of time on a disabled code (this looks random).

Earlier in development it started to choke when I reached level 7 (multiple scenes). Now it chokes at level 5 (multiple scenes). Any ideas where to look for the problem?

Not surprising, because all GDevelop does is take the code from the external events and inserts it into the scene when it compile/previews the game. So whether you move it or not, it won’t make a difference.

Can I assume you’re using event groups to work out where the bottle neck is occurring? If so, can you add more event groups to break down the events into smaller collections of events, to narrow down where it’s happening?

Also, if you can share a screen shot of the events, then we might be able to identify where it’s causing the issue.

Just to clarify a bit, one thing to keep in mind with external events: they should only contain logic for objects that exist in the scenes they’re being used in. Super high level: You should not have one massive external event sheet that contains logic for each level if the levels have unique objects.

For more detail, every event is processed every frame, including any events within an external event sheet. (They only proceed with the actions if the conditions are met, but the conditions are still read and processed). If you have events that are called for objects that don’t exist in the current scene, you will potentially have errors happening. Object groups can help with this a bit, but again only if that object group exists in every scene the external event sheet is used in.

If you are switching scenes, and the external event sheet is calling for more and more objects (even ones that are at the beginning of the scene), you are compounding errors the longer your game runs. Whats worse, if you have things like waits/timers/etc trying to start, those timers are being added more and more for things that will never stop them/process them/etc.

Using external events is a great way to clean up your event sheet, and remove some repetition, but it isn’t a performance optimization of any kind, just a development optimization (and one that could have performance hinderance if you implement problematic events like the above).

All of the above in mind, I’d agree with MrMen that we can’t really provide better guidance without seeing the events that are taking your processing time. It could be something as simple as not using a trigger once, or using trigger once within a “For each” event (which doesn’t work how people are used to, and therefore you’ll have that event occur for each object every frame, regardless of the trigger once).

Thank you for reaching out, Silver-Streak. There are no more external links, the code is copied and pasted in every scene and I still get the same problem around the same place.

Now the engine chocked on a different part of the code that worked fine until this now - and this part shouldn’t be demanding. It goes something like this

When the text of scene var “ActivePlayer” is “Assasssin”
and global var ButtonNext is 1,

check 3 sub events

  • if 2 var are x, then change 2 other variables
  • if 2 other var are y - then change 2 var
  • if 2 other var are z - then change 2 var

This code repeated 2 times, with different values. But apparently this code is too demanding for this game engine, there is really nothing to fix here, and the randomness of chocking is just ridiculous. I think it’s a lost cause, I’ve spent 3 years building the game in the wrong engine - ironically i didn’t encounter this problem until I built most of the game, so the engine might be ok for gamejams, but not for something serious.

I just remembered, a couple of days / weeks ago, the game engine sometimes stops reading string variables - but is not consistent - sometimes it created objects in the menu if “language” text var was “english” sometimes it didn’t and I had to make it a value 0/1. I could hunt down all string var in the game to change them to values, but given how the engine “works” it might just choke on a different part of the code - totally unrelated.

Again I appreciate you reaching out but this is too random to make sense. Sorry for bothering you. I’ll just take a vacation, and try it later, (maybe the engine will get a few updates that might fix / brake the game).

The code you described doesn’t sound like it should cause an issue. Is it just that one event that you managed to narrow down the debugging? It more likely that there is an issue somewhere else and that’s clogging it all up. Are you using many effects in the game?

I assume you’re running the performance profiler to determine where the issue lies?