Repository navigation
[ryoku] visualizer: read spectrum bands once per frame - #1064
Open
0-FoxHunt-0 wants to merge 1 commit into
Open
0-FoxHunt-0 wants to merge 1 commit into
0-FoxHunt-0 wants to merge 1 commit into
Conversation
Motion.rawLevel read Spectrum.levels inside the per-band loop. That property is a readonly list<real> fed by the C++ CavaFeed, and every JS read converts the whole list into a fresh array, so 128 bands at 60 fps meant 128 array conversions a frame on the shell's single GUI thread. The allocations kept the collector active and the thread climbed from 17% to 99% of a core in about 90 s, with RSS rising from 2.1 to 3.9 GiB, then the desktop hitched because both 240 Hz panels had 4.2 ms to commit a frame. Read the list once in tick() and pass it into rawLevel(i, src), which still falls back to Spectrum.levels for any other caller. Measured from a fresh shell at 128 bars and 60 fps with peaks and mirror on: 5-6% of a core after 5 s, 6% after 90 s and 5-6% after 180 s, with RSS flat instead of climbing. Note: Fixed: the desktop audio visualizer no longer drags the shell into the garbage collector after a few minutes of music
Member
🦊 mika's reviewNo actionable findings. Mika looked for bugs, security issues, and risks in the diff and came up empty on clear defects.
🦊 Generated by Mika — the Ryoku org's self-hosted AI code reviewer. Machine findings: verify before merging. |
This branch has not been deployed
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.
What changed
Motion.rawLevelreadSpectrum.levelsinside the per-band loop. Thatproperty is a
readonly list<real>fed by the C++CavaFeed, and every JSread converts the whole list into a fresh array. At 128 bands and 60 fps the
visualizer therefore made 128 array conversions a frame, on the one Qt Quick
GUI thread that also draws the bar, the dock and every desktop surface.
The list is now read once in
tick()and passed intorawLevel(i, src).srcdefaults toSpectrum.levelswhen omitted, so any other caller keepsworking unchanged.
On this machine the shell's GUI thread climbed from 17% to 99% of a core in
about 90 s with music playing, RSS went from 2.1 to 3.9 GiB and then stayed at
that plateau, and the desktop hitched or appeared to freeze. Both panels are
240 Hz, so a commit only has 4.2 ms to land and a thread that never idles
misses the blank. Lowering the visualizer to 30 fps only moved the plateau to
64%, so frame rate was not the cure.
Area
ryoku
How it was tested
On a running CachyOS desktop (TheFoxDen), Ryoku on the
hyperioncheckout,Hyprland, two 1920x1080 panels at 240 Hz, visualizer at 128 bars, 60 fps,
style
segments, mirror and peaks on, music playing through cava. I measuredthe shell process's GUI thread with
se.sum_exec_runtimeand its RSS from/proc/<pid>/status, restarting the shell fresh for each run.Before the change:
After the change, same settings and same measurement:
A 16-bar run after the change went from 3% to about 10% over 60 s, which
matches the band-count scaling: the remaining allocation grows with bars but
is a different source (
SpectrumField.push()rewriting its peak uniforms).Gates run in the worktree:
qmllinton the changed file: clean.bin/ryoku-dev-lint-qmlonmodules/visualizer: clean.bin/ryoku-dev-verify-qml-bindings: no property set twice.bin/ryoku-dev-scan-slop --staged: clean..githooks/pre-commitand.githooks/commit-msgpass.The fix has also been running live from the checkout through the usual local
override for several hours without a QML error or a regression in any look
(bars, segments, ring, scope).
Checklist
[ryoku] scope: summarycommit subject.CHANGELOG.mdupdated in the area I touched (ryoku/shell/CHANGELOG.md).--no-verify.luac -p), shell scripts passbash -n, and QML passesqmllintwhere applicable.the allocation pattern, so only the changelog needed a line.
Confidence Score: 5/5

The PR appears safe to merge.Summary
The visualizer now reads
Spectrum.levelsonce pertick()and passes it to eachrawLevel()call.No actionable issues found. Review was based on source checks; no runtime tests were run.
Reviews (1) · Last reviewed commit: "[ryoku] visualizer: read spectrum bands ..." · Reviewed by Greptile