Right from it’s initial launch on steam, there was a bug reported in Gratuitous Tank Battles for a tiny subset of steam players. The bug was basically that the game ran horribly slowly, with stuttering and skipping music.

Regular blog readers will know I am a bit obsessive about optimisation, so naturally this seemed weird to me. Right from the start I doubted that this was actually the games graphics engine or core gameplay code running slow. Not given the specs of the users reporting it, which was a wide cross-section of hardware types. Happily, this was confirmed by the realisation that running the game from the .exe, outside of steam, enabled it to run perfectly. A good workaround, but not actually a fix.

This was followed by weeks, maybe even months of me investigating what on earth it could be.

Initially, I assumed it must be something about the steam integration code. So that resulted in a ton of going through it with a fine tooth comb and checking every parameter, asking valve if I was doing it right, checking with other devs how I was doing it compared with them etc. I ended up moving the code that initialised steams systems from one point in my code to another, as they recommended, but there was no change. I also changed a callback to run every 100 frames rather than every frame, and again, no difference.

Then, finally we found some helpful players who not only had the bug, but were happy to run diagnostic code on their PC for valve to analyze. A very helpful guy from valve then crunched through it, and found that an alarming amount of time was spent in the sound library, and in Heapvalidate(), called from it. This then led to another 48 hours of me looking at heap validation code, memory errors, installing xperf, the application verifier, trying (and failing) to download Microsoft platform SDKs, lots more poking and prodding…

and then eventually  I got a reply from the sound library people suggesting that yes, it *might* be their code occasionally calling HeapValidate() all the time, and to upgrade to the latest build.

So I did that and it has fixed it…(afaik)

How annoying. The one piece of code in the game not written by me, and it had a bug in it! At least it’s fixed now, so all is well. I bet my code has bugs too :D We still don’t know why it was actually caused by the interaction of the game with steam, but that just seemed to be the randomish trigger for the errant memory checking.

I have a new ninja PC on order. I dread re-installing anything. Is there a magic new way to do this, or will I sit there downloading and installing stuff for 2 or 3 days again?

11 Responses to “That steam stutter bug, and tracking it down…”

  1. Matt Jones says:

    For various utilities don’t forget about http://www.ninite.com.

  2. StevieW says:

    The only way I’ve managed to avoid doing a massive reinstall of all my software when moving to a new PC is to close the drives from the old PC and put them into the new one.
    Haven’t tried this in a while, so not sure how well it works with Win7 (assuming that’s what you use), but with XP and older it only worked when your new motherboard was from the same family as the old one

  3. AlexV says:

    You can use SysPrep to prepare your Windows 7 install for use on a new motherboard and components, if you’re just going to clone or transplant the disks.

    Handy guide here: http://www.sevenforums.com/tutorials/135077-windows-7-installation-transfer-new-computer.html

  4. Josh says:

    You can save the time of downloading by temporarily hooking up your old drive as a secondary drive on the new computer and running the installs from there. Assuming you saved the downloads in the first place! If you do, be sure to copy the files to the new HDD for the next time.

    I actually keep a copy of all important downloads on my file server so they’re accessable from any PC on my network. Storage is cheap, time is expensive.

    Can’t help on the install time though.

  5. Sean says:

    Be careful, usually short-cuts end up being long-cuts. Keep your documents ready on an external drive and installers ready.

    So does this mean you get to use your desk tower cabinet?

  6. Niall says:

    Just transfering the hard drive should work, but Windows tends to throw a tantrum when you do that. Hopefully it should let you re-activate Windows, but I can’t guarantee it. Also other software like the Adobe Master Collection doesn’t seem to like it either.

  7. redniels says:

    It’s 1 pc. do the sensible thing: reinstall. If you just use an image tool or god forbid, just swap the old disk in, you will run into all the quirks and probs which your old pc also had. and which made you decide to buy a new one!
    and lets not forget the possible driver/registry hell.

    sysprep is all good and well but setting it up(make image, “clean” image, search new drivers, enter drivers in image, reenter code, etc etc etc) for 1 pc… it isn’t that much faster than just a simple reinstall..
    This was true in the Win9x era, and unfortunately still is.

    I want my Gratuitous Dragon Battles (or whatever you come up next) somewhere in this decade, and that means that you cannot be stuck in driver hell for to long! ;-)

  8. jackson says:

    What sound library are you using?

  9. dave says:

    PLEASE dont try and transferr your installs (apps) across
    start FRESH. I work in a pc store and some people that transferr windows etc, always have trouble down the road.

    Do you want the next game to have lots of bugs because some old driver is kicking about in your windows that shouldnt be there (eg a sound driver for the wrong chipset of your motherboard)

  10. Stew says:

    There was one good thing about DOS over Windows. DOS never gets gummed up like windows OS’s do. I swear the philosophy of ‘keep it simple stupid’ got lost somewhere trying to get customers lock in. It’s pretty sad that after decades systems still slow down and install all sorts of nonsense and services. They never try to keep themselves contained and isolate themselves so that the system remains smooth.

    DOS definitely had its good points (in terms of migration) that I miss with the advent of windows.

  11. Draxis says:

    Interesting read, thanks for sharing the bug!