From 7ba3c151344eea6ad91cd072ec8a4f4973f0af74 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sun, 23 Apr 2017 16:09:21 -0700 Subject: [PATCH] Work around Safari biquad filter bug! --- js/media.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/media.js b/js/media.js index fa65655c..b4e6aae3 100644 --- a/js/media.js +++ b/js/media.js @@ -82,7 +82,14 @@ export default { this._leftGain.connect(this._chanMerge, 0, 0); this._rightGain.connect(this._chanMerge, 0, 1); - const output = this._chanMerge; + // Safari, both mobile and desktop, has a bug where + // connecting a merger node to biquad filter node + // will cause it to crash. Adding this dummy node + // works around this bug. + const dummyNode = this._context.createAnalyser(); + this._chanMerge.connect(dummyNode); + + let output = dummyNode; this.bands = {}; BANDS.forEach((band, i) => { @@ -101,11 +108,9 @@ export default { } filter.frequency.value = band; filter.gain.value = 0; - /* - Disable this while we wait for Safari to fix its bug. + output.connect(filter); output = filter; - */ }); output.connect(this._gainNode);