| Summary: | Play h5 audio element in wkwebview will report error: Required client entitlement is missing | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | pengyong <pasoul.peng> |
| Component: | Media | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Major | CC: | bfulgham, jer.noble, pvollan, webkit-bug-importer |
| Priority: | P2 | Keywords: | HTML5, InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | iPhone / iPad | ||
| OS: | iOS 14 | ||
What is h5 audio? Can you please elaborate steps to reproduce? 1.There is an audio element and a button button in my HTML file. Click the button to play audio.
```
<body>
<button onclick="handleClick()">PLAY</button>
<audio id="audio" src="https://ac-dev.oss-cn-hangzhou.aliyuncs.com/test-2022-music.mp3"></audio>
<script>
function handleClick() {
document.getElementById("audio").play();
}
</script>
</body>
```
2.Create a wkwebview to load the html file in my demo APP.
```
class ViewController: UIViewController , WKUIDelegate{
var webView: WKWebView!
override func loadView() {
let config = WKWebViewConfiguration()
config.preferences.javaScriptEnabled = true
config.allowsInlineMediaPlayback = true
webView = WKWebView(frame: .zero, configuration: config) //.zero
webView.uiDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string: "https://ac-dev.oss-cn-hangzhou.aliyuncs.com/test-2022-py.html")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
}
```
3.Click the button in the HTML to play the audio, and you can see the error report on the xcode.
```
iPadN[2133:855729] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Required client entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"MediaPlayback" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Required client entitlement is missing}>
```
4.To sum up, this error will appear when playing audio or video in HTML. Then the app performance will drop a lot, and the interactive response will be very slow.
|
An error is reported when playing h5 audio or video elements in wkwebview: Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Required client entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"MediaPlayback" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Required client entitlement is missing}> Then the performance of the webview will become very poor, no response to any element click.This problem has affected our tens of thousands of users.The current solution is to call the client method to play audio.How to solve the problem fundamentally?