Bug 220879

Summary: [iOS] Set background playback restriction for WebAudio
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, glenn, jer.noble, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Eric Carlson 2021-01-22 15:17:08 PST
WebAudio does not play in the background on iOS both because audio doesn't play when the category is set to `AVAudioSessionCategoryAmbient`, and because the AudioContext is paused when the web process is forwarded the `UIApplicationWillResignActiveNotification` notification. 

This notification isn't forwarded when the WebView is hosted in SafariViewController so the AudioContext is not paused, so it resumes playing when the application is foregrounded even if the view controller is not in the foreground.
Comment 1 Eric Carlson 2021-01-22 15:18:13 PST
<rdar://72949281>
Comment 2 Eric Carlson 2021-01-22 15:39:02 PST
Created attachment 418188 [details]
Patch
Comment 3 Eric Carlson 2021-01-23 09:58:12 PST
Created attachment 418227 [details]
Patch for landing
Comment 4 EWS 2021-01-23 12:31:42 PST
Committed r271779: <https://trac.webkit.org/changeset/271779>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 418227 [details].