GoogleChromeLabs / audioworklet-polyfill

🔊 Polyfill AudioWorklet using the legacy ScriptProcessor API.
https://googlechromelabs.github.io/audioworklet-polyfill/
Apache License 2.0
195 stars 20 forks source link

audioWorklet is not defined - Chrome Android 73 #19

Closed JohnWeisz closed 4 years ago

JohnWeisz commented 5 years ago

This is a strange one I picked up today, it seems (my) Chrome Android 73 implementation does define AudioWorkletNode, but not AudioContext.audioWorklet, as if it was an incomplete implementation. However, this polyfill only checks for AudioWorkletNode, and thus there is a runtime error.

The solution I came up was the following, on https://github.com/GoogleChromeLabs/audioworklet-polyfill/blob/master/src/index.js#L22

if (typeof AudioWorkletNode !== 'function' || !("audioWorker" in AudioContext.prototype)) {
JohnWeisz commented 5 years ago

Upon further investigation it seems this issue was in fact not originating from an incomplete implementation, but from using a non-secure origin instead (developing over network, and AudioWorklet requires a secure context). The error wasn't useful, the API was simply not made available.

Regardless, I'll leave the PR open in case it's deemed useful.

AndreVanKammen commented 4 years ago

Thank you, I ran into this as well. I hate it when they magically make stuff disappear on insecure origins, ran into navigator.requestMIDIAccess disappearing as well. This is not very helpful for new developers since all is well on localhost and as soon as you try to put it online nothing works anymore because of this kind of BS. This is NOT how you fix security issues because they can still make those malicious sites under https.