[Webkit-unassigned] [Bug 232640] New: AudioContext stops playing when unplugging wired headphones from iOS devices

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 2 14:42:46 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=232640

            Bug ID: 232640
           Summary: AudioContext stops playing when unplugging wired
                    headphones from iOS devices
           Product: WebKit
           Version: Safari 15
          Hardware: iPhone / iPad
                OS: Unspecified
            Status: NEW
          Keywords: InRadar
          Severity: Normal
          Priority: P2
         Component: Web Audio
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: simmkyu at amazon.com
                CC: cdumez at apple.com, eric.carlson at apple.com,
                    ews-watchlist at webkit.org, glenn at skynav.com,
                    harsho at amazon.com, hta at google.com,
                    jer.noble at apple.com, kevin_neal at apple.com,
                    philipj at opera.com, sergio at correia.cc,
                    tommyw at google.com,
                    webkit-bug-importer at group.apple.com, youennf at gmail.com

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211102/52386a60/attachment.htm>


More information about the webkit-unassigned mailing list