Cookie Crumble froze at level 10 and my profiler showed nothing
Forty-six games in the arcade, each one its own folder, all sharing a handful of libraries. July was a month of going along the shelf rather than building anything new.
The freeze at level 10
Cookie Crumble froze when you reached level 10. Reliably, on the milestone, every time.
I profiled the JavaScript heap and found nothing. No leak, no runaway allocation, no long task I could pin it on. Which is the kind of result that makes you start doubting the bug report.
The cause was a cutscene. Hitting the milestone loaded a multi-megabyte PNG, and decoding it blocked the main thread while image memory spiked. None of that is a JavaScript allocation, so it doesn’t show up in a JS heap snapshot — it’s image and GPU memory, and the tool I reached for first is specifically blind to it.
Converting the art to WebP took Cookie Crumble’s heavy assets from 40MB to 3.2MB, about 92% off, and the title video from 21.7MB to 1.95MB. The freeze went with it.
So: when a profiler shows nothing and the bug is still reproducible, the profiler is answering a different question than the one you asked.
A boss that turned into a cookie
The second Cookie Crumble bug is neater. During a boss fight, certain reshuffles left the boss sprite drawing over a perfectly ordinary, swappable cookie.
Three separate code paths handled reshuffling and all three called the board initialiser, which regenerates every cell from scratch. That wiped the flags marking which cell was the boss. The boss’s position and health lived somewhere else and survived happily. So the game still believed there was a boss, drew it in the right place, and the cell underneath had become a normal piece.
The fix wasn’t to patch the three paths. There were two different bits of code that stamped a boss onto the board and they were allowed to disagree. Now there’s one and both callers go through it. The divergence that caused the bug was the same divergence that made the bug possible to write.
Cookie Crumble also came apart into real modules — board, levels, storage, economy, goals — each pure, each with characterisation tests written before the extraction so I could prove the behaviour didn’t change. 174 tests and coverage thresholds that fail the build if they slip.
Hardening forty-six games at once
The games run in iframes and talk to the parent page for auth. Four of them had inline listeners accepting messages without checking who sent them. The login and logout calls were posting to any origin rather than ours. There was an open redirect in the auth callback.
None of those had been exploited, and all of them are trivial to fix while you’re looking and unpleasant to explain afterwards. Security headers go out on every static response across the whole arcade now.
Also: local storage access is wrapped in try/catch in three games that had been crashing outright in private browsing mode. That’s a fun one — it works perfectly for everyone except people browsing privately, who get a blank screen and no reason.
Two shared helpers, and knowing when to stop
Two bits of maths were duplicated across the arcade: fitting a grid to a canvas, and turning a pointer event into a game coordinate. The second was copy-pasted across about 25 files.
Both became shared helpers. I verified the grid one against over 450,000 generated canvas sizes with zero mismatches before touching a single game with it.
Then I migrated four of the fourteen grid games and stopped. The other ten have layout quirks that genuinely differ, and forcing them through one helper would give me a helper with ten special cases, which is worse than the duplication it replaces. The pointer helper is in the library and no game uses it yet. Shared code is only cheaper if the things sharing it want the same behaviour.
Two things I got wrong
I shipped a bug in the structured data for the game pages. The HTML attribute escaper got used inside a JSON block, so entities never got decoded before parsing, and Freecell’s tagline went out to search engines with a raw HTML entity sitting in the middle of the word “player’s.” An escaper is only correct for the context it was written for, and JSON inside HTML is two contexts.
And a debt audit I ran had to be walked back twice. A claimed touch-input bug in two card games turned out not to exist. A list of seven safe rendering swaps was actually four, because three of them appended to an existing path and would have broken if anything reset it. I checked the claims because they were cheap to check, and both corrections came out of that. If I hadn’t, I’d have fixed a bug that wasn’t there and broken three things that worked.
Elsewhere: 45 of the 46 games got real gameplay screenshots from a new automated capture harness, and every game description was rewritten for readability — the corpus went from a grade 12.6 reading level to 5.9, which matters for a site aimed partly at kids. Four games that existed but weren’t listed anywhere got added to the catalog.
— Bruno