Bug 167788

Summary: WKWebView seems to ignore AVAudioSession category settings in iOS app
Product: WebKit Reporter: Victor Wang <wangshengjia01>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: distinctdan, eric.carlson, haimomesi, jer.noble, mary, roger, webkit-bug-importer, youennf, znelson
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: iPhone / iPad   
OS: iOS 10   
Attachments:
Description Flags
A simple project which show the problem of WKWebView and AVAudioSession none

Description Victor Wang 2017-02-03 02:57:33 PST
Created attachment 300516 [details]
A simple project which show the problem of WKWebView and AVAudioSession

By setting app's AVAudioSession's category to `AVAudioSessionCategoryPlayback` with option `mixWithOthers`, will make sounds from video in UIWebView be mixed with third party background music (such as Spotify). It do not work at all once switch to WKWebView.

Tested on Xcode 8.2.1, iOS 10.2.1

Many thanks.
Comment 1 Radar WebKit Bug Importer 2017-02-04 00:17:35 PST
<rdar://problem/30362584>
Comment 2 distinctdan 2019-11-22 15:50:47 PST
This bug is annoying some of my app's users also because the webview ignores the hardware mute switch. Is there any hope of getting this fixed, or at least providing a property on wkwebview to set its audio session category?
Comment 3 zn 2020-06-09 00:38:54 PDT
We're unable to mix audio from WkWebView and AVPlayer as the webview audio takes precedence and ducks everything else. I really don't understand why WkWebView is so restrictive when it comes to media, i.e. getUserMedia and this audio issue.
Comment 4 haimomesi 2021-08-29 14:33:55 PDT
getUserMedia works under WKWebView, but without any AudioSession manipulation.

That blocks as from using CallKit or applying any audio routing, modes and categories. 

WebKit's setSinkId and enumerateDevices are still experimental so no impl for WebKit.

I hope these missing features will be developed soon and at least WKWebView's AudioSession will be added to its API.
Comment 5 Mary 2022-11-10 08:36:52 PST
It's been 5 years and this still has not been addressed. Our users continue to complain about this issue. Someone please prioritize a fix.