michalochman / react-web-audio-graph

Interactive audio graph editor built with Web Audio API and React
https://michalochman.github.io/react-web-audio-graph/
MIT License
42 stars 8 forks source link

Double the expected AudioWorkletProcessors are created in development mode #10

Closed shyndman closed 2 years ago

shyndman commented 2 years ago

PR demonstrating the problem #9

Disabling hot module reloading resolves the issue. I have a feeling it could be an issue with worklet-loader, because it's based on worker-loader which had similar issues at some point.

michalochman commented 2 years ago

I can reproduce this. How did you disable HMR? I tried setting REACT_APP_FAST_REFRESH=false in the .env file with no luck.

michalochman commented 2 years ago

Also, did you mean "based on worker-loader"? Do you recall how it was fixed there?

michalochman commented 2 years ago

By the way, do you remember my comment https://github.com/michalochman/react-web-audio-graph/issues/8#issuecomment-974701370 about StrictMode? I have just removed it and the AudioWorkletProcessor is only created once. Why? I have no idea.

I do not want to spend much more time on this issue. If similar issue was happening in worker-loader and was fixed then maybe we can get it fixed in worklet-loader the same way. Otherwise we can drop StrictMode and only enable it when needed or ignore this issue altogether.

shyndman commented 2 years ago

Ah, sorry for disregarding that. I thought it seemed unrelated.

You know, I've actually mostly moved on to using Max (which, btw, is buggy but powerful). You wrote some great software, and it was fun learning some React, but I'm in it for the sound design. :)

michalochman commented 2 years ago

Thanks for the update 👍. I'm going to close this issue then, since the issues does not bother me.