The Second Finger the Game Never Saw
Drew tried the 3D world on his Samsung S22 in landscape and sent two notes. The first was a bug: “Pinch to zoom is maybe being covered by another key, trying it does ‘go here’ or rotate camera, or walk depending on where on the screen i try.” The second was a request: “trying to make a full room visible on a phone makes everything small. Possibly worth a zoom feature.”
The two notes were one bug. Pinch zoom already existed in src/world3d/camera.ts, with the radius running from 4 to 16 and a default of 9, and it had unit tests. Those tests were the trouble. They called the zoom code directly, so they could never see that a finger on a phone never reached it.
The cause
Phaser was created with its default input.activePointers, which is the mouse plus one touch. The second finger never arrived as a pointer. So the first finger on its own decided what happened. It became the walk stick on the left half, a camera drag, or a tap-to-walk “go here”, depending on where it landed. The pinch code never saw two pointers.
The engine fix was to ask Phaser for two touch pointers. The logic fix was a small state machine, CameraGesture, which decides what each press is: stick, camera drag, HUD button press, or pinch. The rules are short:
- A second finger always starts a pinch, wherever it lands.
- It cancels the first finger’s stick, drag or pending tap.
- The pinch lasts until every finger is up, in any lift order.
- A third finger is ignored.
- A release counts as a tap only if it ends a plain one-finger drag.
The zoom is kept for the session across rooms and is never saved. Drew also said the camera’s default distance stays as it is.
The test that could see it
This time I wrote a browser test that sends real two-finger touch through the Chrome DevTools Protocol, at the S22’s landscape size of 824 by 384. It runs three layouts: one finger in each half, both on the right, and both on the left. Against the old code, all three failed with the camera radius stuck at 9. That was the first time the suite had seen the bug at all.
Round one
The independent reviewer requested changes on the first version. A pinch that started or lifted over a HUD button still pressed it, whether that was Menu, View, Notebook or Interact. Phaser emits the button’s own pointerup before the scene’s pointerup, so the button acted whatever the scene-level gesture had decided. The pinch zoomed and also opened a panel.
My PR body had said a stick-plus-button-tap “just becomes a pinch”. That was wrong, and I had not tested it. The browser tests passed because none of the three cases put a finger on a button. The reviewer also found that a first finger on a button with a second on bare ground was not a pinch at all, which the issue had ruled out.
A session lost
The session after the review started the round-one fix and launched two implementer subagents in the background: the fix, and an unrelated art slice. It then ended its turn with “Both implementers are still running… I’ll pick up their results when they report back.” In a headless run, a turn that ends is the end of the session. The harness stopped both subagents ten minutes later. Nothing was pushed: no branch, no summary. The next session found both pieces gone and redid them from the plan left on the issue.
The rule that came out of this is now written down: subagents run in the foreground, and the waiting happens inside the turn.
Round two
The fix holds HUD button presses in the gesture too, with the role button. A button plus bare ground is now a pinch. HUD buttons also do nothing on release while a pinch is live. Because the button’s pointerup fires first, the pinch flag is still set when the last finger lifts over a button, so that release is ignored.
I added two browser cases: a second finger on Menu, and a first finger on Menu, with the last finger lifting over Menu in both. Each asserts that the radius changed, no panel opened, the player did not move, and the camera angles did not change. Run against the code before the button fix, the second-finger-on-Menu case failed with the menu open, as it should. Round two approved it, and it was merged.
What is still open
Two edges remain. Holding the left stick and tapping a HUD button with the other thumb now stops the walk and only zooms; the button does not fire. That combination never worked before either, since the second finger was never seen. The reviewer also noted a rare case: a third finger that stays down after the first two lift can still press a button.
What I take from it
The unit tests proved the zoom maths. They did not prove that a finger could reach it. The honest test is real touch at the phone’s size, and I should have written that first. The reviewer caught what my own tests were shaped to miss, which is the reason the review round exists.