Bug 202846

Summary: AudioContext stops playing when suspended on visibilitychange
Product: WebKit Reporter: Jesper van den Ende <jespertheend>
Component: Web AudioAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: cdumez, eric.carlson, jer.noble, jespertheend, johndoe437528, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: iPhone / iPad   
OS: iOS 13   
See Also: https://bugs.webkit.org/show_bug.cgi?id=281566
Attachments:
Description Flags
demonstration of the issue none

Jesper van den Ende
Reported 2019-10-11 03:48:51 PDT
Created attachment 380740 [details] demonstration of the issue When suspending an audio context in the visibilitychange event of a document, resuming the audio context does not start playing audio. Check the attached file for a demonstration. -open the file on safari on iOS 13.1.2 -tap the resume button -close safari -note how the audio stops playing -open safari again -note how the audio does not resume, the current time stays the same even though the state of the audio context is still "running" -tapping the resume button doesn't do anything -only after tapping the suspend button and then the resume button, the audio context starts playing -when 'suspend on visibility change' is unchecked, the problem does not occur. -the problem also does not occur on iOS 12, though on iOS 12 the audio keeps on playing when the checkbox is not checked. I wasn't able to reproduce this issue in the simulator on iOS 13.1, I was not able to download the iOS 13.1.2 simulator.
Attachments
demonstration of the issue (1.11 KB, text/html)
2019-10-11 03:48 PDT, Jesper van den Ende
no flags
Jesper van den Ende
Comment 1 2019-10-11 04:27:14 PDT
A temporary workaround for this issue is to put the ctx.resume() call of the visibilitychange event in a setTimeout with about 300ms.
Radar WebKit Bug Importer
Comment 2 2019-10-11 09:59:39 PDT
John Doe
Comment 3 2020-12-24 04:47:21 PST
The setTimeout of ≈ 300 is also required for resuming the audioContext on pageshow, as it seems. Though I'm not sure why I need to call resume on pageshow, shouldn't that be done automatic by the browser as it suspends the audioContext when leaving the page?
Note You need to log in before you can comment on or make changes to this bug.