r/phaser • u/giacapp_dev • 11h ago
show-off Shipped a Phaser 4 game on Android with Capacitor: what fixed our stutter on Mali GPUs
We just released Cat Rooftop Rush on Google Play, a runner made with Phaser 4.2 and packaged with Capacitor 8 for Android phones and Android TV. A few things we learned on the way, in case they save someone time:
- The stutter on Mali GPUs wasn't fill rate. Same fps at 1284x612 and 2265x1080, with any shader. In the Android WebView a single thread passes the WebGL commands to the driver, and a Chrome DevTools trace showed it busy 70-100% of the time.
- The cause was the batch buffer. Phaser 4 reserves a vertex buffer for 16,384 quads (about 1.8 MB) and rewrites it with bufferSubData on every batch, around twenty times per frame. Our guess is that the Mali driver copies the whole buffer each time. Lights made it worse, because lit and unlit objects use different shaders and so more batches.
- The fix is one line: batchSize: 512 in the game config. The thread went down to 25-60%, and High runs at 60 fps on a Huawei P30 Pro. Our real batches never exceed 112 quads, so nothing gets split. No change on an NVIDIA Shield or on desktop.
- Measure with the same scene every time. We compare runs on a still scene with a fixed seed, reading frame stats from adb and the command thread from the trace, so a change in fps means a change in the code.
Happy to answer questions. The art, if anyone asks, starts from generative AI tools and we assemble and fix it piece by piece.
Trailer: https://youtu.be/fFUhhWazwFo