Investigate, reproduce and fix game bugs methodically instead of guessing. Gather evidence (the viewer's preview state and console, server logs), reproduce with exact steps and seeds, isolate with logging, debug overlays, state dumps, git bisect and binary search, find the root cause, fix it, prove the fix with a test, and report clearly. Includes a symptom → likely cause table for common game ...
Download skill (.zip) Files on GitHubGame bug diagnostics
Never claim a fix without reproducing the bug first and seeing it gone after.
1. Preserve and gather (before touching anything)
- The viewer’s report is evidence:
look_at_preview(current state),read_preview_console(errors) before refreshing, which would destroy that state. Server logs and endpoint responses for anything server-side. - Ask only what you can’t find out: what they did, what they expected, device or browser, how often.
- Note the version (git commit) where it happens.
2. Reproduce
Write exact steps. Make it deterministic: seed randomness (?seed=), use the debug handle to jump to the state
(__game.scenes.switch('play', { level: 3 })), and a fixed viewport. If it’s intermittent, loop the steps
(playwright-game-testing) 20 times and count. Can’t reproduce → collect more evidence (logging below), don’t guess-fix.
3. Isolate
- Log the right things at the moment it goes wrong: state, positions, velocities, dt, the input that frame. Throttle logs (once per event, not per frame).
- Debug overlay (toggle with a key): hitboxes, velocities, state names, FPS, entity count.
- Binary search: disable half the systems, which half still breaks? Comment out until the bug disappears.
- When did it start?
git bisect start; git bisect bad; git bisect good <old-commit>, then test each step. - Check assumptions with asserts:
console.assert(this.hp >= 0, "hp negative", this).
4. Common symptoms
| Symptom | Usual cause |
|---|---|
| Falls through floors / walls, sometimes | Tunneling at high speed or after a dt spike (tab switch, pause) |
| Faster on some screens | Movement per frame instead of × dt (120/144 Hz monitors) |
| Key stuck down | No release on blur / visibilitychange |
| One tap does two things | Same input read by two states in one step; edge not cleared |
| Breaks after restart | State not reset; listeners added again; old timers still running |
| Softlock (can’t continue) | A state with no exit when a condition is never met (all enemies dead off-screen, timer paused) |
| Works locally, broken on itch.io / Bash | Absolute paths, wrong file case, blocked storage, alert, CDN blocked |
| No sound on iPhone | AudioContext not resumed in a touch handler |
| Blank screen | A JS error on load (console), WebGL context failed, a missing asset with no error handling |
| Gets slow over time | Leak (game-memory-leak-detection) or growing arrays |
| Random crash “undefined” | Entity removed while still referenced (target died), array changed during a loop |
5. Fix the root cause
Fix why it happens, not the symptom (don’t add if (y > 1000) y = 0). Keep the fix small. If the code needs restructuring,
fix first, refactor after (game-refactoring).
6. Prove it
Run the same reproduction: the bug is gone and nearby behavior still works (game-regression-testing). Add a test (logic unit test or playtest step) so it can’t come back. Remove temporary logging.
7. Report
“Fixed: falling through platforms after pausing mid-jump. Cause: resuming produced a 2 s dt; the player moved past the
platform in one step. Fix: cap dt at 0.25 s and substep movement (src/core/loop.js:14). Checked: 20/20 repro runs pass;
regression check clean.”