fix(build): the build's details lay out only the lines in view, and at most five times a second #233

Merged
HumanBean merged 1 commit from HumanBean/LongshotLauncher:fix/build-log-freeze into main 2026-11-21 19:15:48 +00:00
Owner

During a build the launcher stops answering: switching the details from Trace back to Info, or just scrolling the log, freezes the window for a minute or more. Each of the build's lines rebuilt and laid out again the whole 2000-line log text on the UI thread, about half a second each, even for lines the chosen level hides.

Fixes #201

Summary

  • App/Views/BuildStepView.axaml: the details' lines are an ItemsControl on a VirtualizingStackPanel (inside the same LogScroll), one SelectableTextBlock per line with its coloured prefix, so only the lines in view are laid out. Before, it was one SelectableTextBlock of 2000 lines × 3 inlines, rebuilt and re-measured whole.
  • App/Views/Views.cs (BuildStepView): a LogText change writes the lines at most every 200 ms (one DispatcherTimer), and not at all when the lines shown are the same (a line the level or search leaves out, the build's 1 s tick). A new level, a search or opening the details still writes at once and goes to the bottom. Following the bottom / staying put when scrolled up is unchanged.
  • tests/launcher_core/LogChecks.cs: checks the virtualized panel and the throttle/skip in the source.

Trade-off: text is now selected one line at a time (each line is its own SelectableTextBlock) rather than across lines; the build report still carries the log.

The page looks the same as before (checked with the build-log screenshot scene), so no screenshot.

Testing

A headless benchmark (Avalonia.Headless, the real BuildStepView and BuildStepViewModel, 100,000 lines already in the log, 19 of each 20 debug/trace, lines posted to the UI thread the way MakeGameRun posts them), on this Linux PC:

main this branch
Open the details at Trace 1648–2239 ms 250–374 ms
Each new line while following, at Trace 257–459 ms < 0.01 ms (written at most 5×/s)
Each new line at Info (hidden trace lines) 241–428 ms < 0.01 ms
Trace → Info 255–471 ms 33–63 ms
5000 lines/s for 3 s, at Trace UI thread 100 % busy, one turn 11.3 s, only 50 lines handled UI busy 10 %, longest turn 33 ms, ~15,750 lines handled, no backlog
Same, at Info 100 % busy, one turn 13.8 s UI busy 6 %, longest turn 13 ms
Scroll step (with a new line each) 345–579 ms 7.5 ms
  • python -I tests/test_launcher_core.py: 2601 checks passed.
  • LAUNCHER=$PWD python -I ../Tooling/tests/test_release.py: 39 of 42 pass; the 3 failures (test_the_bump, test_the_next_stable, test_check_tag_against_the_published_releases) are about git tags in the release script and don't touch any file this PR changes.

🤖 Generated with Claude Code

During a build the launcher stops answering: switching the details from Trace back to Info, or just scrolling the log, freezes the window for a minute or more. Each of the build's lines rebuilt and laid out again the whole 2000-line log text on the UI thread, about half a second each, even for lines the chosen level hides. Fixes #201 ## Summary - `App/Views/BuildStepView.axaml`: the details' lines are an `ItemsControl` on a `VirtualizingStackPanel` (inside the same `LogScroll`), one `SelectableTextBlock` per line with its coloured prefix, so only the lines in view are laid out. Before, it was one `SelectableTextBlock` of 2000 lines × 3 inlines, rebuilt and re-measured whole. - `App/Views/Views.cs` (`BuildStepView`): a `LogText` change writes the lines at most every 200 ms (one `DispatcherTimer`), and not at all when the lines shown are the same (a line the level or search leaves out, the build's 1 s tick). A new level, a search or opening the details still writes at once and goes to the bottom. Following the bottom / staying put when scrolled up is unchanged. - `tests/launcher_core/LogChecks.cs`: checks the virtualized panel and the throttle/skip in the source. Trade-off: text is now selected one line at a time (each line is its own `SelectableTextBlock`) rather than across lines; the build report still carries the log. The page looks the same as before (checked with the `build-log` screenshot scene), so no screenshot. ## Testing A headless benchmark (Avalonia.Headless, the real `BuildStepView` and `BuildStepViewModel`, 100,000 lines already in the log, 19 of each 20 debug/trace, lines posted to the UI thread the way `MakeGameRun` posts them), on this Linux PC: | | main | this branch | |---|---|---| | Open the details at Trace | 1648–2239 ms | 250–374 ms | | Each new line while following, at Trace | 257–459 ms | < 0.01 ms (written at most 5×/s) | | Each new line at Info (hidden trace lines) | 241–428 ms | < 0.01 ms | | Trace → Info | 255–471 ms | 33–63 ms | | 5000 lines/s for 3 s, at Trace | UI thread 100 % busy, one turn 11.3 s, only 50 lines handled | UI busy 10 %, longest turn 33 ms, ~15,750 lines handled, no backlog | | Same, at Info | 100 % busy, one turn 13.8 s | UI busy 6 %, longest turn 13 ms | | Scroll step (with a new line each) | 345–579 ms | 7.5 ms | - `python -I tests/test_launcher_core.py`: 2601 checks passed. - `LAUNCHER=$PWD python -I ../Tooling/tests/test_release.py`: 39 of 42 pass; the 3 failures (`test_the_bump`, `test_the_next_stable`, `test_check_tag_against_the_published_releases`) are about git tags in the release script and don't touch any file this PR changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(build): the build's details lay out only the lines in view, and at most five times a second
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 16s
83a2dcdb5a
Each line of a build rebuilt one SelectableTextBlock of the 2000 lines shown and laid it out again on the UI thread, about half
a second each, even for a line the level left out: at Trace's thousands of lines a second the window stopped answering, and
switching back to Info or scrolling waited behind that queue (#201). The lines are now a VirtualizingStackPanel's, written at
most every 200 ms and only when the lines shown changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean deleted branch fix/build-log-freeze 2026-11-21 19:15:50 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/LongshotLauncher!233
No description provided.