Bug 203293

Summary: WKWebView: audio tag sound stops when app goes to background on iOS 13
Product: WebKit Reporter: jcesarmobile <juliosincesar>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Major CC: aaron, adel.abdelli.aa, bernardo.oliveira, cdumez, ch235, eric.carlson, jer.noble, jon, joshterry55, mbalyaba, pedro.felipe.azevedo.furtado, peng.liu6, protean, trent, webkit-bug-importer, webkit
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: iPhone / iPad   
OS: iOS 13   

Description jcesarmobile 2019-10-23 08:01:57 PDT
Current Behaviour:
When using an audio tag to reproduce sound on a WKWebView, the sound stops shortly after the apps goes to background.
Only happens on iOS 13 (including 13.2 beta).

Expected Behaviour:
Sound should continue with the app in background as it did on iOS 12 and older

Sample app reproducing the issue:
https://github.com/jcesarmobile/background-audio-bug

(note that the app has background mode enabled for audio and still doesn't prevent from pausing the audio)
Comment 1 Radar WebKit Bug Importer 2019-10-23 10:45:26 PDT
<rdar://problem/56544807>
Comment 2 Trent Brown 2019-11-29 02:42:10 PST
It appears that this is due to web audio from the wkwebview not having the same entitlement that safari has for background keeping background proccesses open.
Comment 3 Maxim Balyaba 2020-02-25 05:08:35 PST
Hello Trent Brown!
Do you mean that it is not an issue ?
Comment 4 Joe Moore 2020-03-04 10:07:39 PST
Can someone please acknowledge this? It's a new bug, as far as I am aware, introduced with iOS 13 (or possibly more specifically 13.2) and is impacting countless applications and developers worldwide, myself included. Prior to this bug, audio playing on a page viewed in webkit worked perfectly fine, even after backgrounding the app or putting the phone to sleep. We have a significant amount of content that is nearly unusable as a result of this bug.
Comment 5 JTerr 2020-04-15 14:23:16 PDT
I am having this issue as well, is there any fix coming soon?
Comment 6 Pedro Furtado 2020-05-18 09:28:20 PDT
Any news in this issue? It affects ALL hybrid apps that play sounds in background in IOS environment.
Comment 7 Timothy Hatcher 2020-05-26 06:42:04 PDT

*** This bug has been marked as a duplicate of bug 205687 ***
Comment 8 JTerr 2020-05-26 07:50:35 PDT
(In reply to Timothy Hatcher from comment #7)
> 
> *** This bug has been marked as a duplicate of bug 205687 ***

I see this has been marked duplicate and resolved. Do you know when this will be live? I updated to ios 13.5 and i am still having issues today. Thank you for any information you can pass along.
Comment 9 Chris Dumez 2020-05-27 16:11:51 PDT
(In reply to Timothy Hatcher from comment #7)
> 
> *** This bug has been marked as a duplicate of bug 205687 ***

Why this you dupe this Tim? Did you verify this actually fixed this particular issue?
Comment 10 Pedro Furtado 2020-06-01 16:45:05 PDT
In which version of iOS it will be available?
Comment 11 JTerr 2020-06-02 07:52:49 PDT
Yes it would be very helpful to know which version of iOS this bug will be fixed on. Our entire WKWebview app audio has not worked in months. Thank you
Comment 12 Pedro Furtado 2020-06-02 13:29:17 PDT
Because of duplicated ticket related to this bug is resolved and released in iOS 13.5.1, this bug is fixed in iOS 13.5.1?
Comment 13 Pedro Furtado 2020-06-02 19:39:39 PDT
Please, can you reopen this bug? It was not fixed in iOS 13.5.1.
Comment 14 Chris Dumez 2020-06-02 20:31:43 PDT
(In reply to Pedro Furtado from comment #13)
> Please, can you reopen this bug? It was not fixed in iOS 13.5.1.

Did you validate that it was indeed not fixed in iOS 13.5.1. If so I will happily un-dupe.
Comment 15 Chris Dumez 2020-06-02 20:32:41 PDT
Reopening this the duping was wrong.
Comment 16 Joe Moore 2020-06-03 07:17:49 PDT
Can someone please prioritize this bug? I think the flurry of activity around this and the bug that this was (briefly) marked as a dupe of should be indicative of how many people are eager for this to be fixed. This appears to have been a problem for over a year at this point (per this bug: https://bugs.webkit.org/show_bug.cgi?id=198277).
Comment 17 Jon Levy 2020-06-03 08:16:06 PDT
I just want to add my voice others asking that this bug be treated as high priority.
Comment 18 JTerr 2020-06-03 08:59:05 PDT
^^^ I too would love to see this as a priority. I appreciate the help on this issue and hope we can resolve soon :)
Comment 19 Pedro Furtado 2020-06-05 08:24:32 PDT
Let's wait an official declaration of maintainers ...
Comment 20 Bernardo Oliveira 2020-06-09 01:05:44 PDT
Here I'm using the iOS 13.5.1 and audio still stops playing when a standalone web app is no longer in the foreground or in lock screen.
Comment 21 Chris Dumez 2020-06-11 14:37:58 PDT
We are actively working on this. The reason you are not seeing activity on this bug is because the fixes are not in WebKit but rather in other components of the system. We will comment here when we have this fully fixed.
Comment 22 Pedro Furtado 2020-06-11 19:33:24 PDT
Thank you so much for this feedback!

We are looking forward to a release asap with this bugfix. Many apps that my company develops does not work properly for months.

But we are happy to see this bug is now a high priority. Thanks again!
Comment 23 Pedro Furtado 2020-06-20 08:34:47 PDT
Is there some news available for us?
Comment 24 Chris Dumez 2020-06-20 09:47:01 PDT
(In reply to Pedro Furtado from comment #23)
> Is there some news available for us?

The news I have is that we have a complete fix and the corresponding radar has been marked as fixed. I have also validated that the fix is working.

However, I am unable to comment on when the fix will ship. I will try and remember to update this bug when it does ship though.
Comment 25 Pedro Furtado 2020-06-20 10:17:10 PDT
Oh, that is a great, very great news! 

Thanks for feedback! 

Well, now we just have to wait a release with this fix asap, but knowing that is already fixed is a very good news!
Comment 26 Jon Levy 2020-06-20 12:03:27 PDT
Great news, that there is a fix!  I eagerly await more information about when it will be deployed.
Comment 27 Adel Abdelli 2020-06-22 00:09:16 PDT
Hello,
Do you know approximately when the fix will be released ? 
This bug is very problematic because our applications do not work anymore on IOS and we have a lot of pressure from our company.

Please let inform us ..
Comment 28 Maxim Balyaba 2020-06-22 00:35:56 PDT
Looks like issue is fixed after latest iOS update.
Tested on iphone xr ios 13.5.1
Comment 29 Pedro Furtado 2020-06-22 03:28:29 PDT
Negative. iOS 13.5.1 without this fix there. That's why we are waiting a release ...
Comment 30 Maxim Balyaba 2020-06-22 03:42:02 PDT
We are tested cordova ionic 4 app, with <audio> tag.
Before it stops after 30sec app in background. 
Now all is fine (tested by different users and devices).
Do you set background audio setting ?
https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos/enabling_background_audio
Comment 31 Pedro Furtado 2020-06-22 03:44:53 PDT
Oh Yeah. But if the audio pause because of internet lack, or anything else, it not allow play again. In that case, only with the app in foreground is possible. So, bugfix is not released yet. But we are happy to see this released asap.
Comment 32 Pedro Furtado 2020-07-10 15:55:36 PDT
IOS 14 will have this bugfix? Please, say yes kkkkkk
Comment 33 Chris Dumez 2020-07-10 16:02:53 PDT
(In reply to Pedro Furtado from comment #32)
> IOS 14 will have this bugfix? Please, say yes kkkkkk

The fix should be present in iOS 14 beta 2 which got released a few days ago. I encourage people to test.
Comment 34 Cybronics 2020-07-13 06:55:17 PDT
(In reply to Chris Dumez from comment #33)
> (In reply to Pedro Furtado from comment #32)
> > IOS 14 will have this bugfix? Please, say yes kkkkkk
> 
> The fix should be present in iOS 14 beta 2 which got released a few days
> ago. I encourage people to test.

can confirm. Thanks guys.
Comment 35 Pedro Furtado 2020-08-13 06:55:15 PDT
The bugs still happens in ios 14 beta. Oh god! Can you guys reopen the bug, please?
Comment 36 jcesarmobile 2020-08-21 07:18:34 PDT
The issue I reported is fixed, I've tested on iPadOS 14 beta 4 and beta 5, and verified that works on both.

So if you are facing a similar problem, better report a new issue.

You can try the sample app I provided to reproduce the issue, just updated the audio file because the link I used was down.

https://github.com/jcesarmobile/background-audio-bug
Comment 37 Calvin Ho 2020-09-21 11:07:44 PDT
I confirm that this bug is fixed in iOS 14.0. Thanks!