-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Work when AudioContext is not supported #23290
Comments
Are there browsers out there that don't support |
Thank you for looking into this. Yes, there are browsers out there that do not support AudioContext or have it disabled by default. The user is not disabling it in these situations, and with Android Tor, users cannot access about:config to reenable it (if it would even be there). Browsers like Tor and Brave disable features for security, privacy, and rarely to also hinder hidden bitcoin miners (which steals compute). It is not reasonable to assume an optional API feature exists, that is why modern browser APIs started to be designed with easy feature detection. I remember the hellscape of using browser detection and it not being reliable. There is at least one widely used browser, which the presented assumption does not hold, causing no graceful fallback but instead crashing. I was hoping emscripten, frameworks, and mobile game engines, could fix this bug because it effects many of your down stream developers and users. These sites should just work without audio. |
Can you point to any documentation about the optional nature of |
I think it might be reasonable to support this as an option. (An option, since doing it by default would add too much code size for users that don't need it, and also some users might not want it - e.g. an audio mixer app would prefer to crash than silently not work.) We do have something similar for other WebAPIs, "headless mode":
Those do not check if the feature exists already, though, but they do show how to fake an API from JS. Something similar could be done from JS for AudioContext. That would take some work, though, and I don't see an existing project that has that among the links here. But I think it would make sense to welcome a contribution that looked like
|
I think OP is asking for this by default, since its unlikely that app developers will go out of their way to support Tor browser explicitly the hope is that emscripten (by default) will just work in absence of AudioContext. I'm not sure offering a optional polyfill is any better than that what folks can do today with |
Boring Tor info:
@sbc100 I want to be helpful, but I cannot spend more time on this, the following is just the obvious, and I do not have time to edit it better. I mean no offense anywhere in it. I feel you, that the web has rough edges to navigate for browsers, frameworks, websites, and users. Since emscripten is the main framework to compile non-web codebases to the web, fixes to and safeguards in emscripten save thousands of man hours from your downstream devs and users. It is commendable what emscripten has already accomplished in cross-platform compatibility. The web strives to have graceful fallbacks, so it can be beneficial to more people. Major-Browsers disable standard APIs that are a security risk. So do Minor-Browsers! Many browsers have intentionally not supported, partly or wholly, AudioContext over the years, including Tor, LibreWolf, and Brave (partly & may eventually block in private-mode: brave/brave-browser#16185). Mozilla-Firefox making 86% of its revenue in deals for tracking user information, shows their conflict of interest, but they do keep a negative list of APIs that are too extreme even for them: https://mozilla.github.io/standards-positions . So what these other browsers are doing is not out of the ordinary, it just is not being done by the Oligopoly. Browsers are pragmatically required to be different then the standards, because most (and popular) websites refuse to follow the standards, like the "Do Not Track" feature. This has always been the case for the web. w3.org/TR/webaudio-1.0 is only a W3C "recommendation" and no one fully follows the standard (see: https://wpt.fyi/results/webaudio?label=master&label=stable&aligned).
AudioContext working is not required any more than Tracking Vulnerabilities:
|
The the record I believe "recommendation" is the highest level in the W3C, its just the term they used for a standard that is complete, and there is no further step after that. It was pointed out to be the Brave has a way to disable in the fingerprinting without disabling the API: https://fingerprint.com/blog/audio-fingerprinting/#brave. Specifically they have 3 levels the most strict of which is: The sound wave is replaced with a pseudo-random sequence. This seems like a good approach that doesn't break websites. |
I would strongly object to a change in default here, I'm afraid. As I mentioned before, some apps are audio-focused, like a sound mixer. For them to claim to work when they are silent/broken would be a serious regression for them. Even if most apps could tolerate silence instead of audio, that needs to be decided by the developer of the app. In other words, yes, feature detection makes sense, but only the app can decide what the proper response is to the lack of a feature, not Emscripten. (And a specific way an app can do this, e.g. when getting Otherwise I agree with all the rest here. There are definitely valid reasons to want this, and an easy way to do this for all Emscripten users would be good to have. |
Many online games use emscripten to run in the browser, but most will crash if AudioContext is not supported.
This includes most Unity and SDL games.
These crashes are preventable if emscripten would have audio playback be a no-op when AudioContext is not supported (and still init). For programs/emscripten using AudioContext for compute, a shim/polyfill of either AudioContext or OfflineAudioContext would work.
Example rust shim: https://crates.io/crates/web-audio-api
Example node.js shim: https://github.com/ircam-ismm/node-web-audio-api
Example SDL reproduce error:
Could not initialize SDL2, No audio context available
DustinBrett/daedalOS#500
Example Unity reproduce error:
Web Audio API is not supported in this browser
https://purejamgames.itch.io/artificer
The easiest way to test this is to use the Tor browser or in
about:config
setdom.webaudio.enabled
to false.This is NOT a crash you can expect every downstream Dev to manually fix.
The text was updated successfully, but these errors were encountered: