You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Audio capture drives AudioEngine.handleAudioChunk on the main thread, doing resample checks, energy + SMA, VAD (AudioSegmentProcessor), visualization summary, segment extraction, and subscriber callbacks.
Capture is active even when model is not ready (v4 path), so this work runs continuously.
Evidence
Main thread active time in trace: main_thread.total_dur_ms = 21958.8ms over 29.7s.
Hot path locations: src/lib/audio/AudioEngine.ts (handleAudioChunk + updateVisualizationBuffer + notifyVisualizationUpdate), src/lib/audio/AudioSegmentProcessor.ts.
Hypothesis
Doing VAD + visualization summary + segment extraction on the main thread contributes to high CPU during capture.
Actions
Move VAD + energy computation into AudioWorklet or a worker and send only small metrics back.
Split visualization summary into a worker or throttle it to <30fps.
Guard processing when not recording or when UI is hidden.
Acceptance
Main-thread CPU usage drops measurably when recording with model not ready.
30s trace shows lower main-thread active time and fewer long tasks.
Context
AudioEngine.handleAudioChunkon the main thread, doing resample checks, energy + SMA, VAD (AudioSegmentProcessor), visualization summary, segment extraction, and subscriber callbacks.Evidence
main_thread.total_dur_ms= 21958.8ms over 29.7s.src/lib/audio/AudioEngine.ts(handleAudioChunk + updateVisualizationBuffer + notifyVisualizationUpdate),src/lib/audio/AudioSegmentProcessor.ts.Hypothesis
Actions
Acceptance