Small patch with a fix for audio framework issues.
If there is one thing we have had more issues with than anything else, it is audio. Today I believe I squashed a heisenbug with audio. For the uninformed, Heisenberg was famous for studying how things change when you look at them vs when you don’t look at them, and a heisenbug is a bug that doesn’t exist when you use tools that can find bugs. This heisenbug was a heap corruption caused by someone else’s code interacting with audio hardware, probably all of my least favorite things combined in one place.
I was able to get the game to crash very consistently in the live distribution simply by spawning ships and having them battle, but when I attached a debugger the game would never crash. It’s not the type of thing that puts me in a good mood.
However, after many hours of poking and prodding I noticed that it didn’t crash if I could not hear any sounds playing, so I did a ton of research on our audio framework looking for clues. Long story short, the bug was not in our code at all and I had to fiddle with the source for our audio libraries to limit the number of sounds that would play at once to something that audio hardware could realistically handle on windows. The result was a partial success!
I say partial success because it isn’t an elegant solution, and it will probably need to be revised in the future, but the game no longer crashes randomly due to audio related memory corruption. The net result is almost a 4x increase to the FPS during massive space battles, or looking at it another way we can spawn 4x as many ships and have them shoot at each other without dipping below 60fps. This is great news for our simulation stability, so what’s the drawback? Well, when there are too many things all trying to play sound at the same time, many sounds simply don’t ever play and a massive space battle with a hundred capital ships all blowing each other into pieces doesn’t sound as noisy as it ought to. I’m calling it a win regardless. Having lots of big ships battling at once is my favorite thing.