gillesdemey / node-record-lpcm16

:microphone: Records a 16-bit signed-integer linear pulse modulation code encoded audio file.
ISC License
212 stars 59 forks source link

Recording is delayed by several seconds when used in a packaged Electron app #51

Closed BenBergman closed 5 years ago

BenBergman commented 5 years ago

I have been developing an Electron app using this library. It works great when I run it with npm start, but if I package the app all audio is ignored for about 5 seconds. I have tested this on multiple machines. The delay is slightly different depending on the machine but is still present.

I'm working on creating a minimal reproduction of my code but figured I should post this already in case someone else has experienced this.

BenBergman commented 5 years ago

While trying to make a minimal reproduction of this issue, I created a new Electron project that just starts recording to a file immediately on launch. After resolving $PATH issues this app works just fine, so it seems my delay issue may be due to my own code.

One thing I did notice though is that with record in verbose mode my record.start() prints that it is starting recording exactly when I expect it to but only starts reporting data about 5 seconds later.

BenBergman commented 5 years ago

Just to test things out, I tried spawning a different command than rec to see if spawn in my app was slow, but a spawn('date') gives me data effectively instantly. I also tried stripping out a bunch of code from my app unrelated to the audio capture. This reduced my delay from about 5 seconds to 2 or 3 seconds. This is implying to me that there is some cumulative slow down. Again, no delay is seen if just run with electron .

BenBergman commented 5 years ago

I am developing on macOS Mojave and discovered that if I sign the app the issue goes away. I can also explore the contents of the unsigned .app and run the executable directly and there is no issue.