gibber-cc / gibberish

Fast, JavaScript DSP library that creates JIT optimized audio callbacks using code generation techniques
387 stars 35 forks source link

Packing/Minifying breaks constructors of polytemplate based instruments #34

Open Cygnusfear opened 3 years ago

Cygnusfear commented 3 years ago

Hey there, wanted to say Genish/Gibberish are incredible!

I've been playing around with it for a bit but then ran into an issue including it in a project. I eventually discovered the polyphonic instruments based on polytemplate.js and the poly mixins no longer work once gibberish.js is minified. The gibberish_worker is no longer able to properly parse or recognize their constructors.

Have quickly glanced over the polytemplate.js code but I saw some comments about the proxy code being a nightmare and I have to say I don't understand enough of what's going on there or in Genish to be able to jump in and fix the issue. Though I would've liked to.

Thank you for the awesome work!

Edit: attached the errors thrown by the AudioWorklet for clarification

Screenshot 2021-03-02 at 17 51 40
charlieroberts commented 3 years ago

Hi and thanks for the kind words! There's code generation that relies on some global names to exist in the audio thread, and my guess is that minification breaks this. Can you configure the minifier to not shorten variable names? Not sure how much file size reduction you'd get after this but could still be a helpful amount... keep me posted!

Cygnusfear commented 3 years ago

Hola! Yeah I had a feeling there was some sort of reflection going on being broken by the minifier. I initially used it in a create-react-app and I was trying to avoid ejecting the whole project for now. To verify I did an isolated test with a minifier and got the same issue.

I'm sideloading it now so my issues are fixed. But since the whole gibberish lib is on the heavy side I would be curious and willing to look for a fix if you could hint me at where this code gen is happening.