Closed hrueger closed 1 year ago
could you show me your node code causing this crash ?
Thanks for the fast response. I'll try to find the exact call. It's a pretty complex project, it might take a while.
So, I've finally found it. This is the code:
const SoundMixer = require("native-sound-mixer").default;
const pollInterval = setInterval(() => {
for (const device of SoundMixer.devices) {
console.log(device, device.volume);
}
}, 500);
It works find for the first 6 iterations, then in the 7th one it crashes. However, I was not able to reproduce that in a standalone example, I don't know why. It is definitely that line, though, as it works fine if I comment it out.
It does not matter if I read the mute
or the volume
property by the way.
Are you using the call in a multi threaded context ? It looks like the problem is the same as this one https://github.com/nodejs/node-addon-api/issues/779. I can hardly fix the code right now, i'll try to make it as fast as I can.
I am using Worker Threads on my application, but this library is used in the main thread.
I might have located the problem, i'll try to fix it as soon as possible.
Thanks in advance!
Since the bug is not reproductible in a standalone, it will be hard to test the code on my side. I can still push the fix on develop and you can test it before I push a new version if that's ok for you ๐. Otherwise, I will push the fix to a new version on npm registry but I can't be sure it will fix the problem ...
I can still push the fix on develop and you can test it before I push a new version if that's ok for you
Sure ๐
It took longer than I expected, I should be done by next week I guess.
No problem, thanks for your efforts ๐
I pushed something to 20-native-crash
branch, I have no clue whether it might be better but you can try anyway.
Hm, I can't even reproduce the original error anymore... Very strange.
However, while testing, I found that there may be a memory leak? Not sure, though. If you run the following code, you can see the memory usage of the Node Process increasing by about 1MB / s. Maybe this gives a hint? Could also be completely unreleated, though ;-)
const nsm = require("native-sound-mixer").default;
let mute;
let volume;
(async () => {
while (true) {
console.log("next round")
for (let i = 0; i < 1000; i++) {
for (const device of nsm.devices) {
mute = device.mute;
volume = device.volume;
}
}
await new Promise((resolve) => { setTimeout(() => { resolve(); }, 500); });
}
})();
If you can't reproduce the original error, I hope it was some strange node issue. Concerning the memory leak problem, I'm currently working on it. However, due to the way node handles memory, the memory should be flushed regularly, fixing the memory leak as it goes.
I hope it was some strange node issue
I agree ๐
Concerning the memory leak problem, I'm currently working on it.
Thanks a lot
The memory leaks concerning the devices should be fixed on develop (for windows only)
Yes, can confirm that the memory leak is gone ๐ Thanks for your effort.
Hi, when trying to use this lib on a Windows 10 machine, my application crashed with the following error:
Any idea?