Bug 181939

Summary: AudioBufferSourceNode start method causes OfflineAudioContext to start running
Product: WebKit Reporter: yotammann
Component: Web AudioAssignee: Jer Noble <jer.noble>
Status: RESOLVED FIXED    
Severity: Major CC: commit-queue, eric.carlson, jer.noble, spwilliamsiam, webkit-bug-importer, yotammann
Priority: P2 Keywords: InRadar
Version: Safari 11   
Hardware: iPhone / iPad   
OS: iOS 11   
Attachments:
Description Flags
Patch none

Description yotammann 2018-01-22 12:31:57 PST
The OfflineAudioContext.state should be "suspended" and not increment the currentTime until `startRendering` is invoked. The issue is that as soon as AudioBufferSourceNode.start is invoked, the OfflineAudioContext.state returns "running" and the OfflineAudioContext.currentTime starts incrementing usually much faster than real time. This makes it impossible to schedule anything after an AudioBufferSourceNode is started since the scheduled time will usually be in the past. 

Test case: https://jsfiddle.net/3h8e3bcg/

Should print to the console: "should be suspended: suspended" then "should still be suspended: suspended"

PASSES on Chrome, Firefox and Safari 11 on Desktop. 

FAILS on Safari on iOS 11. prints: "should be suspended: suspended" then "should still be suspended: running"
Comment 1 Radar WebKit Bug Importer 2018-01-22 16:56:58 PST
<rdar://problem/36755393>
Comment 2 Sam Williams 2018-03-25 14:40:50 PDT
=---------------------------=
F I X   S O O N   P L E A S E
F I X   S O O N   P L E A S E
F I X   S O O N   P L E A S E
=---------------------------=

But really, please do fix soon, as this bug is SO ANNOYING!!!
https://jsfiddle.net/ayunami2000/c5xdL6xL/
This is where I discovered the bug. Everything else in the JSFiddle works, but offlineAudioContext's oncomplete event never fires.
Also, https://codepen.io/tomduncalf/pen/GmvPNp works on iOS!!!

=---------------------------=
F I X   S O O N   P L E A S E
F I X   S O O N   P L E A S E
F I X   S O O N   P L E A S E
=---------------------------=
Comment 3 Jer Noble 2018-03-26 11:14:07 PDT
Created attachment 336527 [details]
Patch
Comment 4 Eric Carlson 2018-03-27 08:52:00 PDT
Comment on attachment 336527 [details]
Patch

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

> LayoutTests/webaudio/offlineaudiocontext-restriction.html:18
> +var calledResumeWithUserGesture = false;

Nit: this isn't used.
Comment 5 WebKit Commit Bot 2018-04-02 08:40:25 PDT
Comment on attachment 336527 [details]
Patch

Clearing flags on attachment: 336527

Committed r230158: <https://trac.webkit.org/changeset/230158>
Comment 6 WebKit Commit Bot 2018-04-02 08:40:26 PDT
All reviewed patches have been landed.  Closing bug.