So…. GTB is out there being played by real actual people, rather than just me and my cats, and of course, the first few bug reports come in.
It seems hard for many gamers to believe that developers do their best to reduce bugs, because the minute you play a beta build, you encounter crazy stuff that makes you think “how the HELL did they let this one go?”. I thought I’d give an example of the worst bug found so far, and what caused it, and why I didn’t spot it.
Alt-Tab hangs the game.
On the surface of it, that seems mad, and annoying. Surely cliff tested it? Yes… he did, massively so, and it worked fine. So when I got multiple bug reports, after I KNEW it worked, I did some digging. Did alt-tab work for me? yes. In release build? yes. In release-build run outside Visual Studio? Yes? In different maps? Yes? Nighttime? yes. units selected at point of alt-tab? paused? mid-explosion? shockwave being rendered? nightvision on? paths drawn? yes,yes,yes,yes… after a cold reboot? YES.
Testing all that takes longer than it sounds… So then I do what you *have to do* when you encounter stuff like this. You pretend to be playing innocently, and go through an entire mission, playing and ignoring the potential bug, winning an entire battle. Then you play a second battle, and alt-tab. HANG
Which makes you think that it is something to do with multiple battles. Cue lots of digging through code. Cue turning on the directx debug run-time and maximised error reporting, and running the game in debug. Also cue bouts of near-sobbing when I manage to play 2 battles and it NOT happen… Eventually I manage to reproduce the hang in the debugger. (This is a big win). The you get that infuriating directx error that basically says “Srry, can’t restore DX, you forget to release some directx resource. We know which one, but we are leaving it to you to guess..” or words to that effect.
I bet this guy wrote that one:
Anyway, to cut a loooong (6+ hours) story short, eventually, a whole lot of experimenting shows that the problem occurs only if the post-mortem dialog, or one of it’s many offshoots get launched. This does some multi-threading, which led me up a right blind alley. Anyway… eventually it becomes clear that displaying the unlock-choices dialog causes it…sometimes…
Then a sudden brainwave. The unlock choices *sometimes* gives you a new Hull, and to do that it needs to render that hull. As an optimisation, it doesn’t draw it in layers, it renders out a composite texture (multi-layered) as a sprite, and uses that (it will get re-used later in various dialogs…). That means some render-target code gets triggered. A bit of digging shows that when I create a render target to save out a new composite hull texture, I wasn’t calling Release() on it correctly, in two places. Arrghhh! bug fixed. (AFAIK).
So why didn’t I find it before I shipped? Well basically I implemented the unlock dialog after I’d already tested the hell out of alt-tab. By the time I was close to shipping, and double-checking alt-tab, I either tested it in the first battle (no probs) or I had already unlocked anything and didn’t see that dialog, or I got lucky and the dialog only offered modules or ready-rendered hulls.
But it’s swings and roundabouts. This bug was hell, but pretty much every issues everyone is experiencing on the unit design screen to do with saving and deleting turns out to be a single line where I used = instead of ==.
Don’t you just love C++?