Journal

Two bugs that were the whole story

A five-character fix the demuxer hid for days, a single wrong number that left a channel silent for two — and the build gate we wrote so we couldn't cheat our way past either.

Most of building the player was chasing two bugs that, between them, taught us the only two lessons that stuck.

The first lived in the video demuxer. To find a packet you scan for a start marker and read the byte after it; we read the marker instead. Every packet came back labelled as nothing, so the decoder configured itself with nothing and produced, faithfully, nothing — two whole tiers sitting silent while the logs scrolled past looking healthy. The fix was five characters. The post-mortem underneath it is nine words: the bug was reproducible all along. The all along is the part that hurts.

The second was a channel that went silent for two days. Zero audio frames decoded, zero audio errors logged — and zero errors is the worst line in the log, because it is the part that was supposed to notice telling you it didn’t. The cause was a single wrong number in a hand-typed table: a frame size off by 256 bytes. We caught it only because we were testing our own audio against our own fixtures and the numbers disagreed. We hadn’t caught it sooner because the tests were written against the same wrong number, and so reported green the whole time.

Both bugs had an easy way out, and it was always the same one: let the server peek at the bytes. We did not trust future versions of ourselves to keep saying no — so we made the build say it for us. There’s a script in our pipeline that fails the build if a single forbidden word shows up in the relay’s source. It has caught us three times since. Each time, we read the failure, said fair, and undid the change.

Next: where we are now — the engine we deleted, and the night the eye closed →

— Twiga team