According to the Web Audio spec https://webaudio.github.io/web-audio-api/#dom-audionode-connect AudioNode.connect "returns destination AudioNode object". This does not seem to be the case in both iOS Safari 11 and desktop Safari 11, where AudioNode.connect returns `undefined`. It's problematic for code which uses chaining of .connect methods. Steps to reproduce: > const ac = new webkitAudioContext() < undefined > g1 = ac.createGain() < GainNode {gain: AudioParam, context: webkitAudioContext, numberOfInputs: 1, numberOfOutputs: 1, channelCount: 2, …} > g2 = ac.createGain() < GainNode {gain: AudioParam, context: webkitAudioContext, numberOfInputs: 1, numberOfOutputs: 1, channelCount: 2, …} > g3 = ac.createGain() < GainNode {gain: AudioParam, context: webkitAudioContext, numberOfInputs: 1, numberOfOutputs: 1, channelCount: 2, …} > g1.connect(g2).connect(g3) < TypeError: undefined is not an object (evaluating 'g1.connect(g2).connect')
<rdar://problem/43609703>
I started work on a patch for this.
Created attachment 351198 [details] Patch
Comment on attachment 351198 [details] Patch Thank you!
Comment on attachment 351198 [details] Patch Clearing flags on attachment: 351198 Committed r236648: <https://trac.webkit.org/changeset/236648>
All reviewed patches have been landed. Closing bug.
Comment on attachment 351198 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=351198&action=review > Source/WebCore/Modules/webaudio/AudioNode.idl:37 > - [MayThrowException] void connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0); > + [MayThrowException] AudioNode connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0); I believe there is a slightly more efficient way to do this by using the [ReturnValue] attribute on the destination object, so the JavaScript binding will reuse the passed-in wrapper rather than having to look it up.
Comment on attachment 351198 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=351198&action=review >> Source/WebCore/Modules/webaudio/AudioNode.idl:37 >> + [MayThrowException] AudioNode connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0); > > I believe there is a slightly more efficient way to do this by using the [ReturnValue] attribute on the destination object, so the JavaScript binding will reuse the passed-in wrapper rather than having to look it up. Gotcha, should I put together a new patch for that? If so, should the patch be attached to a new bug?
(In reply to Walker Henderson from comment #8) > Comment on attachment 351198 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=351198&action=review > > >> Source/WebCore/Modules/webaudio/AudioNode.idl:37 > >> + [MayThrowException] AudioNode connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0); > > > > I believe there is a slightly more efficient way to do this by using the [ReturnValue] attribute on the destination object, so the JavaScript binding will reuse the passed-in wrapper rather than having to look it up. > > Gotcha, should I put together a new patch for that? If so, should the patch > be attached to a new bug? Why don't you file a new bug and reference this.
I threw together a patch for this already. Filed bug 190231.