Skip to content
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

perf: put some code inside a Worker #88

Open
WofWca opened this issue Jul 14, 2022 · 0 comments
Open

perf: put some code inside a Worker #88

WofWca opened this issue Jul 14, 2022 · 0 comments

Comments

@WofWca
Copy link
Owner

WofWca commented Jul 14, 2022

Worker should offload the main thread. But I'm not sure what code we can put inside of it. FYI audio processing is already done inside AudioWorkletProcessors, which are run on a separate thread.

Reason: it's best for silenceDetector.onmessage (specifically in the StretchingController) listener to get executed as fast as possible because it is responsible for playback rate changes.

It thought that the best thing would be to put the silenceDetector.onmessage listener to a Worker and that's it, but unfortunately DOM is not accessible from inside workers, so I thought maybe we could go the other way around and put everything else inside a Worker. For example, all the event listeners (addEventListener and onMessage). They also usually access DOM, so we're gonna need some interfacing as well. Although I'm not sure if sending data to a Worker would be more efficient than just processing the event in-place.

Another idea I had is to put a bunch of queueMicrotasks (or setTimeouts) everywhere across the code so that it has a chance of getting interrupted by the silenceDetector.onmessage listener.

Also need to keep in mind the requestIdleCallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant