<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Web Audio restores wrong sample rate and sounds distorted"
   href="https://bugs.webkit.org/show_bug.cgi?id=154538">154538</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Web Audio restores wrong sample rate and sounds distorted
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>Safari 9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>iOS
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>iOS 9.2
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Major
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Web Audio
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ashley&#64;scirra.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Repro URL: <a href="https://www.scirra.com/labs/bugs/iosdistort/">https://www.scirra.com/labs/bugs/iosdistort/</a>

Steps to reproduce:
1. Visit the URL.
2. Observe the displayed audioContext.sampleRate. It should be 44100 Hz.
3. Press the button. A sound should play, and a regular sound starts playing.
4. Kill Safari (double press-and-hold home button, swipe away Safari from apps list)
5. Open Safari again
6. Safari restores the previous page
7. Press the button again
8. Observe sample rate and listen to audio quality

Observed result:
The audio quality is severely distorted and sounds terrible. The sample rate has also changed to 48000 Hz, which may be related.

Expected result:
Audio quality same as on first listen, and sample rate should probably stay at 44100 Hz.

This appears to be a device-specific issue. This does not reproduce on an iPad Air 2, but it does reproduce on an iPhone 4S, all running iOS 9.2.1.

This is causing significant problems for all Construct 2 content on iOS. See here: <a href="https://www.scirra.com/forum/ios-sound-problems-since-ios-9-2_t167412">https://www.scirra.com/forum/ios-sound-problems-since-ios-9-2_t167412</a>
According to user reports, it only happens on iPhones and not iPads, the webview is affected, and the problem is new as of iOS 9.2.

After the audio sounds distorted, closing the Safari tab and reopening it seems to restore the audio quality and the 44100 sample rate. However note this is not an option with Cordova apps. We have also found what seems to be a workaround we can apply from our engine: if on startup we create an AudioContext, immediately call close() on it, throw it away, then create a new AudioContext which we use for the rest of the app, it appears to work correctly. We will shortly be shipping this workaround for iOS devices, but this should be fixed as it affects all existing deployed web content.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>