Using ScriptProcessorNode | Anywhere | Deprecated; runs on main thread โ dropouts under UI load |
new Float32Array(...) inside process() | AudioWorkletProcessor.process() | GC allocation โ potential pause during render |
Creating objects/arrays/closures inside process() | AudioWorkletProcessor.process() | GC pressure โ jitter |
port.postMessage() every process() block | AudioWorkletProcessor | High overhead; batch updates or use SharedArrayBuffer |
Accessing window, document, or DOM from worklet | process() or worklet scope | Worklet thread has no DOM access โ throws ReferenceError |
Importing non-worklet-safe modules in addModule() | Worklet module file | DOM APIs throw; do network/file loading on the main thread and pass data in |
| Not handling autoplay policy | AudioContext creation | Context starts suspended; must resume on user gesture |
SharedArrayBuffer comms without integer Atomics protocol | Worklet โ main comms | Race-prone shared state โ Atomics works on integer typed arrays, not Float32Array |
Changing AudioNode graph from worklet thread | process() | connect()/disconnect() are main-thread-only |
| Assuming a hardcoded render quantum in loops/buffers | process() | Spec and browsers use 128-frame quanta today, but code should use output[channel].length |
Forgetting await audioContext.resume() | After user gesture handler | Stays suspended; no audio output |