<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>223733</bug_id>
          
          <creation_ts>2021-03-25 00:45:22 -0700</creation_ts>
          <short_desc>Play h5 audio element in wkwebview will report error: Required client entitlement is missing</short_desc>
          <delta_ts>2021-03-27 02:54:01 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 14</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HTML5, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="pengyong">pasoul.peng</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>jer.noble</cc>
    
    <cc>pvollan</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1743687</commentid>
    <comment_count>0</comment_count>
    <who name="pengyong">pasoul.peng</who>
    <bug_when>2021-03-25 00:45:22 -0700</bug_when>
    <thetext>An error is reported when playing h5 audio or video elements in wkwebview: Error acquiring assertion: &lt;Error Domain=RBSAssertionErrorDomain Code=3 &quot;Required client entitlement is missing&quot; UserInfo={RBSAssertionAttribute=&lt;RBSDomainAttribute| domain:&quot;com.apple.webkit&quot; name:&quot;MediaPlayback&quot; sourceEnvironment:&quot;(null)&quot;&gt;, NSLocalizedFailureReason=Required client entitlement is missing}&gt;
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?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1743919</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2021-03-25 14:40:21 -0700</bug_when>
    <thetext>What is h5 audio? Can you please elaborate steps to reproduce?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1743920</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-03-25 14:40:31 -0700</bug_when>
    <thetext>&lt;rdar://problem/75854010&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744038</commentid>
    <comment_count>3</comment_count>
    <who name="pengyong">pasoul.peng</who>
    <bug_when>2021-03-25 19:11:54 -0700</bug_when>
    <thetext>1.There is an audio element and a button button in my HTML file. Click the button to play audio.
```
&lt;body&gt;
        &lt;button onclick=&quot;handleClick()&quot;&gt;PLAY&lt;/button&gt;
        &lt;audio id=&quot;audio&quot; src=&quot;https://ac-dev.oss-cn-hangzhou.aliyuncs.com/test-2022-music.mp3&quot;&gt;&lt;/audio&gt;
        &lt;script&gt;
   
            function handleClick() {
                document.getElementById(&quot;audio&quot;).play();
            }
        &lt;/script&gt;
&lt;/body&gt;
```
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: &quot;https://ac-dev.oss-cn-hangzhou.aliyuncs.com/test-2022-py.html&quot;)
        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: &lt;Error Domain=RBSAssertionErrorDomain Code=3 &quot;Required client entitlement is missing&quot; UserInfo={RBSAssertionAttribute=&lt;RBSDomainAttribute| domain:&quot;com.apple.webkit&quot; name:&quot;MediaPlayback&quot; sourceEnvironment:&quot;(null)&quot;&gt;, NSLocalizedFailureReason=Required client entitlement is missing}&gt;
```
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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744473</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-03-27 02:54:01 -0700</bug_when>
    <thetext>&lt;rdar://problem/75917755&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>