p5.js-sound icon indicating copy to clipboard operation
p5.js-sound copied to clipboard

Chrome issue: TypeError: Cannot read property 'addModule' of undefined

Open xuan-91 opened this issue 5 years ago • 13 comments

Screen Shot 2020-04-24 at 5 58 04 PM

xuan-91 avatar Apr 24 '20 21:04 xuan-91

same issue here...it is weird, because I had the same code 2 days ago and the error was not there. It just appeared when I ran it today. I wonder if it has to do with some Chrome update/changes?

teo523 avatar Apr 28 '20 11:04 teo523

Hi again @xuan-91 , I found this was solved already here. The problem is when using HTTP protocol instead of HTTPS. I did it and it worked out. I hope it works for you too.

teo523 avatar Apr 28 '20 13:04 teo523

Hi again @xuan-91 , I found this was solved already here. The problem is when using HTTP protocol instead of HTTPS. I did it and it worked out. I hope it works for you too.

Hi teo523, thank you for mentioning this, mine is working now!

xuan-91 avatar May 01 '20 02:05 xuan-91

How do I solve it If for some reasons I can't use HTTPS?

mcw256 avatar May 14 '20 21:05 mcw256

How do I solve it If for some reasons I can't use HTTPS?

You can use a tunnel to your localhost. For instance, ngrok creates a HTTPS URL that refers to your localhost, and it's for free!

teo523 avatar May 15 '20 18:05 teo523

@teo523 Thanks for the tip! The latest version of p5.sound 3.1.2 had broken the ability to locally network a sketch (on macos machines, using http://name.local:xxxx ) – since it's technically not 'localhost' anymore. Previously it failed quietly, obviously not able to use the mic, but now it returned this 'addModule' bug preventing whole sketch from loading – this ngrok totally solves the issue for linking machines via an https tunnel.

ffd8 avatar Jun 29 '20 15:06 ffd8

Hi, the HTTPS thing worked for me

ThatCoolCoder avatar Aug 14 '20 05:08 ThatCoolCoder

Confirming that HTTPS solved this problem for me, too. Thanks, @teo523

robzach avatar Aug 19 '20 15:08 robzach

This is still broken on Safari/Chrome. And progress on this?

pdeveltere avatar Feb 03 '21 15:02 pdeveltere

You can work around this using the GoogleChromeLabs audioworklet-polyfill. However, I found it irksome that the GoogleChromeLabs pollyfill hasn't had a release published since it was updated to fix this issue, so I forked it and published an updated npm package. You can workaround this issue by adding this to your HTML:

<script src="https://unpkg.com/@free-side/audioworklet-polyfill/dist/audioworklet-polyfill.js"></script>

sflanker avatar May 16 '21 00:05 sflanker

@sflanker 's solution works perfectly for those looking for a quick fix even a year+ later.

MatterL avatar Oct 13 '22 19:10 MatterL

@MatterL Where in your React app did you add this line of HTML? I tried adding it in the <body>, but it didn't work for me.

msamogh avatar Oct 13 '22 20:10 msamogh

@MatterL Where in your React app did you add this line of HTML? I tried adding it in the <body>, but it didn't work for me.

You're going to want it up in the HEAD, I put it directly under where I imported the p5.js library. So my script imports look like this:

<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/addons/p5.sound.js"></script>
<script src="https://unpkg.com/@free-side/audioworklet-polyfill/dist/audioworklet-polyfill.js"></script>
</head>
<body>
 Body here-
</body>
</html>

Hope this helps.

MatterL avatar Oct 14 '22 17:10 MatterL