Performance notes

Making Mobile Game Audio More Reliable

By 5 min read

Last updated

Why the first tap can be silent

Desktop testing made the Buy and Sell sounds appear instant, but some phones behaved differently. Mobile browsers may delay media loading, suspend audio until a user gesture, or limit how many sound objects can play at the same time. A sound file existing on the server does not guarantee that the first interaction will be audible.

The checkout sound was easier to hear because it played later in the session, after the browser had already received several user gestures and had more time to load the file. That difference helped identify the problem as playback readiness rather than missing purchase logic.

Preload early, unlock honestly

The current approach requests the small audio files early and also prepares them on the first pointer, touch, or keyboard interaction. Preloading is best effort: the game still assumes a mobile browser may refuse to decode audio until a permitted gesture occurs.

Buy and Sell use a small pool of audio elements. Rapid clicks rotate through the pool instead of repeatedly rewinding one element that may still be playing. The game action is never blocked while waiting for audio; cart accuracy has priority over sound.

Serving assets from R2

Images and audio are served from a dedicated asset host backed by Cloudflare R2. Keeping stable paths lets the game use the same asset URLs in development and production through one configurable base URL. Version query strings provide a simple way to invalidate an old cached asset after a replacement.

Small effects are intentionally short. A long, high-bitrate sound increases the chance that the first interaction arrives before decoding is complete. The goal is immediate feedback, not a soundtrack download.

What I verify on a real phone

Audio testing must include a fresh private tab because a warm cache can hide first-visit delays. I check the first Buy, several rapid purchases, the first Sell, silent mode behavior, Bluetooth output, and a return visit. I also confirm that refusing or delaying sound never prevents the visible balance and quantity from updating.

There is no universal way for a website to override a device's silent mode or browser media policy. The interface therefore provides visual money-change feedback as the reliable baseline, with sound as an enhancement.

Continue reading

Browse all articles