lichen-community-systems / Flocking

Flocking - Creative audio synthesis for the Web
GNU General Public License v2.0
697 stars 60 forks source link

The MediaElementAudioSourceNode unit tests fail periodically in Chrome #230

Closed colinbdclark closed 6 years ago

colinbdclark commented 6 years ago

As mentioned by @the-t-in-rtf on #224, Flocking's Web Audio API-related tests have started failing on Chrome due to the implementation of its new autoplay policies. The error is:

"webaudio-tests.js:105 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD"

Since unit tests need to run without any user intervention, the only solution I can think of to address this is to ensure that testem sets the appropriate command line flag to disable the autoplay policy when launching Chrome. The (only) relevant flag that works is:

--autoplay-policy=no-user-gesture-required
the-t-in-rtf commented 6 years ago

Hi, @colinbdclark. A quick look through the Chromium command-line options suggests that we have a few ways to enable autoplay. You should be able to add one or more of those new flags to the browser args in your testem.json file. I linked to the one I'd start with if I were you, --no-user-gesture-required.

colinbdclark commented 6 years ago

Sadly --no-user-gesture-required, as well as any of the other apparently appropriate flags, don't work. The one above, fortunately, does. I'll submit a PR shortly.