NEW 240646
AudioContext fails to resume in WKWebView
https://bugs.webkit.org/show_bug.cgi?id=240646
Summary AudioContext fails to resume in WKWebView
Ashley Gullen
Reported 2022-05-19 07:10:48 PDT
A user of our web-based game engine Construct (www.construct.net) discovered a strange issue with Web Audio in WKWebView. I believe it's a bug in iOS. Sample Xcode project demonstrating the issue: https://www.dropbox.com/s/5gdoxb9nkcqe9pd/Audio%20test.ios.project.zip?dl=0 This project is built using Cordova and loads some web content in WKWebView. The WKWebView is configured to allow media playback without a user gesture via mediaTypesRequiringUserActionForPlayback, so audio playback immediately on startup is allowed. The web content creates an AudioContext on startup and immediately starts playing a music track. Press the home button and wait 30 seconds. This fully suspends the app. Then open the app again. It resumes, but there is no audio playback. I've debugged this and checked: - the audio context state does return to "running" - our code correctly remembers where playback reached upon suspending, and re-starts playback upon resuming - if we add a 5 second delay before starting playback, it works correctly - if we start playback in a touch (matching the user gesture requirements in the Safari browser), it also works correctly So it looks like there's a bug in WKWebView where if playback is started immediately, it is not able to continue playback after suspending and resuming. Perhaps there is a race condition where something needs to happen shortly after audio context creation for suspending/resuming to work? Immediate audio playback is not normally possible in Safari due to the user gesture requirements, so perhaps this is an overlooked aspect of WKWebView.
Attachments
Radar WebKit Bug Importer
Comment 1 2022-05-26 07:11:13 PDT
Note You need to log in before you can comment on or make changes to this bug.