AudioContext dies (silently) in IOS14 Safari on iPad
nmcgann opened this issue · 0 comments
If the tab with the metronome app is made inactive the AudioContext is 'suspended' / 'interrupted' and has to be manually re-started with audioContext.resume();
in the play()
function once the tab is made active again. (see https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/state)
This works on Chrome, but not in Safari. AudioContext is apparently re-started and running in Safari, but the audio clock is frozen leaving the application dead. The only workround I have found is to detect the 'suspended' or 'interrupted' state and then close the AudioContext and make a new one (plus any associated nodes like gain).
This then works in both Safari and Chrome. (see https://github.com/nmcgann/metronome for this fix and various other added features)