NokiMo
relativisticgame
relativisticgame

patreon


Week 47: bugfixes and release work

Apologies for being late with the weekly reports. I put my energies on the release preparation and on writing other posts. I didn’t have enough bandwidth to do all the writing. But the release is out of the door now (I’ll soon post about it), so here is the report for week 47, covering the period 18-22 September.

The focus of week 47 was fixing bugs in preparation for the first demo release, involving the publication of a minimalistic web-runnable executable on itch.io.

The one-sentence summary is: I fixed a couple of major bugs and a few minor ones. Below you’ll find a lot more details.

First, I ran the demo on all devices I had access to. I soon found out that while the demo was working on my Linux browsers and on my Android mobile, it had issues on other systems. In particular, the background graphics were not rendered at all on my Windows and MacOS laptops. It turned out that I was using old OpenGL API calls. The fix was to move to using Vertex Array Objects (VAOs) for setting vertex attributes. This is something I wanted to do for a long time. Once done, the demo could run on all test devices.

While doing this work, I also improved debug support, which helped fix some other minor issues.

Next major issue was memory usage. I noticed that on my mobile the demo crashed after using it for about one minute. The executable was running out of memory! Emscripten, the toolchain I use to build the game, defaults to reserving 16 MB of RAM memory for the application. This isn’t much for today’s standards, but is well above the current needs of my demo. My demo needs about 0.5 MB to run. So what was going on?

Well, it turned out that Lua was gradually eating up all the available memory. This is something I had previously noticed, but I had not investigated fully. So I looked into this. It seems that Lua’s Garbage Collector (GC) is too slow to collect garbage when using the default settings. The problem indeed disappears if collectgarbage() is called every frame. The solution I opted for was tuning the GC parameters, thus making the GC more aggressive. (I set pause to 100 and stepmul to 800.)

The fix works, but makes me feel a bit uncomfortable about Lua’s memory management. It seems others had similar issues. One alternative possibility would be trying Lua 5.4 which introduces a different Garbage Collection scheme. I hesitated doing this update, as migrating from Lua 5.3 to Lua 5.4 is likely to require one/two more days of hacking. I did however migrate from Lua 5.3.5 to 5.3.6, before doing all my GC investigations (the changes were minimal, unlike the ones between 5.3 and 5.4.)


Related Creators