'whats the current state of navigator.mediaDevices.getUserMedia for audio on IOS

I know this has been asked before but those answers are a little dated and Apple keeps changing things. I have an PWA app that runs fine on mac (safari , chrome),windows (Chrome, edge), android (chrome, edge). But does not work on ios safari or chrome

I am testing on an IPad running ios 15.4

  • not sure which of navigator.mediaDevices.GetUserMedia, navigator.getUserMedia, navigator.webKitGetUSerMedia... is supposed to work
  • do I need to be served from HTTPS?
  • does audioWorklet work on any IOS browser (I can work without this, but prefer to use it)


Solution 1:[1]

OK well I now know a lot more about this so will add my own answer. This is microphone input

AudioWorklet works on current safari on IOS but there are many oddities to be aware of

  • console.log from the worklet is not reported by web inspector. So I ended up writing log messages to the worklet's messageport and logging them in the code that started the worklet

  • many audio examples do a lot of juggling to try to locate the 'getUserMedia' function. Safari will only work if is called like this

    navigator.mediaDevices.getUserMedia

If you do

getUserMedia = navigator.mediaDevices.getUserMEdia || .... || .... ;
getUserMedia(....)

Safari will throw complaining that that function must be called a child of mediaDevices

  • The size of the inputs array spontaneously changes after 100 or so samples for no apparent reason. Starts out with inputs[0][0] and inputs[0][1]. Ie stereo input left and right. After 100 or so samples it suddenly only has inputs[0][0], ie mono.

  • the reporting of exceptions in the worklet in non existant, everything just silently fails.

  • async await code does not try catch properly

Ie this code

async foo(){
      try{
          ..
          await xxx();
          ...
      catch(e){
          log(e);
      }
 }

does not catch an exception thrown by xxx

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pm100