Bug 232640
| Summary: | AudioContext stops playing when unplugging wired headphones from iOS devices | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Kyu Simm <simmkyu> |
| Component: | Web Audio | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | cdumez, eric.carlson, ews-watchlist, glenn, harsho, henry2014, hta, jer.noble, kevin_neal, philipj, sergio, tommyw, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 15 | ||
| Hardware: | iPhone / iPad | ||
| OS: | Unspecified | ||
Kyu Simm
Problem:
- AudioContext stops playing when unplugging wired headphones from iOS devices.
Steps to Reproduce:
1. Do not plug wired headphones yet.
2. Open https://codepen.io/simmkyu/pen/xxLPNqe in iOS Safari or iOS Chrome.
3. Choose "Play OscillatorNode" that plays the 440 Hz tone using Web Audio nodes and HTMLAudioElement.
4. Plug wired headphones into your iOS device. You can still hear the tone from your headphones.
5. Unplug wired headphones from your iOS device. Go to the "Actual Results" section.
Steps to Reproduce 2 (the same code without using CodePen):
1. Connect your iOS device to macOS.
2. Open any website in iOS Safari. Open the Safari Web Inspector to inspect the website.
3. Run the following script in the console. The script plays the 440 Hz tone using Web Audio nodes and HTMLAudioElement.
```
(async function () {
// Allow this website to play HTMLAudioElement.
await navigator.mediaDevices.getUserMedia({ audio: true });
// OscillatorNode => GainNode => MediaStreamAudioDestinationNode
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const destinationNode = audioContext.createMediaStreamDestination();
const gainNode = audioContext.createGain();
gainNode.gain.value = 0.1;
gainNode.connect(destinationNode);
const oscillatorNode = audioContext.createOscillator();
oscillatorNode.frequency.value = 440;
oscillatorNode.connect(destinationNode);
oscillatorNode.start();
// MediaStreamAudioDestinationNode => HTMLAudioElement
const audio = document.createElement('audio');
document.body.appendChild(audio);
audio.srcObject = destinationNode.stream;
audio.play();
})();
```
4. Plug wired headphones into your iOS device. You can still hear the tone from your headphones.
5. Unplug wired headphones from your iOS device.
Actual Results:
- You cannot hear the tone from your iOS device's speakers.
Expected Results:
- You should continue hearing the tone from your iOS device's speakers.
Build:
- iOS 15.0 and iOS 15.1
- ioS Safari 604.1
- iOS Chrome 95.0.4638.50
Additional Information:
- Important: iOS Safari or iOS Chrome plays the tone again if you go to the Home screen and return to the browser app. After you complete the "Steps to Reproduce" section, try to go to the Home screen (or another app) and reopen the browser app.
- In the "Steps to reproduce" sections, I used OscillatorNode and GainNode for demonstration, but the bug is reproducible only with the MediaStreamAudioDestinationNode. For example, you can connect your microphone's MediaStream to MediaStreamAudioDestinationNode. When unplugging your headphones, you will stop hearing your voice from HTMLAudioElement.
- I used Apple EarPods with Lightning Connector for testing.
- The bug does not occur on macOS Safari (15.0) and other desktop browsers. I tested it using MacBook Pro (16-inch, 2019), Big Sur 11.6.1, and Apple EarPods with 3.5mm Headphone Plug.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/102787007>
henry2014
This issue still reproduces, and we are unable to use WebAudio for processing on iOS because of it. Any chance that someone could take a look?