Bug 234275 - AudioBufferSourceNode is not being played on repeat visit and/or refresh
Summary: AudioBufferSourceNode is not being played on repeat visit and/or refresh
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: Safari 15
Hardware: All iOS 15
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-13 15:12 PST by Yuriy Kravets
Modified: 2021-12-20 15:13 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuriy Kravets 2021-12-13 15:12:22 PST
This is a strange bug that I've encountered on all browsers on iOS or mac with m1 chip. iOS I've tested firefox and safari, on Mac I've tested Safari and Chrome.
I've built an app that creates some audio with BaseAudioContext.createBufferSource() and whether it's going to be played depends on couple of factors:
- running the web app locally -> works every time, no matter how many times I refresh or switch tabs;
- going to a deployed https page -> on first load everything plays normally, after refresh or tab switch it just stops working, nothing is played although the code is executed.

Going to Settings -> Safari -> clear page cache seems to help on iOS.
For mac Safari I have to go to Safari -> empty cache or for Chrome -> open dev tools and refresh the page.

example can be found here https://demiurg.app/tabs/tab-player.html?tabId=89

on windows and android devices there is no such issue, the audio plays each time I press the play button.

If this bug should be submitted elsewhere, please do that or redirect me to a correct bug tracker.
Comment 1 Yuriy Kravets 2021-12-15 11:39:24 PST
I have pinpointed the code that triggers such behaviour. This is somehow related to caching of WebWorker code. Adding time param to path to the worker code makes the browser load a fresh copy of that file, and this leads to some kind of reevaluation on the WebAudio side.

const worker = new Worker(`../measure-processor-worker.js?v=${new Date().getTime()}`);

the strange thing here is that the code seem to execute each time (tested through some console.logs) but the sound is not being played. What that code does is it generates JSON objects with information about what has to be played + duration, it is not calling any WebAudio related API functions.
Comment 2 Radar WebKit Bug Importer 2021-12-20 15:13:15 PST
<rdar://problem/86742536>