Bug 169849

Summary: Web Audio ScriptProcessorNode pauses, emits hum after switching audio output device
Product: WebKit Reporter: Brooke Vibber <bvibber>
Component: Web AudioAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: hartman.wiki, jer.noble, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Mac   
OS: macOS 10.12   

Description Brooke Vibber 2017-03-18 12:28:09 PDT
We're using Web Audio's ScriptProcessorNode to play audio files that have been decoded in JavaScript dynamically; it works quite well except when the audio output device is changed during playback.

On my MacBook Pro running macOS 10.12.3, I can reproduce this by plugging or unplugging a USB speaker during playback; both directions produce similar results:
* audio stops on the old device
* on the new device, a humming noise may be emitted
* audioprocessing events are no longer delivered

When switching back to the original output device, audioprocessing events continue being delivered, and audio continues as expected.

Simplified test case: https://brionv.com/misc/audio.html

Same results with Safari 10 release version, Technical Preview, and WebKit Nightly.
Comment 1 Radar WebKit Bug Importer 2017-03-19 13:47:25 PDT
<rdar://problem/31137513>
Comment 2 Jer Noble 2017-03-19 20:26:31 PDT
This sounds suspiciously like a bug we fixed in iOS last year; I must have done it in a platform specific area of the Web Audio code. Should be relatively easy to port over.