iOS 13 - WkWebView BUG: audio stops when in background

I've an app that uses WkWebView to play audio from Soundcloud and Mixcloud by using their javascript widget, on iOS 13 Beta 6 the audio stops when the app is not in foreground, even when Audio is on in Background Modes.


When starting the playback this assertions is thrown:


Error acquiring assertion: <NSError: 0x282cf67c0; domain: RBSAssertionErrorDomain; code: 2; reason: "Required client entitlement is missing"> {
userInfo = {
  RBSAssertionAttribute = <RBSLegacyAttribute: 0x1592432e0; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>;
}


And after entering background state the following assertion is thrown and audio suspended:


Can't end BackgroundTask: no background task exists with identifier 13 (0xd), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug. 
[ProcessSuspension] Background task expired while holding WebKit ProcessAssertion (isMainThread? 1).


This is not happening in iOS 12, where the audio plays normally when in background.

I have the same problem. Any solution?
I have the same problem too.
I have this issue as well.
Same problem!! I can see that thread is one year old and still no fix, is this a joke?? I am developping a popular music production app and we run webaudio under the hood. The only way to make the audio come back is to kill and restart the app, ridiculous... I am very disappointed, this is not professional from Apple, they should address this issue and give more info.

So as everybody here I have the same problem, my test setup is on iOS 13.6.1. It is very bad! I am a WebAudio expert so here is what I found.

When our music app is set in background mode (user switches to another app or screen turned off), all the WebAudio AudioContexts inside the WkWebView freeze after exactly 27 seconds. At that moment, our app turns silent and the AudioContext.currentTime stops incrementing despite that the AudioContext.state is still "running". That's the only way to detect that broken WebAudio state I found.

And the worst part is that bringing back the app to the foreground don't resuscitate the frozen AudioContexts, they are dead forever, I tried. You can recreate new AudioContexts though but in our case we simply restart all the app, which means the user lost his progress. This is a quick fix waiting for the real iOS fix.

It is obviously a big bug introduced in iOS 13. Also I can see that this issue is almost one year old and it has not been fixed, that's not respectful for all HTML5 developer here, that's sad! Hoping someone competent will take this issue seriously. Thanks!
I had the same issue and turns out that it was an improper javascript writing.

In my case, I was executing $('#selector').focus() before $(document).ready which caused the issue, and when I placed the focus method into document ready, it was resolved.

So check you javascript.
iOS 13 - WkWebView BUG: audio stops when in background
 
 
Q