UYLLII

Blog › Engineering

Engineering

Bugs only a real phone finds: pixel ratios, ghost clicks and invisible lag

By David3 min read
Minesweeper Rogue feature graphic

My games are web games wrapped for Android, which means almost all testing can happen in a desktop browser: fast, automated, headless. That's great, and it's a trap. Here are the bugs that every automated test passed and a phone found in minutes.

Device pixel ratio rounding

In Minesweeper Rogue, dragging a wraparound board barely moved it on my phone. The layout rounded sizes to whole device pixels, and at my phone's pixel ratio of 2.625 a 7-wide board came out 0.98 pixels too wide, enough to break the wrap. The desktop test ran at a ratio of 2.0, where the numbers happened to fit.

Fix: round down. Check: the test now runs at 411×867 with a 2.625 ratio.

Synthesised clicks

Same game. Tapping into a tunnel opened an "Enter?" sheet that flashed and closed at once. After a touch, the browser synthesises a click, and that click landed on the new sheet's backdrop, which closes the sheet. A desktop mouse doesn't do that.

Fix: dialogs swallow clicks for 400 ms after opening. Check: the test uses an emulated touchscreen with real touch events.

The same family of bug produced the much nastier closing-an-ad-taps-the-game problem.

Lag you can't screenshot

Emberfall's second chapter was visibly laggy on my phone and perfect on desktop. Measured at phone resolution, frames took 88 ms. Screenshots looked identical, and the bot that played the story finished fine.

Check: a frame-time measurement at phone resolution. Bots and screenshots can't see lag.

Flicker that only appears at low frame rates

In Genesis, a board started flickering about three times a second, right after I'd made it more battery-friendly. The refresh code set canvas.width on every update, and writing canvas.width clears the canvas, even to the same value. While the board repainted every frame, the blank was never visible. Once it repainted less often, there was a blank frame up to 33 ms long.

Check: the UI tour now fails if a canvas is cleared while the screen is idle.

Buttons that do nothing

Also in Genesis: the Buy and Auto buttons on a new tab did nothing. Clicks were handled by one delegated listener, with a list of selectors it recognised, and the new buttons' attributes weren't on the list. The page rendered perfectly.

Check: an "orphans" test fails on any handler attribute that the click list doesn't know.

Running out of graphics memory

In Tavern Heroes, tapping the Blacksmith quickly about 60 times made pictures go blank. Each tap rebuilt the whole gear tab (about 100 images) and drew 19 hero portraits onto new canvases. 13 ms on desktop. On a phone, it ran out of graphics memory.

Fix: only the sheet redraws, and portraits are shared. Check: a test counts how many elements and canvases one tap creates.

Rotation

Tavern Heroes turned sideways with the phone. It's designed for portrait, but its build script had been copied from a game that supported landscape. A desktop browser has no rotation.

What I do now