Skip to content

fix(chart): let the render path rest when idle - #105

Merged
mrcsin merged 1 commit into
masterfrom
render-path
Oct 2, 2026
Merged

mrcsin merged 1 commit into
masterfrom
render-path

Conversation

@mrcsin

@mrcsin mrcsin commented Oct 2, 2026

Copy link
Copy Markdown
Member

Problem

Group F of docs/plans/20260929-window-per-process.md (Tasks 11-14):

  • the chart's redraw ran through Sample(33 ms), a periodic timer that woke the UI thread every 33 ms for the chart's whole life, idle or not;
  • RenderFinished read a view field on the render thread that the UI thread wrote;
  • the column buffer shifted 100 000 columns on every append past its cap;
  • a sidebar box and the chart each wrote a pen's visibility, kept apart by _isSettingVisibilityFromChart.

What changed

  • ChartRedrawSchedule: one emission 33 ms ahead, later requests join it, nothing scheduled while no view subscribes, Dispose cancels a pending one.
  • TrendChartView.ReportDataAreaWidthTo(TrendChartViewModel): each frame's width goes to the view model it was drawn for, on the UI thread; SetTargetColumnCount drops a repeat.
  • EnvelopeLine trims MaxColumns / 10 at once.
  • TrendPenState.IsVisible has a private setter and one writer, SetPenVisibility. The row box binds it OneWay and writes through ToggleVisibilityCommand; the group switch takes the same route. The row binds name, colour and unit through PenState.Pen, so a revised pen shows without a rebuild.
  • Two tests that raced the code under load now wait for the event they assert on: ChartHistoryRequestCancellationTests (AwaitStart), and the settings restart tests in StartupFailureWindowTests, MainWindowViewTests, SettingsViewTests (the button's IsEffectivelyEnabled).
  • CLAUDE.md, charting.md, trend-interaction.md, bench.md, testing-strategy.md, trend-feature-spec.md follow the code.

Verification

  • dotnet build SemiPlot.slnx: 0 warnings. Unit 1591/1591, integration 138/138.
  • Acceptance Evidence item 6 grep prints nothing; AppendingPastTheCapTrimsOneChunk and AnIdleChartSchedulesNoRedraw pass. The plan's "Verify it yourself" lists every new test.
  • Manual run on the demo stand: sidebar boxes, group switch, pen unit and name edits, resize, idle CPU.
Per-task commits before collapse
33acadd docs(plans): record the render-path run
efbc7d8 refactor(chart): drop restating comments
90d1335 refactor(chart): address smells findings
762c4ff fix(chart): address review findings
1165db1 refactor(legend): give pen visibility one writer
6915c4d fix(chart): let an idle chart schedule no redraw
4eb4f6c fix(chart): keep the data-area width on the UI thread
f6c26f3 fix(chart): trim the column buffer in chunks

https://claude.ai/code/session_01PfZJa7neMMKPzycFR6iuhD

The chart's redraw ran through Sample(33 ms), a periodic timer that woke
the UI thread every 33 ms for the chart's whole life, idle or not. The
render thread read a view field the UI thread wrote, the column buffer
shifted 100 000 columns on every append past its cap, and a sidebar box
and the chart each wrote a pen's visibility, kept apart by a guard flag.

A redraw request now schedules one emission 33 ms ahead; requests inside
that span join it, nothing is scheduled while no view subscribes, and
Dispose cancels a pending one. The schedule lives in ChartRedrawSchedule.
RenderFinished posts every frame's width to the view model the frame was
drawn for, on the UI thread, and SetTargetColumnCount drops a repeat. The
buffer trims one tenth of its cap at once.

TrendPenState.IsVisible has one writer, SetPenVisibility: its setter is
private, the row box reads it one way and writes through its command, and
the group switch takes the same route. The sidebar row binds the pen's
name, colour and unit through the pen state, so a revised pen shows at
once.

Two tests that raced the code under load now wait for the event they
assert on: the history cancellation test for the read to start, and the
settings restart tests for the button to be enabled.

Claude-Session: https://claude.ai/code/session_01PfZJa7neMMKPzycFR6iuhD
@mrcsin
mrcsin marked this pull request as ready for review October 2, 2026 11:26
@mrcsin
mrcsin merged commit 0dcbc54 into master Oct 2, 2026
2 checks passed
@mrcsin
mrcsin deleted the render-path branch October 2, 2026 11:30
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.

1 participant