A few more questions about the weird lag I get lol

Hey everyone, I’m just about done with my game and now I’m basically just trying to make it run smoother, so I have one last bunch of questions to ask, and then hopefully I wont annoy people here anymore with my walls of text posts lol

First issue is slow loading. I added hundreds of small sprites to my game near the end and the loading time of my game skyrocketed up to about 40 seconds on my main phone (not a very good phone but still), and even up to like a minute and a half on a really cheap phone (tho other games that i try on it load pretty quick). Nothing I see makes me believe that sprites affect loading time but I’m not sure what else it could be, it went up very noticeably once I started adding them. I have removed unused assets from resources, and I tried to compress my images but it made absolutely no difference.

I also have some basic lag, laggy/freezy animations and a very sluggish sometimes unresponsive feel especially on the cheap phone, even on a scene where there’s barely anything going on in events and like 3 objects in the scene - essentially it’s just a scene that lets you scene change to other scenes. When you press a button to switch scenes, the screen darkens with a simple animation and even that seems to drop frames. My backgrounds range from 240x135 to 720x135 and are zoomed into 4x through events. Ironically, some of the scenes with 720 width backgrounds are the least laggy. I am aware of the fact that events can cause lag, either by an action running with no condition or there being a million conditions being checked all the time so I do try to avoid those things. I’m mainly wondering if there might be an issue with zooming into my sprites or sometihng?

In the console it still says I have hundreds and hundreds of errors, all saying things along the lines of “you didnt enter a number in a field where a number was expected”, and I feel like that may actually be a bug with gdevelop at this point, because I pinpointed specific actions that lowered the errors when they were removed, but there was nothing wrong with them. I don’t remember exactly which they were but if someone is really interesting in seeing I can try to find them again. I just remember feeling confident that there was literally nothing to change. But either way, I’m not sure if those errors are having an effect on my game’s performance or what.

but the weirdest lag that I get are these brief freezes that happen a few seconds after loading a scene, and only once per scene, per launch of the game. So, after launching the game, a few seconds will pass and it will freeze for a bit and then it does that on every scene, exactly once. when you go back to the scenes they dont do it anymore. Restarting the game restarts it. I know that’s vague but I’m hoping that there’s just some specific thing that can cause that sort of issue that people know about lol.

Try to share some screenshots of your project so we can see what’s happening there, maybe a ForEach or a Timer is cause of the freeze.

How many objects are in the scenes that have the initial load lag?
The fact that it only happens on initial load makes it sound like a caching issue, but GDevelop preloads assets, so it could be an indexing of the cached assets in the scene perhaps. There may be potential to make some of those objects into global objects and moving the caching/indexing up a level… but that could have memory overhead for all other scenes.

Thank you for the responses! I do actually have a bit over 100 global objects. I suppose that could actually be the problem? I wasn’t suspecting it since the intensity of lag varies with scene, but I’m not sure. (for example, some scenes have just a slight almost unnoticable freeze and the animations are smooth) The scene that gives me the biggest problem and the longest lag spike at the beginning has probably around 100 objects present (a lot of which are global objects), and it’s the second scene - where you get to after the title screen. It does have a lot going on in events, but the fact that the freeze happens on each scene makes me feel like it may not actually be event related, because all scenes vary with their events.

And I’ll take some screenshots, though there’s a lot so I’ll need to go through it and see if there’s any parts that stand out as potential problem parts. I have been very careful when using foreach events though and making sure to not run actions without conditions etc.

Having actions without conditions is fine.

What are your file sizes - images and audio? Are you using any layer effects? These are can have a real noticeable processor drain on older devices.

Otherwise, if you provide screen shots of your events, we may spot something that’s nor obvious.

100 global objects is a lot… I guess it depends on their size but that overhead applies to every scene… so try making a completely empty new scene with no logic or new objects. Make that the first scene after the title screen. If it takes that empty scene seconds to load… you may just be stuck having to un-globalize those objects (which will not be easy)… I pray it’s something else.

Yeah, if I could redo this game from scratch I would do a thousands things differently, and would have less scenes and substantially less global objects lol. I’ll try what you mentioned and I also have some other ideas in mind that I’m going to try regarding the global objects so I’ll let you know what I find.

@ MrMen, the biggest images I have are my backgrounds which are 720x135. There are quite a lot of 160x140 images (about 350-400, it’s basically an entire collection of clothes and character customization options lol. I had kept all the sprites the same size to enable easy flipping of my character and it’s layers of clothes, but I guess I could spend some time to trim them down and manually redo some stuff.
My longest audio clip is 1 minute long, the rest is only a few seconds. The lag existed before the audio was put in the game tho. No layer effects.

An update! Hopefully this might be helpful for anyone that has issues like these.
I think I’ve found a way to fix the freezing that I get at the beginning of each scene. I discovered that the freeze was being caused by my events, but it was more like the issue was rooted in the size of the event sheets rather than in any specific part in them. Moving all of it to an external event and linking to that completely fixes the freezing. I’m not sure if it’s a bug that I was running into or if that’s just the nature of android apps and how they’re built.

I also think that my slow loading screen is entirely tied to the excessive amount of images that I have in my project. I’m not sure if gdevelop is really built for the type of thing I was trying to do (I have 4500 images lol). Removing a couple thousand of them as a test made the loading screen nonexistent. I think i’ll just live with it though and hope people don’t mind too much lol. If I were to make another Gdevelop game though, I would definitely aim to make it smaller scale.

I also noticed that the blank black screen that shows right when the game is launched, before the % is visible, seemed to take a very long time too, and found that that one was tied to my events. Finding and removing unnecessary parts in my events cut the time of that screen in half.

4500 images LOOOOL! I hope you’re using a compressor for that, use RIOT compressor or https://compresspng.com/
For the events and External events is a good practice overall for debug.

Yeah I compressed them hahah. and I’m glad to hear that external events are commonly used, I think i’m probably going to be using quite a few of them. Wish i understood how they worked a long time ago haha