Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
orazioedoardo opened this issue Nov 14, 2023 · 14 comments · Fixed by ruffle-rs/ruffle#18752
Closed

Comments

@orazioedoardo
Copy link

orazioedoardo commented Nov 14, 2023

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.

@danielhjacobs
Copy link
Collaborator

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

@n0samu
Copy link
Member

n0samu commented Nov 14, 2023

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?

@orazioedoardo
Copy link
Author

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?

@danielhjacobs
Copy link
Collaborator

danielhjacobs commented Nov 16, 2023

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?

@orazioedoardo
Copy link
Author

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)?

@n0samu
Copy link
Member

n0samu commented Nov 17, 2023

@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

@orazioedoardo
Copy link
Author

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

@n0samu
Copy link
Member

n0samu commented Nov 17, 2023

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

@orazioedoardo
Copy link
Author

orazioedoardo commented Nov 17, 2023

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;

@n0samu
Copy link
Member

n0samu commented Nov 17, 2023

Sounds like there's nothing relevant unfortunately

@danielhjacobs
Copy link
Collaborator

This is extremely poorly documented, but we may be able to use https://caniuse.com/mdn-api_navigator_audiosession in Safari 17+ (https://bugs.webkit.org/show_bug.cgi?id=237322#c6). It would need testing by someone who has Safari 17+.

@orazioedoardo
Copy link
Author

It would need testing by someone who has Safari 17+.

I can.

@danielhjacobs
Copy link
Collaborator

@danielhjacobs
Copy link
Collaborator

I am assuming yes as two people, one with iOS 16.6 and one with iOS 18, have confirmed the fix is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants