Bug 226620 - Microphone stopped/paused when application goes to background
Summary: Microphone stopped/paused when application goes to background
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Other
Hardware: iPhone / iPad iOS 14
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2021-06-03 18:38 PDT by dharjanto
Modified: 2022-06-13 22:45 PDT (History)
6 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description dharjanto 2021-06-03 18:38:39 PDT
While on a voice call from web application using WkWebView, if the application went to background or pressed power button, the microphone stopped transmitting voice. The audio from the other peers continued to play but eventually stopped playing at all. Adding Background Modes capabilities as described here doesn't help at all:
We tried passing alwaysRunsAtForegroundPriority option when creating WKWebView, but using this option is considered as Private API according to Apple.

Is there a way to keep the microphone to continue transmitting the voice and playing peers audio? Thank you.
Comment 1 Radar WebKit Bug Importer 2021-06-10 18:39:17 PDT
Comment 2 nicolas.gerlach 2022-03-23 02:33:30 PDT
I'm having the same issue with a webapp in Safari on Mac (BigSur / Monterey).

Safari microhone capture via getUserMedia does only work when the Safari window is visible on the screen (1px visible is sufficient). Whenever Safari is moved to the background the microphone stops transmitting sound, as if it was muted by a hardware button. For the web-application this is not transparent afaik.

This behaviour is especially inconvenient for multi user web-apps using webrtc, where microphone input can be used together with screen sharing (getDisplayMedia). Users usually assume that they can be heared when sharing their entire screen, even if safari is not in the foreground / visible. It feels inconsistent to on the one hand allow screen sharing when the safari window is not visible, but on the other hand block microphone transmission.

Can someone clarify if this behaviour is intentional and if there is a way to resolve this via settings or something else?

@dharjanto Were you able to resolve this?
Comment 3 youenn fablet 2022-03-23 03:18:47 PDT
It is not expected that audio tracks be muted in Safari on Mac.
https://webrtc.github.io/samples/src/content/peerconnection/pc1/ continues to play audio for me when Safari is in the background.
Note that, when being backgrounded, silent WebAudio used to be suspended, we recently fixed this issue.

@Nicolas, can you validate what the exact issue is? If that is still not working, can you file a new bug with as much input as possible?

@dharjanto, for WKWebView, muting is happening on iOS in case UIBackgroundModes (https://developer.apple.com/documentation/bundleresources/information_property_list/uibackgroundmodes) does not contain "audio".
Can you try that?

Closing this bug as behaving correctly, for now.
Feel free to reopen as needed.