RonnySchleicher opened a new issue #937: URL: https://github.com/apache/cordova-ios/issues/937
# Bug Report If I use the cordova-plugin-wkwebview-engine and play a soundfile, i beome follow **assertion.** ``` 2020-07-10 13:40:04.054571+0200 TEST[1927:49192] [assertion] Error acquiring assertion: <NSError: 0x600002e7ba80; domain: RBSAssertionErrorDomain; code: 2; reason: "Client is missing required entitlement"> { userInfo = { RBSAssertionAttribute = <RBSLegacyAttribute: 0x7fce0fd216e0; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>; } } ``` This is not nice but not the real problem. If I install this app via the app store and the audio object of this sound file plays automatically without user action, for example after receiving an SIO message, the assertion causes the app to crash. The really deadly problem is that with Cordova and the cordova-plugin-wkwebview-engine I can no longer play sounds without direct user action when the App is installed over the official Apple App-Store! ## Steps to reproduce the Assertion in X-Code * Install the newest X-Code Version 11.5 (11E608c) on your Mac with macOS 10.15.5 * Create a fresh and new Cordova App for iOS. You can use follow script: ``` #!use this two lines to install the lastest cordova version #!sudo npm uninstall -g cordova #!sudo npm install -g cordova rm -r PhoneGap_ios cordova create PhoneGap_ios de.test.test Test cd PhoneGap_ios cordova platform add ios cordova plugin add cordova-plugin-wkwebview-engine cordova plugin ls ``` * Open the X-Code Project and add follow line in the cordova **index.html** (project/Staging/www/index.html): ``` <input type="button" id="buttontest" value="Click me..."/> ``` The complete changed **index.html** look like this: ``` <!DOCTYPE html> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <html> <head> <!-- Customize this policy to fit your own app's needs. For more guidance, see: https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy Some notes: * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this: * Enable inline JS: add 'unsafe-inline' to default-src --> <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <link rel="stylesheet" type="text/css" href="css/index.css"> <title>Hello World</title> </head> <body> <div class="app"> <h1>Apache Cordova</h1> <div id="deviceready" class="blink"> <p class="event listening">Connecting to Device</p> <p class="event received">Device is Ready</p> </div> <input type="button" id="buttontest" value="Click me..."/> </div> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="js/index.js"></script> </body> </html> ``` * Open the X-Code Project and add follow line in the cordova **index.js** (project/Staging/www/js/index.js): ``` onDeviceReady: function() { this.receivedEvent('deviceready'); document.getElementById('buttontest').addEventListener('click', function() { console.log('Received Event click: start #############################'); try { var audio = new Audio('sounds/s1.wav'); audio.play(); } catch(err) { console.log(err.message); } console.log('Received Event click: end -----------------------------'); }); }, ``` The complete changed **index.js** look like this: ``` /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ var app = { // Application Constructor initialize: function() { document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); }, // deviceready Event Handler // // Bind any cordova events here. Common events are: // 'pause', 'resume', etc. onDeviceReady: function() { this.receivedEvent('deviceready'); document.getElementById('buttontest').addEventListener('click', function() { console.log('Received Event click: start #############################'); try { var audio = new Audio('sounds/s1.wav'); audio.play(); } catch(err) { console.log(err.message); } console.log('Received Event click: end -----------------------------'); }); }, // Update DOM on a Received Event receivedEvent: function(id) { var parentElement = document.getElementById(id); var listeningElement = parentElement.querySelector('.listening'); var receivedElement = parentElement.querySelector('.received'); listeningElement.setAttribute('style', 'display:none;'); receivedElement.setAttribute('style', 'display:block;'); console.log('Received Event: ' + id); } }; app.initialize(); ``` When I start the app on the iPhone (in this sample it is an iPhone X), the new button is showing. <img width="450" alt="Bildschirmfoto 2020-07-10 um 14 12 49" src="https://user-images.githubusercontent.com/1914203/87153324-93a3a300-c2b7-11ea-8987-565fc85377ab.png"> After click the button follow message is showing in the X-Code ``` 2020-07-10 14:16:40.964661+0200 FAMANICE[2123:63730] Received Event click: start ############################# 2020-07-10 14:16:40.983068+0200 FAMANICE[2123:63730] Received Event click: end ----------------------------- 2020-07-10 14:16:41.101598+0200 FAMANICE[2123:63842] [assertion] Error acquiring assertion: <NSError: 0x6000029ec4b0; domain: RBSAssertionErrorDomain; code: 2; reason: "Client is missing required entitlement"> { userInfo = { RBSAssertionAttribute = <RBSLegacyAttribute: 0x7fce0fd202c0; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>; } } 2020-07-10 14:16:41.101697+0200 FAMANICE[2123:63842] [ProcessSuspension] 0x116baab68 - ProcessAssertion() PID 2123 Unable to acquire assertion for process with PID 2123 2020-07-10 14:16:41.101786+0200 FAMANICE[2123:63730] [ProcessSuspension] 0x116baab68 - ProcessAssertion::processAssertionWasInvalidated() 2020-07-10 14:16:41.103452+0200 FAMANICE[2123:63842] [assertion] Error acquiring assertion: <NSError: 0x6000029dd0b0; domain: RBSAssertionErrorDomain; code: 2; reason: "Client is missing required entitlement"> { userInfo = { RBSAssertionAttribute = <RBSLegacyAttribute: 0x7fce11229040; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>; } } 2020-07-10 14:16:41.103541+0200 FAMANICE[2123:63842] [ProcessSuspension] 0x116baabb8 - ProcessAssertion() PID 2123 Unable to acquire assertion for process with PID 2129 2020-07-10 14:16:41.103617+0200 FAMANICE[2123:63730] [ProcessSuspension] 0x116baabb8 - ProcessAssertion::processAssertionWasInvalidated() ``` ### What is expected to happen? No error message appeares. ### What does actually happen? The error message appeares. ### Command or Code see above ### Environment, Platform, Device * iMac17,1 with macOS 10.15.3 (19D76) * X-Code Version 11.4 beta (11N111s) with the related SDK * iPhone X with iOS 13.4 (also tested with other iPhone with iOS 13.4) * Latest Cordova Version ('5.1.1' in cordova.js) ### Version information see above ## Checklist - [x] I searched for existing GitHub issues - [x] I updated all Cordova tooling to most recent version - [x] I included all the necessary information above ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org