Closed Bug 1871764 Opened 2 years ago Closed 2 years ago

SharedArrayBuffer unavailable in "data:" and "file:///" origin.

Categories

(Core :: Web Audio, defect)

Firefox 120
defect

Tracking

()

RESOLVED DUPLICATE of bug 1871765

People

(Reporter: bugzil.la, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0

Steps to reproduce:

I try to write AudioWorkletProcessor working in "file://" origin. I tried to write application in local file and I cannot enable the SharedArrayBuffer which is needed for high performance AudioWorkletProcessor.

$micStream=await navigator.mediaDevices.getUserMedia({audio:true}); 
$micAudioCtx=new AudioContext();
$audioCtx=new AudioContext();
$micMS=$micAudioCtx.createMediaStreamSource($micStream);
$gainNode=$audioCtx.createGain();
$gainNode.connect($audioCtx.destination);
$micSampleRate=$micMS.context.sampleRate;
var $data=`
class RecorderProcessor extends AudioWorkletProcessor
{
   mem=null;
   constructor()
   {
      super();
      this.mem=new WebAssembly.Memory({initial: 4, maximum: 4, shared: true});
      this.port.postMessage(this.mem); // this line emits error!!!
   }

   process($i)
   {
       //...
   }
}
registerProcessor('VAProcessor', RecorderProcessor);`;
$data='data:text/javascript;base64,'+btoa($data);
await $micAudioCtx.audioWorklet.addModule($data);
$micRec=new AudioWorkletNode($micAudioCtx, 'VAProcessor');
$micRec.port.onmessage=handleSAB;


Actual results:

Firefox emits error that there is no COEP and COOP headers, **but there is no possibility to set these headers**.  


Expected results:

Firefox should permit "file:///" and "data:" origin (if created from the same JS code) and main «website» is loaded from file. The file:/// origin can be treated as trusted started by user manually. 

In file:/// origin there is no way to set COOP and COEP. There must be other mechanism to make SharedArrayBuffer available for "file:///" applications. 

The SharedArrayBuffer is must-have for AudioWorkletProcessors. There is no other stable solutions (postMessage causes reallocations and then errors during handling samples from microphone). 

Problems related to spectree should probably not prevent a user from running programs s/he has written.

The Bugbug bot thinks this bug should belong to the 'Core::Web Audio' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Web Audio
Product: Firefox → Core
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Duplicate of bug: 1871765
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.