ruffle-rs.github.io icon indicating copy to clipboard operation
ruffle-rs.github.io copied to clipboard

Audio not working on Safari iOS/iPad OS when mute is switched on

Open orazioedoardo opened this issue 1 year ago • 10 comments

For some odd reason, when the mute switch is on, Safari does not play sound when reproduced through Web Audio, though it does when reproduced through HTML. Looks like there are workarounds to enable audio playback even when muted, if you can consider this something worth addressing.

orazioedoardo avatar Nov 14 '23 19:11 orazioedoardo

This is basically a Safari bug (Web Audio plays on the ringer category for some reason, while HTML5 will play on the media category). It appears like there is a workaround, but it's so horrid looking I'm not sure it's a good idea: https://stackoverflow.com/a/46839941

danielhjacobs avatar Nov 14 '23 20:11 danielhjacobs

We do actually have a workaround in place for this: https://github.com/ruffle-rs/ruffle/blob/master/web/packages/core/src/ruffle-player.ts#L1735 What device is this not working for? And what is the value of navigator.maxTouchPoints?

n0samu avatar Nov 14 '23 21:11 n0samu

What device is this not working for?

iPhone / iPad, version 17.1.1 (latest). Sound works if I keep another tab open with a paused HTML video. Yeah, I’m not joking. Also works if other tab is playing sound but then you hear both.

And what is the value of navigator.maxTouchPoints?

orazioedoardo avatar Nov 14 '23 21:11 orazioedoardo

That workaround does seem to have a catch: "console.warn(Failed to play dummy sound: ${err});". Are you able to access the console on your iPad to see if that logs?

danielhjacobs avatar Nov 16 '23 22:11 danielhjacobs

Are you able to access the console on your iPad to see if that logs?

I would need to attach it to Safari on a Mac, which I do not have on hand now. Perhaps I could host a modified version of the site that prints console messages to the screen (if you tell me what to change)?

orazioedoardo avatar Nov 17 '23 07:11 orazioedoardo

@orazioedoardo You can use Eruda or the iSource Browser from the app store to see console messages without attaching to a Mac. To use Eruda, you need to create a shortcut in the Shortcuts app that can be used in Safari:

import("https://cdn.jsdelivr.net/npm/eruda").then(() => eruda.init());
completion();

image

n0samu avatar Nov 17 '23 19:11 n0samu

Thanks, the shortcut works but the console does not display any message. Actually, it doesn’t seem to show messages on any site.

orazioedoardo avatar Nov 17 '23 21:11 orazioedoardo

I experienced the same thing but I thought it was because of my outdated iOS version 😦 Can you try iSource Browser?

n0samu avatar Nov 17 '23 21:11 n0samu

I managed to load Eruda “properly” by pasting the javascript uri in the address bar. After I load a game and press play there are some warnings about fonts and unimplemented functions, depending on the file. The following warnings appear no matter the SWF file, not sure if relevant.

WARN core/src/stub.rs:126 Encountered stub: AVM2 flash.display.MovieClip.goto() with SWF 9 movie
WARN  mpa: invalid main_data_begin, underflow by 91 bytes log.target = "symphonia_bundle_mp3::layer3";
log.module_path = "symphonia_bundle_mp3::layer3";
log.file = "/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-bundle-mp3-0.5.3/src/layer3/mod.rs";
log.line = 86;

orazioedoardo avatar Nov 17 '23 22:11 orazioedoardo

Sounds like there's nothing relevant unfortunately

n0samu avatar Nov 17 '23 22:11 n0samu