WKWebView getUserMedia microphone gets muted in background

First, thank you for adding getUserMedia to WKWebview.

Now, I have a webrtc session with audio and video going both directions, problem is that when the app goes to background I can only hear the incoming audio on the iPhone side, but the mic audio is not being sent from the iPhone to the remote side.

Using the new iOS 15 API I can see that wkwebview.microphoneCaptureState becomes muted shortly after applicationDidEnterBackground (using wkwebview.setMicrophoneCaptureState to active doesn't help when in the background either).

I see this issue in iOS 15 beta 8 and also in iOS 14.7. If using the native mic capture with AVAudioSession then the mic continues to work in the background, so I background modes are good.

Is there some config I can set to continue having the mic working in the background?

Thank you

This is easily testable by using the following code in iOS and opening the same url (https://janus.conf.meetecho.com/videocalltest.html) in the desktop browser (tested with chrome), clicking Start, registering a name, and calling the other side.

let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
let webview = WKWebView(frame: .zero, configuration: config)
webview.load(URLRequest(url: URL(string: "https://janus.conf.meetecho.com/videocalltest.html")!))

Hi @lemor_mish - Thanks for reporting this! Have you been able to cache microphone permissions for each user? We wrote a demo app to record audio and each time the user gets the microphone permissions prompt.

Mic background still doesn't work for me with iOS 15.1 (beta 3). I noticed that "Mic mode" in the control center changes from "Standard" to "Off when the app goes to the background and I'm not able to turn it back to standard (unless returning the app to the foreground).

Any news or workarounds here? Our app has a similar use case of using the microphone inside of a webview with a webrtc session, and we're observing the same issue where we can hear audio from other users, but the mic does not work (does not send any audio) once the app is minimized.

Having the same issue. When APP is in foreground OR in background everything is working fine. We get Microphone output. When APP is killed (manually or by operating system) and we connect to the remote side (by tapping on the notification) - no microphone :/

Did you find any solution?

is there any way or any voice recorder app that works in the background for IOS 15?

I am facing same problem. What i have found is that when my app using getUserMedia in WKWebview is in background and i use different app using audio (for example audio/video player and play media) then after media is finished, i can hear again audio from my app BUT also my mic is working in background. What is different to getUserMedia in Safari is that when active mic in Safari is in background, i can see orange bar. In my app i can see only orange dot even if i get it working with the other app as mentioned before.

This appears to be working for me now. I'm using iOS 17.5.1. I had to add 'audio' to the UIBackgroundModes audio setting in Info.plist and then background audio would work the same as Safari. Without this setting it behaved as described, audio would cutout as soon at the app goes in the background.

WKWebView getUserMedia microphone gets muted in background
 
 
Q