Welcome back to your regular VV Eekly Update! I hope that everyone is having a lovely January, in this lovely year 2024, on this lovely VV-ednesday. What a good day for a VV Eekly Update! (whoops)
Today, I have a tale of preloading optimizations, optimizing loading times, and, tragically, premature optimizations. (Spoiler alert!)
Today’s post is a doozy, but if you manage to read to the end, you’ll get a sneak peak of a very very exciting thing!! (Very!)
Preloading
Recently, I’ve noticed that starting Vyn and Verdan to test out features has started taking longer and longer. Previously, opening the game would take a second or two, but it started taking multiple seconds.
Anyone who’s used a computer before knows that that’s the worst! I hate waiting. You hate waiting. Crucially, all of the other people who might open Vyn and Verdan probably hate waiting.
So, I decided to debug why it took so long to load. Let’s walk through that.
When you open a game using Godot, the engine loads whichever scene you set as your main scene. That scene typically has a few children – other scenes that are part of the main scene. It also loads what are called “autoloads” – things that are always loaded and are always present everywhere. I’ve talked about them before in VV Eekly Update #11 – Godot Patterns.
Therefore, one of these must be the cause of the long loading time. It didn’t take too long to figure out – I have a long list of “preloaded data”. Basically, the engine loads this data into memory before the game even starts, so that the game doesn’t stutter in the middle of gameplay when things get loaded.

There’s a lot here! But it makes a lot of sense for this to be the laggy element. As the game has grown in scope and with more and more data being preloaded, this would naturally take longer and longer.
Background Loading
The issue that I saw was that data would take too long to load, causing the game to be slow to launch. The standard solution is to load data in a background thread, which Godot even has a whole tutorial on! This can’t possibly be that hard, right?
All in all, it wasn’t too hard. I did spend a few days working on it, but now I have a standard solution that:
- Allows for registering assets in one line of code per asset
- Creates a background thread
- Automatically starts loading assets when the game is started
- Uses a different background thread to maintain completion status
- Logs how long loading assets takes each time the game is started
- Automatically cleans everything up
I do say it wasn’t too hard, but I did lean hard on my previous experience as a software engineer. This stuff would have been very difficult for an inexperienced programmer! I think the tutorial did a pretty good job of explaining the basics, however. Nonetheless, I was grateful that I already knew the intricacies of thread management!
After I built this utility, Vyn and Verdan would open quickly to the starting screen, but then there would be a few seconds before the game could be played. Now that I had this utility, I could see that loading assets in the background took about ~6 seconds after the game was opened.
My next question was: Can I reduce this loading time further?
Asset Sizes
Which asset in particular was taking long to load? To find out, I deleted each preloaded asset one by one to see if there was any outlier. Luckily, there was a HUGE outlier!
var SCENE_LEVEL := preload("res://main/level.tscn")
Surprise, surprise. Loading the whole game level took a long time! Who would’ve guessed. Let’s take a look at what the level looks like.

To keep going, I went into the level scene, and I deleted each child of the scene one by one. Surprisingly, the UI layer was actually the big outlier here! Let’s take a look at that UI layer.

In the UI layer, the effects was the big outlier. “Effects” are what I call the big screen special effects that happen in games. For example, the screen darkening with a heartbeat, the sun spots that appear after winning a level, and winds blowing left or right are all effects. You might be able to guess what I did next.

This was a little harder to figure out, but I eventually figured out that if I deleted both “SunSpots” and “Upwards”, then Vyn and Verdan would take ~2 seconds to load instead of the previous ~6 seconds. So, why was that?
I poked around in the SunSpots file, and this jumped out at me!

Don’t worry too much about the weird jaggy lines – the bottom line is the important bit. This was almost 16 MB! I immediately went to look at the sizes in the folder.

Yup, there’s a clear correlation here. Most of these files are 2 KB, and SunSpots and Upwards were 64 MB each. For those keeping track at home, that’s an approximately 32,000 times difference!
The reason that there’s a large image in there was because I was using a big image to say “spawn things all over the screen” for both SunSpots and Upwards. You can also see that Seasons and Empower are large. For those, I was saying “spawn things around the edge of the screen”.
The “all over the screen” was an easy fix. There was an option that I had missed earlier that just let me say “a box this size”, which, by the way, takes MUCH less data than a large image.

The “around the edges of the screen” was a little harder. For those, I ended up actually changing behavior and saying “a ring around the size of the screen”. Luckily, I think it might actually look better now – here’s the old and new behavior.


And here’s the updated sizes in the folder:

Nothing above 10 KB! *whew*
After all of that, the background loading now takes 0.8 s down from about 6 seconds. That’s a huge decrease! If it only took less than a second to load, then I don’t think I ever needed to implement background loading… That was certainly a premature optimization! But it’s OK – I’ll appreciate having this background loading utility in the future, and it certainly was the point of Vyn and Verdan for me to learn from this type of mistake.
So that’s all for today! If you have any feedback, please post on the usual Disco – oh wait, did I forgot something? Haha I knew you wouldn’t let me forget!

Now, THAT is all for today! Look forward to the next VV Eekly Update, since it’s a very special update!!