Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

It looks like this no longer works in Safari or any browser on iOS. It hangs on load because the files `laugh.wav`, `dragon_death.wav`, and `jorge.wav` are sent with no `Content-Length` header. For some reason, Webkit (iOS and Safari's web engine) does not like this for sound files. These files never load, and `pendingStuffToLoad` in the `loadSound(path)` function in `gamelib.js` never reaches 0. For audio files, Safari seems to send a request with a `Range: bytes=0-1` header, and then sends it again with a`Range: bytes=0-whatever-content-length-was-from-previous-request`. But when a file is gzip compressed, the `Content-Length` isn't given when the `Range` header is present in the request (at least, not for itch's Cloudflare R2 bucket).

I'm not sure what the best fix would be here. Maybe make all the sound effects MP3 or OGG files? Those formats are already compressed, so `Content-Length` would always be available to Safari. Those 3 wav files above happen to be the three biggest wav files that try to load. The cut off seems to be 50 KB since win.wav (46 KB) loads, but jorge.wav (62 KB), doesn't. I observed that Cloudflare Pages does not have this problem (I rehosted it for my own private use). Perhaps itch needs to re-examine their R2 bucket upload settings? Maybe they can ensure that WAV files never get gzipped.

I notice also that for MP3 files, if a server doesn't provide a `Content-Length` header, Safari just plays it anyway. For instance, if an MP3 in Safari is sent with `Transfer-Encoding: chunked` (notice I didn't say `Content-Encoding`), instead of showing you a little playback bar where you can jump back and forth in the playback, it shows a "Live Broadcast" bar and only the pause button is available.

What a whacky browser. You can't escape it on iOS either. Chrome and Firefox on iOS are both forced to use Webkit under the hood, so you literally cannot play it on any iOS device anymore which is very sad.