Bug 237878 - AudioContext is suspended on iOS when page is backgrounded
Summary: AudioContext is suspended on iOS when page is backgrounded
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-15 00:09 PDT by youenn fablet
Modified: 2023-02-01 11:03 PST (History)
13 users (show)

See Also:


Attachments
WIP (9.96 KB, patch)
2022-03-15 06:29 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (22.91 KB, patch)
2022-03-16 03:03 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2022-03-15 00:09:11 PDT
Following on https://bugs.webkit.org/show_bug.cgi?id=231105 which was MacOS specific, we have the same AudioContext issues:
- If page is backgrounded, AudioContext will be stopped even though AudioContext is not used directly for playing audio
- AudioContext might be resumed by web page in case it can autoplay (for instance if page is continuing to capture audio, which allows to continue playing audio).
Comment 1 youenn fablet 2022-03-15 06:29:10 PDT
Created attachment 454699 [details]
WIP
Comment 2 youenn fablet 2022-03-16 03:03:20 PDT
Created attachment 454812 [details]
Patch
Comment 3 EWS 2022-03-17 00:22:56 PDT
Committed r291390 (248520@main): <https://commits.webkit.org/248520@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 454812 [details].
Comment 4 Radar WebKit Bug Importer 2022-03-17 00:23:16 PDT
<rdar://problem/90415179>
Comment 5 youenn fablet 2022-03-23 23:55:39 PDT
As spotted by Cameron, media/auto-play-web-audio-in-about-blank-iframe.html is failing  on bots after this change.
Comment 6 youenn fablet 2022-03-23 23:59:40 PDT
(In reply to youenn fablet from comment #5)
> As spotted by Cameron, media/auto-play-web-audio-in-about-blank-iframe.html
> is failing  on bots after this change.

Hypothesis: background state is kept from a past test and never reset to false across tests.
Comment 7 Matthew Windwer 2022-04-04 09:49:24 PDT
Thanks for fixing this. What iOS release can we expect this fix?
Comment 8 Jeremy Thoms 2022-04-29 05:30:21 PDT
> Thanks for fixing this. What iOS release can we expect this fix?

I'd also like to know the targeted iOS release. It's become a critical issue for us.
Comment 9 Adrien iWebDJ 2022-05-20 04:53:16 PDT
Oh no not again... almost same problem was introduce iOS 13 (webaudio stops when app is in background), it took one year to fix back then... https://developer.apple.com/forums/thread/121822

Please, this is CRITICAL, how can we develop a real music app with WVWebView if the audio stops in background? ... The problem doesn't happen on iOS Safari.

I am questioning the QA team who validated this release because the problem is so obvious.
Comment 10 Adrien iWebDJ 2022-05-20 04:57:28 PDT
Same bug in iOS13 > https://bugs.webkit.org/show_bug.cgi?id=203293, fixed in iOS14 and introduced again in iOS15... please this is a big issue...
Comment 11 Adrien iWebDJ 2022-06-07 10:08:42 PDT
@youenn fablet, Is this critical bug fix will be shipped on iOS16 only? if so it won't be accessible for all iPhones prior to iPhone 8, which is a big problem for wide adopted apps. Could you please release the fix in iOS15? iOS14 is not affected by this bug. Thanks!!
Comment 12 youenn fablet 2022-06-07 10:24:53 PDT
(In reply to Adrien iWebDJ from comment #11)
> @youenn fablet, Is this critical bug fix will be shipped on iOS16 only? if
> so it won't be accessible for all iPhones prior to iPhone 8, which is a big
> problem for wide adopted apps. Could you please release the fix in iOS15?
> iOS14 is not affected by this bug. Thanks!!

This particular fix should be in the iOS 16 beta 1.
Comment 13 Adrien iWebDJ 2022-06-08 16:25:36 PDT
@youenn fablet thank you for the reply and the fix!! but tell me if I am wrong, will this mean that the iPhones 6s/7/SE1 and many iPads will never be able to play background webaudio? (= making it unusable) 

If so, this would be a big problem because it has never happened to have a "hole" in the support of webaudio... :/
Comment 14 Ian Lovejoy 2022-06-15 11:07:23 PDT
Just another upvote: it would really really be great if this fix could be merged into a 15.x release! Thanks for your consideration.
Comment 15 Adrien iWebDJ 2022-07-12 10:58:52 PDT
@youenn fablet, I just installed iOS 16 Beta 1 as you adviced, the fix is not there, WebAudio keeps stopping if app go to background... :'(

Also I have issue with WebAudio with bluetooth, it is completely buggy. I don't know if you were aware of it...

(I am french too :)
Comment 16 Adrien iWebDJ 2022-07-12 11:11:32 PDT
 ps : test it by yourself if you need : https://apps.apple.com/us/app/youdj-mix-music-now/id1459666155 
(desktop version is a popular DJ app : https://you.dj)
Comment 17 Adrien iWebDJ 2022-09-16 08:48:52 PDT
Just to let you know, the fix is still not included in iOS 16.1 beta :'(
Comment 18 leo.au 2022-10-26 12:42:52 PDT
The bug is still present in iOS 16.1 release.  Tested on an iPhone 11 Pro demo playing various games on https://nj-casino.goldennuggetcasino.com/
Comment 19 Adrien iWebDJ 2023-02-01 11:03:02 PST
The bug is 18 months old and it is still present in iOS 16.3, discouraging...

Also iOS 16.3 introduced a new bug! Now the silent switch is also muting WebAudio... 

The WKWebView behavior should match native apps for audio, otherwise it is useless and confusing.

I have open a new bug thread, these issues are too blocking : https://bugs.webkit.org/show_bug.cgi?id=237878
Comment 20 Adrien iWebDJ 2023-02-01 11:03:35 PST
Sorry the new bug thread is : https://bugs.webkit.org/show_bug.cgi?id=251532