Skip to content

Apply new waveform colors without restarting SE (#13897) - #13898

Merged
niksedk merged 1 commit into
mainfrom
claude/fix-waveform-color-restart
Aug 20, 2026
Merged

Apply new waveform colors without restarting SE (#13897)#13898
niksedk merged 1 commit into
mainfrom
claude/fix-waveform-color-restart

Conversation

@niksedk

@niksedk niksedk commented Aug 20, 2026

Copy link
Copy Markdown
Member

Fixes #13897 — changing the waveform color or the selected waveform color only took effect after restarting SE, while every other waveform color changed instantly.

Root cause

The fancy draw style (the default) batches waveform columns by a quantized amplitude bucket and caches a pen per bucket. The bucket key carries no color at all, so:

  • _fancyWaveformPenCache / _fancyWaveformGradientCache / _fancyWaveformGlowPenCache hold pens painted in whatever color was current when that bucket was first drawn, and
  • _fancyBatches — the pooled batch dictionary, which keeps a Pen of its own — does too.

ResetCache() cleared the three pen caches but not _fancyBatches. So Settings -> OK did everything right (pushed the new colors, reset the caches, and the geometry cache key does include the colors), the geometry was rebuilt — and then stroked with the stale batch pens. Only a brand-new control, i.e. a restart, dropped them.

That is exactly the split reported: waveform color, selected color (and fancy high color, which the reporter probably did not try) are the only three that go through the fancy batch/pen cache. Background, cursor, shot change, paragraph left/right and text build a fresh brush in their setter and are drawn live, so they always updated at once. The classic draw style was never affected either — it uses _paintWaveform / _paintPenSelected, rebuilt in the setters.

Fix

  • New ResetFancyColorCaches() clears all four color-bearing caches together, and invalidates the visual (the color properties are not AffectsRender, so nothing else asked for the repaint).
  • Called from ResetCache() and from the WaveformColor / WaveformSelectedColor / WaveformFancyHighColor setters, so no caller has to remember to reset anything. WaveformFancyHighColor was a plain auto-property with no invalidation at all.

Tests

tests/UI/Controls/AudioVisualizerColorTests.cs renders a fancy waveform, changes a color, re-renders, and asserts the cached draw pens no longer carry the old color — for the waveform color (with and without an explicit ResetCache()), the selected color, and the fancy high color.

All 4 fail on main and pass with the fix; the full UI suite (3246 tests) passes.

The fancy draw style batches waveform columns by a quantized amplitude
bucket and caches a pen per bucket. The bucket key carries no color, so
the pen/gradient/glow caches - and the pooled _fancyBatches dictionary,
which holds a pen of its own - keep painting in whatever color was
current when the bucket was first seen.

ResetCache() cleared the three pen caches but not the batches, so
Settings -> OK rebuilt the waveform geometry and then stroked it with
the stale batch pens: waveform color, selected color and fancy high
color only showed up after a restart, while every other waveform color
(background, cursor, shot change, paragraph left/right, text) updated
at once because those build a fresh brush in their setter.

Clear all of them together in ResetFancyColorCaches(), call it from
ResetCache() and from the three color setters, and invalidate the visual
there - the color properties are not AffectsRender, so nothing else asks
for the repaint.

Fixes #13897

Co-Authored-By: Claude Opus 5 <[email protected]>
@niksedk
niksedk merged commit aa414f1 into main Aug 20, 2026
1 check passed
@niksedk
niksedk deleted the claude/fix-waveform-color-restart branch August 20, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

waveform color change require restart SE

1 participant