Repository navigation
Conversation
Move 4096-point Hann FFT calculation from the JavaScript main thread to the background meter tick in Rust using realfft. Emit pre-binned 80 dB values over audio://spectrum instead of streaming 8192 raw PCM float samples over IPC. Replace dynamic SVG rect re-creation with HTML5 2D canvas in the spectrum component to eliminate DOM reconciliation overhead. Add teardown to tauri event listeners to prevent memory accumulation in WebView2.
Horuse
requested changes
Oct 15, 2026
Horuse
left a comment
Owner
There was a problem hiding this comment.
Thanks for contributing to the project! This is a pretty serious issue that I hadn't noticed, and I appreciate you fixing it. A few things before merging:
- The canvas is blurry on Retina because it's sized in CSS pixels. It needs devicePixelRatio scaling; waveform_scope.svelte (~line 790) already does this.
- The spectrum story in Storybook is empty now: src/stories/harness/signal.ts still sends raw audio://scope data for spectrum. It should send bars on audio://spectrum.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a severe memory leak and CPU bottleneck in the Spectrum node on WebView2 / Windows.
Prior to this change:
audio://scope) at ~25-30 Hz. In Tauri on Windows, eachemittranslates to an inter-process COMExecuteScriptcall with JSON serialisation, which flooded V8 heap memory up to 5.15 GB and pinned CPU at ~13%.<rect>nodes on every animation frame, triggering continuous DOM reconciliation overhead.Changes
realfftdependency. Moved 4096-point Hann FFT and 80-bin logarithmic power aggregation into the background meter thread (meter-tick). It now emits a lightweight payload of 80 dB floats overaudio://spectrum.spectrum.svelteto a flat HTML5 2D Canvas (fillRect), keeping axes and labels as crisp vector SVG overlays.tauriListento return an explicit cleanup function and guard against listener leaks during component unmount races.Results
Dependency Note
Added
realfft = "3.4"tosrc-tauri/Cargo.tomlwithopt-level = 3in dev profile. RealFFT was chosen because it operates purely on real-valued inputs with half the memory and computation overhead compared to general complex FFTs.Verification