[Solved] Game performance drops after a while

Correct, Trigger Once does not behave as you’d expect on for each. It makes the event only occur once…but only for the first instance it is used on. A lot of people fall into that issue and it leads to something where they create object instances, then they’re wondering why they’ve ended up with hundreds of object instances when they expect 5.

Normally the recommendation is instead of trigger once, add a boolean variable to the object, require it to be false as a condition of the “For each” event, then set it to True as the last action of the event. (You would then also reset that to False whenever you do your other actions that would normally be triggering the “For each”)

Really? So there are some changes under the GDevelop hood that effect performance? I hope someone who works on developing GDevelop is taking note…

1 Like

For clarification, the Devs have been tracking this:

Unfortunately, no one has been able to provide a reproduceable issue that occurs, pinpoint an exact version where it performs differently (130 didn’t have any major changes, for example), or are reporting different things entirely (other users reporting their games suddenly perform slowly from the start, which is very different than what Brainofcthulu is experiencing).

The only through-line has been the users may have older hardware that is no longer supported by Chromium’s WebGL setup, which would mean they’re no longer supported by current versions of electron.

So it is either isolated to events that haven’t been reproduced yet, specific to their machines and WebGL support, or a placebo from going back to prior versions (even something as simple as their machine not clearing cache/memory/storage correctly on previews, and going back to prior versions clears it could lead to this).

I do know there is going to be another electron update, which will include a newer version of Chromium (incase it is a Chromium memory leak or something), but if it is a minimum-WebGL spec change, that’s permanent.

2 Likes

I just made an account to respond in this thread. I am having the EXACT same issue. It seems like I am even developing a game in a similar genre.

I have 6 areas in my game with 13 rooms each (12 + boss room). Each room is a scene in Gdevelop and at the end of each scene going to the next there is a chance to move into 3 different variants for the next scene, so in total there are 19 scenes for each area and there will be somewhere around 220+ scenes when the game is finished.

In the middle of the second area, so around the 18th scene or so (counting main menu and tutorial room), an intense lag starts that makes the game pretty much unplayable. It starts at the beginning of the scene every time when nothing has happened yet. This only started recently and for some reason the FPS counter I have in game cannot detect it. I used the performance profiler to check and it says the slowdowns are coming from the events I have in the game. I use one external event sheet for every room other than boss rooms. The same one, there are no changes room to room. I optimized these events as much as I could and then I noticed looking at the performance profiler that (when the lag is happening) about 70% of the added ms are completely unaccounted for.

If I change anything and press the “Update” button to update the preview it completely fixes the lag. If I change scenes again the lag continues. If I preview the scene where I started lagging while playing there is no lag whatsoever. When I first encountered this issue I assumed it was a problem with my events so I started optimizing them and checking the performance profiler as much as I could to see what needed it most, and the more optimizations I made the farther back it would push the lag spikes. Meaning, it originally started around the middle of area 2 and it now happens usually at the area 2 boss which is about a 6 scene difference.

I guess I will rollback my Gdevelop to a previous update if I have to but I hope that doesn’t break any features or anything. I know the “Wait X Seconds” action was recently put into the engine and I have used that a lot in my events.

Does anyone know whats causing this or is this still a complete mystery? I can reliably recreate this issue if anybody wants to see.

Yeah I can’t rollback to 5.0.130 as Brainofthulu did to fix their problem. That version of the game doesn’t have the “Wait X Seconds” action which I have used extensively. Honestly I don’t even know how I would redo most of these events that use that action in other ways. This has completely halted my progress on the game I’m developing and I’m doing this full time right now so I am completely screwed because of this :confused:

If anybody has any ideas of a way to fix this problem I would really appreciate the help.

I would make a new bug report under a possible data leak. If the lag goes away when you update the scene (which i assume rebuilds and refreshes it) then it sounds more like a data leak issue than anything.

If possible try making a bare bones project with just enough functionality to move to a new scene and make like 50 blank scenes. See if, with literally nothing else going on, it still lags. If it does lag again after so many scene changes, post it online for the devs to check out and include it in your bug report. Then youll know for sure it has nothing to do with your events.

The only other thing i can ask about is if you have anything carrying over from scene to scene like music or layouts that arent getting deleted right. I assume you already checked this but i thought id bring it up just in case.

How could a layout not get deleted right? Do they carry over from scene to scene even if you don’t specify to create them in each scene? I have an external layout that I use for the UI and it’s in every scene. Could this be an issue that causes lag somehow? I would love for me to have been using external layouts incorrectly because that would be a simple fix but again I think this problem only started recently and I have had the external layout in as UI for months of development time now.

I mean moreso like if you have layouts being created using global variables triggered by your events. I had this issue in my current game where if you died during the boss fight i forgot to reset the global variables and it would spawn the boss too early.

Also! Check out your instance list in the debugger. See if there is any extra instances in the scene past what you expect. Like if something spawns on top of itself you wouldnt see it.

I completely turned off all external layouts and played up to the point where the lag starts and it lagged as it usually does so its definitely not that. I checked the instance list (which was a great idea, I did not check it at all up to this point) but everything was completely normal.

These are my most recent results from the performance profiler. There is more than 50% unaccounted for within the events section by my math. The 25% from the UI section is kind of odd though as that usually doesn’t create any slowdown. I will try to look at those events now but I’ve run the profiler before while this lag happens and thats not even normally the issue. Whenever the lag starts seemingly random section of events will be listed as causing unusual slowdowns. If I try to optimize those events as I have been doing it helps push back the point when the lag starts but then something else will randomly shoot up in percentage, only when the lag starts. Every time there is consistently a majority of the ms unaccounted for though.

Take a screenshot of the profiler when its fine and when its laggy and see if there are any differences. You may find whatever section is changing if at all.

This is from the exact same scene, without me having touched any of the events. The only difference is that I launched a preview of this specific scene as opposed to having played through the game to get to this point.

Whats going on in your UI events? Thats the only major difference i see so far.

Edit: and the items events

I optimized the events slightly by grouping a couple of events with the same conditions but its basically the same.


That’s all the events in that section.

The items section has a lot of events that do a lot of different things really spread out and last time I checked no one event section had more of a performance hit than another, it adds up to being one of the highest percentage groups but the performance loss is really spread out over a bunch of events that have only a very small impact.

The first issue I see:
You’re setting the opacity of multiple objects Every frame. You’re hiding objects every frame.

This impacts performance every frame and will impact performance more when there are more objects. You should probably be ensuring they only happen once (if the opacity > 0, or if the object is not hidden).

Same is true for showing objects.

1 Like

What I’ve read from your screen shots is that the events under Settings and under Forest Boss are hogging the processing. I’d focus on those two first. Your UI processing usage pales in comparison.

The render step is taking a fair bit of time too, but I’m not sure how you can fix that. Do you have sprites animating even when they’re off the screen?

I agree and that’s a good idea but not really related to my main issue in any obvious way. I have these events in every scene and the performance is usually perfect. I will implement that right now though. Thank you. Maybe it could fix it somehow who knows.

It could be part of the problem and shouldn’t be discounted. Your issue may not just be limited to one event but may be caused by a culmination of events.

Yeah, I was about to try looking at the settings as that seems to be the most prevalent issue with my normal events now that everything else is more optimized. I don’t have any sprites animated offscreen or even any sprites that are off screen at all. I have events that delete anything that moves out of the player’s view at all.

You meant like this right? I wouldn’t have thought of that. Thank you. It made the performance slightly better for that event group in the profiler.

I am going to look at the settings section now.

Yep, you can probably also add “trigger once” to the first events (Cursor/touch is on/is not on) and it’ll help a bit, but what you have now helps eliminate most of the large concern.