I am struggling to have my AudioWorkletNode work 100% of the time without any audio drops or glitches. Actually, it seems that it is able to render (the 128 frames) it in about 2ms, which seems pretty decent. I'm also using the latencyHint: playback option for the AudioContext.
Here you have the results of a profiling:
I see a lot of space between each audio render call, so I guess it is OK:
I am using Electron 16, based on Chromium 96.
Using Window's Process Explorer, I have identified the process responsible of the Audio work, and it is running in Normal priority (8), not in real-time priority. When the application gets into background (not focused), that is when the glitches may start appearing, very occasionally, but annoyingly.
From what I read here https://bugs.chromium.org/p/chromium/issues/detail?id=813825#c33, it seems that the thread should run in real-time priority.
Could anyone clarify? Am I missing something here?



You are looking at the process priority, not the thread priority. In process explorer with the process selected you should be able to see threads below it and the priority level should be 26.