Bug 274507 - REGRESSION (iPadOS 17.5): Audio distortion occurs when using AudioContext with a sample rate of 44100Hz and an AudioWorklet
Summary: REGRESSION (iPadOS 17.5): Audio distortion occurs when using AudioContext wit...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: Safari 17
Hardware: iPhone / iPad iOS 17
: P2 Major
Assignee: Jean-Yves Avenard [:jya]
URL:
Keywords: InRadar
: 274647 275726 275801 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-05-22 00:19 PDT by tamaru
Modified: 2024-06-25 08:52 PDT (History)
7 users (show)

See Also:


Attachments
A video sample demonstrating the distortion and the source code of the demo page (547.75 KB, application/x-zip-compressed)
2024-05-22 00:19 PDT, tamaru
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description tamaru 2024-05-22 00:19:23 PDT
Created attachment 471468 [details]
A video sample demonstrating the distortion and the source code of the demo page

There is a bug in Safari on iPadOS 17.5.1 where audio becomes distorted when an AudioContext is created with a sample rate of 44100Hz, and an AudioWorklet is used within that context. This distortion affects any audio played within the AudioContext, regardless of whether the audio is processed by the AudioWorklet.

Steps to Reproduce:

1. Create a new AudioContext with a sample rate of 44100Hz.
  const ctx = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: 44100 });

2. Add an AudioWorklet module to the AudioContext.
3. Play any audio through the AudioContext.
  const playSound = () => {
    const oscillator = ctx.createOscillator();
    oscillator.connect(ctx.destination);
    oscillator.start();
  }

  ctx.audioWorklet.addModule("AudioWorkletProcessor.js").then(() => {
    playSound();
  })

Expected Results:
  The audio should play without distortion.

Actual Results:
  The audio is distorted when played through the AudioContext.

Additional Information:
-This issue does not occur on iPadOS 17.4.1 but is present on iPadOS 17.5.1.
-The device model used for testing is iPad Air (5th generation).
-The distortion occurs regardless of the specific operations performed within the AudioWorklet. The distortion occurs even if no AudioWorkletNode is created.
-The issue is reproducible almost every time under the given conditions. However, reloading or reopening the Safari tab can change whether the distortion occurs, even with the same code.
-The audio sometimes becomes distorted just by adding an AudioWorklet, even without specifying a sample rate at 44100Hz. This distortion always occurs when first opening a new tab without reloading.
-A demo web page has been created to reproduce this bug. The URL is https://safari-44100hz-audioworklet-bug-demo.netlify.app/
-A video sample demonstrating the distortion and the source code of the demo page are attached for reference.
Comment 1 Radar WebKit Bug Importer 2024-05-22 10:53:51 PDT
<rdar://problem/128551401>
Comment 2 Jer Noble 2024-05-22 11:29:16 PDT
I can reproduce the behavior on macOS as well as iPadOS. This may have regressed via 275262@main, which introduced ShareAudioDestination.
Comment 3 Jean-Yves Avenard [:jya] 2024-05-24 06:25:58 PDT
Pull request: https://github.com/WebKit/WebKit/pull/29048
Comment 4 Jer Noble 2024-05-28 14:52:23 PDT
*** Bug 274647 has been marked as a duplicate of this bug. ***
Comment 5 EWS 2024-05-28 16:28:52 PDT
Committed 279409@main (d72323075072): <https://commits.webkit.org/279409@main>

Reviewed commits have been landed. Closing PR #29048 and removing active labels.
Comment 6 EWS 2024-05-31 09:18:18 PDT
Committed 272448.1053@safari-7618-branch (01cc3500a26e): <https://commits.webkit.org/272448.1053@safari-7618-branch>

Reviewed commits have been landed. Closing PR #1311 and removing active labels.
Comment 7 Alexey Proskuryakov 2024-06-24 09:02:40 PDT
*** Bug 275726 has been marked as a duplicate of this bug. ***
Comment 8 Alexey Proskuryakov 2024-06-25 08:52:04 PDT
*** Bug 275801 has been marked as a duplicate of this bug. ***