-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio starts jittering the more sounds are played #396
Comments
but i don't have 500 nodes connected at a given time, After the hundreds of sounds play, everything should be disconnected and cleared, |
Right, I misunderstood. Changing my stress test to run less nodes concurrently but checking the load for a longer running time, I can't seem to reproduce this issue. Are you sure the In the current implementation, we don't free up audio processor resources when the control thread still holds on to the corresponding AudioNode. I believe @b-ma already mentioned that we should not do this in case the node has ended/stopped and cannot be started again but this is not implemented yet: #397 Tangentially, we should probably add an |
Hey, I'm a bit surprised too with these numbers because this looks almost the same setup (maybe even less demanding) as in the In this example the period between each grain is 0.01 sec and their duration is 0.2 seconds, which means we spawn a 100 sources / second with 20 sources are overlapping at every moment. Do you have the same issue if you run this example? |
The only difference I can think of is the size of the |
Just another question, is your source looping? |
I have some looping, but they only play 20 times. The ones that play hundreds of times are not looping and are less than 0.5 seconds in duration. |
Really strange... Does it helps if you explicitly impl Drop for Sound {
self.source_node.stop();
// this is not mandatory then, but doesn't hurt
self.source_node.disconnect();
self.gain_node.disconnect();
} |
using stop doesn't fix the issue. |
https://github.com/cybersoulK/debug_web_audio_api |
Hey, thanks for the example, I think I managed to make it work by just doing: impl Drop for Sound {
fn drop(&mut self) {
// self.source_node.disconnect();
// self.gain_node.disconnect();
}
} But I have no idea of the why, this is a bit problematic... If I leave any of the Just asking myself and maybe this is because we have only part of the code, but I don't understand why you keep this list of active nodes? You could just spawn them and forget them right away |
Hah, now this is interesting. It's a manifestation of the bug I just fixed in 7b048c2 The fix addresses the issue that I haven't tested it yet but I'm convinced this issue does not occur on the
Indeed. The Web Audio API deals with this for you via dynamic lifetimes, search "fire and forget" on https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode |
i confirm that the current master solved the issue |
Great to hear! Thanks to your bug report we fixed a logic bug and a performance issue. And we're prepping up a method to better aid users in submitting diagnostics via #401 I will publish a new release of the library this weekend. |
after a few hundred source nodes connect and disconnect, there are a lot of loud pops or sound jitter. / abrupt interruptions (some leak in web-audio-api or cpal usage?)
pop.mp3.zip (internal recording of the bullets sounds,
Render capacity shows increasing numbers:
I used kira.rs with the cpal backend, and it never did this.
I just compared them side by side with exact same sound conditions.
My minimal code for each sound that plays:
and later when the sound stops:
I made sure that all of the sounds are being dropped and their nodes disconnected
The text was updated successfully, but these errors were encountered: