Skip to content

[ryoku] visualizer: read spectrum bands once per frame - #1064

Open
0-FoxHunt-0 wants to merge 1 commit into
Ryoku-dev:unstable-devfrom
0-FoxHunt-0:visualizer-levels-hoist
Open

0-FoxHunt-0 wants to merge 1 commit into
Ryoku-dev:unstable-devfrom
0-FoxHunt-0:visualizer-levels-hoist

Conversation

@0-FoxHunt-0

@0-FoxHunt-0 0-FoxHunt-0 commented Dec 5, 2026 •

Copy link
Copy Markdown

What changed

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. 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 into rawLevel(i, src).
src defaults to Spectrum.levels when omitted, so any other caller keeps
working 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 hyperion checkout,
Hyprland, two 1920x1080 panels at 240 Hz, visualizer at 128 bars, 60 fps,
style segments, mirror and peaks on, music playing through cava. I measured
the shell process's GUI thread with se.sum_exec_runtime and its RSS from
/proc/<pid>/status, restarting the shell fresh for each run.

Before the change:

elapsed GUI thread
5 s 17%
45 s 83%
90 s 98-99%
180 s 99%

After the change, same settings and same measurement:

elapsed GUI thread RSS
5 s 4% 2079 MiB
15 s 5% 2108 MiB
30 s 5% 2151 MiB
90 s 6% sawtooth, no climb
180 s 5-6% sawtooth, no climb

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:

  • qmllint on the changed file: clean.
  • bin/ryoku-dev-lint-qml on modules/visualizer: clean.
  • bin/ryoku-dev-verify-qml-bindings: no property set twice.
  • bin/ryoku-dev-scan-slop --staged: clean.
  • .githooks/pre-commit and .githooks/commit-msg pass.

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

  • One logical change, with a clear [ryoku] scope: summary commit subject.
  • Matching CHANGELOG.md updated in the area I touched (ryoku/shell/CHANGELOG.md).
  • The git hooks pass locally; I did not use --no-verify.
  • Lua parses (luac -p), shell scripts pass bash -n, and QML passes
    qmllint where applicable.
  • No duplicated config, no dead code, no commented-out code, no em-dash.
  • Docs updated if behavior or layout changed. Behavior is unchanged, only
    the allocation pattern, so only the changelog needed a line.

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge.

Summary

The visualizer now reads Spectrum.levels once per tick() and passes it to each rawLevel() call.

  • The visualizer reads its audio bands once per frame.

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

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
@neur0map

neur0map commented Dec 5, 2026

Copy link
Copy Markdown
Member

🦊 mika's review

No actionable findings. Mika looked for bugs, security issues, and risks in the diff and came up empty on clear defects.

⚠️ Partial run: describe: after 3 attempts: llm: hermes rate_limited; review: after 3 attempts: llm: hermes rate_limited


🦊 Generated by Mika — the Ryoku org's self-hosted AI code reviewer. Machine findings: verify before merging.

@neur0map neur0map added area:ryoku Ryoku project area type:bug A reported problem labels Dec 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ryoku Ryoku project area type:bug A reported problem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants