| Summary: | AudioContext stops playing when displaying a dialog (window.alert() or window.confirm()) | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Kyu Simm <simmkyu> |
| Component: | Web Audio | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Normal | CC: | cdumez, jer.noble, karlcow, rniwa, webkit-bug-importer |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | Safari 16 | ||
| Hardware: | All | ||
| OS: | All | ||
Problem: - AudioContext stops playing when displaying a dialog (`window.alert()` or `window.confirm()`) Steps to Reproduce: 1. Open any website in macOS or iOS Safari. (For iOS Safari steps, unmute your device.) 2. Run the following script in Safari's console. The script adds a button to play a tone and show a dialog. ``` (() => { const button = document.createElement('button'); button.innerText = 'Play audio'; button.style = 'position: fixed; top:0; left:0; z-index:9999'; document.body.appendChild(button); let isPlaying = false; button.addEventListener('click', async () => { if (isPlaying) { window.alert('Alert!'); } else { isPlaying = true; button.innerText = 'Call window.alert'; const audioContext = new (window.AudioContext || window.webkitAudioContext)(); const oscillator = audioContext.createOscillator(); oscillator.type = 'square'; oscillator.frequency.setValueAtTime(440, audioContext.currentTime); // value in hertz oscillator.connect(audioContext.destination); oscillator.start(); } }); })(); ``` 3. Click the "Play audio" button at the top-left corner of the website. You should hear a tone from Safari. 4. Click the "Call window.alert" button. Actual Results: - The tone cannot be heard as the dialog appears. Expected Results: - The tone should continue playing after the dialog appears or when the dialog is dismissed. Test Environments: - macOS Safari 16.4 - iOS Safari 16.3 Additional Information: - In macOS Chrome 111, the audio continues to play without any pauses. - In macOS Firefox 111, the audio stops while the dialog is visible, but resumes playing after the dialog is closed.