Bug 239696

Summary: Audio playback rate sped up for few seconds when using createMediaElementSource
Product: WebKit Reporter: Luigi Pulcini <luigi>
Component: Web AudioAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Major CC: cdumez, chrisguttandin, eric.carlson, esprehn+autocc, ews-watchlist, glenn, jer.noble, kangil.han, me, philipj, sergio, tero, webkit-bug-importer, youennf, youssefdevelops, y_soliman
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch for landing
ews-feeder: commit-queue-
Patch for landing
ews-feeder: commit-queue-
Patch for landing
none
Patch for landing none

Description Luigi Pulcini 2022-04-23 14:46:12 PDT
Several customers of my plugin WavePlayer are reporting that audio playback in Safari 15 and iOS 15 is "sped up" for a few seconds before settling to the correct rate.
I have just tested this on my MacBookPro with Mac OS 10.15.7 and Safari 15.4 using the simplest createMediaElementSource implementation you could possibly think of (a 16-line script) and can confirm the bad behavior only in Safari, while Chrome, Firefox, and Edge are not affected.

You can test this at the following address:
https://webaudioapi.com/samples/audio-tag/
Comment 1 Tero Parviainen 2022-04-25 08:20:18 PDT
Confirming I'm also seeing the same behaviour on OS X 12.3.1, Safari 15.4.

The speeding-up happens reliably at the beginning, and seems to reoccur occasionally well into the playback. 

The same happens both when starting playback with the element already attached into the web audio graph, and when connecting a previously started element.
Comment 2 Jeffrey Alan Scudder 2022-04-25 20:35:10 PDT
Yes I see this behavior when trying to use createMediaElementSource on both iOS and Safari, with both video and audio tags. I think it happens across the board. Also, the audio is delayed significantly in the context of using a video tag.
Comment 3 Radar WebKit Bug Importer 2022-04-30 14:47:13 PDT
<rdar://problem/92569332>
Comment 4 youenn fablet 2022-05-12 02:47:50 PDT
Created attachment 459215 [details]
Patch
Comment 5 Eric Carlson 2022-05-12 06:18:22 PDT
Comment on attachment 459215 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=459215&action=review

> Source/WebCore/ChangeLog:9
> +        We added a way for AudioSampleDataSource to reduce latemcy due to its audio buffer by reading the audio buffer faster

s/latemcy/latency/
Comment 6 youenn fablet 2022-05-12 06:54:16 PDT
Created attachment 459229 [details]
Patch for landing
Comment 7 EWS 2022-05-13 00:45:29 PDT
Eric Carslon found in /Volumes/Data/worker/Commit-Queue/build/Source/WebCore/ChangeLog does not appear to be a valid reviewer according to contributors.json.
/Volumes/Data/worker/Commit-Queue/build/Source/WebCore/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).
Comment 8 youenn fablet 2022-05-14 11:41:58 PDT
Created attachment 459359 [details]
Patch for landing
Comment 9 youenn fablet 2022-05-15 22:38:35 PDT
Created attachment 459394 [details]
Patch for landing
Comment 10 youenn fablet 2022-05-15 22:41:18 PDT
Created attachment 459396 [details]
Patch for landing
Comment 11 EWS 2022-05-15 23:38:31 PDT
Committed r294221 (250579@main): <https://commits.webkit.org/250579@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 459396 [details].