Skip to content

Smoother board on low-end tablets (steady 30 fps + adaptive sharpness) - #75

Merged
kevsaj merged 1 commit into
mainfrom
smooth-low-end
Nov 21, 2026
Merged

kevsaj merged 1 commit into
mainfrom
smooth-low-end

Conversation

@kevsaj

@kevsaj kevsaj commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Requested by Kevin · project thread

Why

On a TCL tablet (Android 15, 4 GB) the game feels choppy unless Reduce motion is on; a Galaxy S26+ is smooth. Every animation stays. The board just draws in a way a weaker device can keep up with.

What changed

  1. Steady frame timing. Phaser's limit was exactly 30 fps. It draws once 1000/limit ms have passed, counted in whole screen refreshes, so two 60 Hz refreshes (or three at 90 Hz, four at 120 Hz) often came to a hair under 33.3 ms and it waited one more refresh. Moves stepped unevenly between 30 and 20 fps. With the limit at 33 (target still 30), the board draws a steady 30.
  2. Adaptive board sharpness (src/board/quality.ts). Since Play Games on PC: landscape window, interface scaled to fit, sharp board #73 the board canvas is drawn at full devicePixelRatio, which is a lot of pixels to redraw 30 times a second on a big tablet with an entry-level GPU.
    • Pixel budget: 0.8 MP and ratio ≤ 2 on devices reporting ≤ 4 GB deviceMemory or ≤ 4 cores, and 4 MP otherwise. Phones barely notice. Big low-end tablets drop to about 1.4×.
    • Frame watchdog: if the board stays under 24 fps for two 2-second windows in a row, sharpness drops by ×0.8 and redraws at the new size. It never goes below 1 canvas pixel per CSS pixel, which was the look before Play Games on PC: landscape window, interface scaled to fit, sharp board #73. Pauses (app in background) don't count, and the first 2.5 s of a floor are skipped.
    • The level it settles on is saved (loopbot.boardScale), so the next floor starts there. Each app launch tries one step sharper again, so a one-off slow moment doesn't make the board soft for good.
  3. Plus glow eyes now animate --bot-eye on the eye shapes themselves instead of on <html>. Before, a glowing eye restyled every element on the page every frame. The title bot's antenna keeps its blink as well as the glow.

Testing

  • tsc -b clean, vitest run: 2,738 tests pass (new quality.test.ts: tier detection, budget, step-down memory, watchdog ignores single dips and pauses)
  • Tablet viewport (800×1280 @2x) in Chromium: the board renders correctly at the reduced budget. With CPU throttled 20×, the watchdog stepped 1.42 → 1.14 → 1.0 within 10 s and then held.
  • Not yet tried on the TCL tablet itself. Rides with the next build.

Generated by Claude Code

…l budget

- Phaser fps limit 33 (target 30): with exactly 30, two 60 Hz refreshes often summed to just
  under 33.3 ms, so frames stepped unevenly between 30 and 20 fps (visible stutter on moves)
- src/board/quality.ts: board pixel budget (0.8 MP and ratio <= 2 on devices with <= 4 GB or
  <= 4 cores, 4 MP otherwise) plus a frame watchdog that steps sharpness down when the board
  stays under 24 fps; never below 1 canvas pixel per CSS pixel, remembered across floors, one
  step sharper retried each launch
- Plus glow eyes animate --bot-eye on the eye shapes, not on <html> (no whole-page restyle per frame)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HnC1czXPoK7Wh1ccNHkt8t
@kevsaj kevsaj self-assigned this Nov 21, 2026
@kevsaj
kevsaj merged commit c0126c3 into main Nov 21, 2026
3 checks passed
@kevsaj
kevsaj deleted the smooth-low-end branch November 21, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants