r/expo • u/Worldly-Skirt-4811 • 11h ago
Built a 3D offline + online Chess app in Expo, Three.js, and Supabase — how I handled budget Android FPS & server-authoritative clocks



Hey r/expo,
I'm a solo dev and just pushed v1.17.0 of FreeChess to Google Play (currently 100% crash-free across 300+ installs, with budget devices like Samsung Galaxy A14 and A06 as my top active phones).
A few architecture choices that worked really well in Expo:
- Keeping Three.js smooth on budget Android GPUs:
• Dark minimal shaders/lighting to avoid heavy shadow maps, plus an instant 2D toggle mid-game if players want zero-overhead bullet/rapid play.
• Local offline engine (5 bots Novice→Master, 100 lessons, move hints, and post-game accuracy/blunder review) so offline play needs zero network or account.
2. Server-authoritative moves & clocks (Supabase Free Nano tier):
• Moves go through a Supabase Edge Function that replays from initial_fen, validates legality, and commits via a Postgres RPC under a row lock.
• Clocks are calculated server-side (now() - turn_started_at) with a 1500ms lag allowance—client clocks are display-only.
• Supabase Realtime Broadcast is strictly a lightweight {version, status, turn} doorbell that triggers a snapshot fetch (with a 2s poll fallback), keeping Postgres CPU around ~3%.
3. Handling budget Android background kills:
• 5s heartbeats, 12s disconnected indicator, and a 60s continuous-absence grace window before abandonment can be claimed (verified server-side so two backgrounded phones can't race back to farm wins).
Play Store link (Android):
Happy to share more on the Expo + Three.js setup or Supabase RPC design—and would love honest feedback on how the 3D board feels on your device!




