WIP: Preload window: log name in the doc, whole-line log writes, own path shortening, lossy reads #467

Draft
Jesper-A wants to merge 1 commit from Jesper-A/Darner:up-preload-window-log-followups into Main
Collaborator

Refs #215

What it changes

Follow-up to #215 (merged at 0cea71f11). It answers the small points of the review and the 125 % report. All changes are in apps/darner/src/preload_ui.rs.

  1. Log name. The module doc said darner-preload-<time>.log; the file is darner-preload-<time>-<pid>.log (review point 1: #215 (comment)). The doc is fixed, and a test checks the source for it.
  2. Split lines. The two reader threads (stdout and stderr) each held a handle and used writeln!, which can write the text and the newline separately (review point 2). Now both share one handle behind a lock, and each line is built with its newline and written in one write_all (log_line). The child's own logger still appends through its own handle, so one of its lines can still land between two of ours. This only stops our two threads splitting each other's lines. A test runs two threads writing 500 lines each and checks that all 1000 come out whole.
  3. Path at 125 %. superhero-520 saw a 98-character zh-CN path lose the last g of .log at 120 DPI, while DT_PATH_ELLIPSIS did not shorten it (#215 (comment); review point 3). Now the window measures the text in the row's font (GetTextExtentPoint32W) and shortens the path itself (fit_path): the label at the start and the file name at the end stay, the middle becomes an ellipsis, and a file name too long for the row alone is cut from its left. A test checks this with one unit of width per character, including a wide-character label.
  4. Lossy reads. lines().map_while(Result::ok) stopped at the first line that was not valid UTF-8, so the rest of the child's output was lost and its pipe left to fill. lossy_lines turns bad bytes into U+FFFD and reads to the end (a read error ends the stream). A test covers \r\n, bad bytes and a last line with no newline.

The plan for these four was posted on #215 before the merge: #215 (comment)

How it was tested

  • Tested revision: branch up-preload-window-log-followups @ d6e0adf91, based on main 47d21cd3b.
  • Based on main 47d21cd3b. main is now d91d8e4d6; git merge-tree merges the branch cleanly there. Not rebased, not re-tested on the new main (WIP).
  • Commands and results: cargo clippy -p darner, with and without --all-features, and the darner tests for preload_ui, reported clean by the porter; exact flags and counts not kept. I did not re-run them for this text.
  • Changes a default: no. The window behaves as before except for the four points above. The log row's look changes only when the path does not fit.
  • A/B result: not applicable (no speed claim).
  • Gates run on that revision: scoped only. Not run: the workspace clippy (with and without --all-features) and cargo test --workspace --locked.
  • Gameplay: not run in game, and the window was not looked at.
  • Shader wave sizes tested: no shader change.
  • Hardware dependence: see "Spec dependence".
  • Coverage gaps, for the run before WIP: comes off:
    • The window at 100, 125 and 150 % scaling, in English and zh-CN, with a short and a 98-character and a 260-character log path: the label and the whole file name visible, no clipping. (The fit_path tests use a stand-in width, not the real font.)
    • A preload whose child prints bad UTF-8 on stderr keeps reading.
    • The log file after a real preload: no line split between the two parent threads.

Spec dependence

  • Likely general: window drawing and file writes, none specific to a card.
  • May depend on our specs: nothing known.
  • Untested elsewhere: other DPI settings, other fonts (Segoe UI and Microsoft YaHei UI are used), other Windows versions.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not run in game; the window not looked at.
  • This PR contains one change based on main: the follow-ups of one PR's review, all in one file.
  • The diff follows docs/asset-policy.md. (Text only.)
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs (open PRs only; file lists read through the API): #450 and #458 also change apps/darner/src/preload_ui.rs. #458 has one hunk (about line 566, in mod window), roughly 35 to 55 lines from our nearest hunks. #450 has hunks around the stderr reader and run (about lines 372 to 465 on main), several within a few lines of ours, so a textual conflict with #450 is possible. Line numbers come from each PR's own diff.
  • Replaces or overlaps: none found (no open PR makes these four changes).

This change was made with AI assistance (Claude Code).

Refs #215 ## What it changes Follow-up to #215 (merged at `0cea71f11`). It answers the small points of the review and the 125 % report. All changes are in `apps/darner/src/preload_ui.rs`. 1. **Log name.** The module doc said `darner-preload-<time>.log`; the file is `darner-preload-<time>-<pid>.log` (review point 1: https://git.gtahub.st/TrustNo1/Darner/pulls/215#issuecomment-862140). The doc is fixed, and a test checks the source for it. 2. **Split lines.** The two reader threads (stdout and stderr) each held a handle and used `writeln!`, which can write the text and the newline separately (review point 2). Now both share one handle behind a lock, and each line is built with its newline and written in one `write_all` (`log_line`). The child's own logger still appends through its own handle, so one of its lines can still land between two of ours. This only stops our two threads splitting each other's lines. A test runs two threads writing 500 lines each and checks that all 1000 come out whole. 3. **Path at 125 %.** superhero-520 saw a 98-character zh-CN path lose the last `g` of `.log` at 120 DPI, while `DT_PATH_ELLIPSIS` did not shorten it (https://git.gtahub.st/TrustNo1/Darner/pulls/215#issuecomment-862196; review point 3). Now the window measures the text in the row's font (`GetTextExtentPoint32W`) and shortens the path itself (`fit_path`): the label at the start and the file name at the end stay, the middle becomes an ellipsis, and a file name too long for the row alone is cut from its left. A test checks this with one unit of width per character, including a wide-character label. 4. **Lossy reads.** `lines().map_while(Result::ok)` stopped at the first line that was not valid UTF-8, so the rest of the child's output was lost and its pipe left to fill. `lossy_lines` turns bad bytes into U+FFFD and reads to the end (a read error ends the stream). A test covers `\r\n`, bad bytes and a last line with no newline. The plan for these four was posted on #215 before the merge: https://git.gtahub.st/TrustNo1/Darner/pulls/215#issuecomment-863822 ## How it was tested - Tested revision: branch `up-preload-window-log-followups` @ `d6e0adf91`, based on main `47d21cd3b`. - Based on main `47d21cd3b`. main is now `d91d8e4d6`; `git merge-tree` merges the branch cleanly there. Not rebased, not re-tested on the new main (WIP). - Commands and results: `cargo clippy -p darner`, with and without `--all-features`, and the `darner` tests for `preload_ui`, reported clean by the porter; exact flags and counts not kept. I did not re-run them for this text. - Changes a default: no. The window behaves as before except for the four points above. The log row's look changes only when the path does not fit. - A/B result: not applicable (no speed claim). - Gates run on that revision: scoped only. Not run: the workspace clippy (with and without `--all-features`) and `cargo test --workspace --locked`. - Gameplay: not run in game, and the window was not looked at. - Shader wave sizes tested: no shader change. - Hardware dependence: see "Spec dependence". - Coverage gaps, for the run before `WIP:` comes off: - The window at 100, 125 and 150 % scaling, in English and zh-CN, with a short and a 98-character and a 260-character log path: the label and the whole file name visible, no clipping. (The `fit_path` tests use a stand-in width, not the real font.) - A preload whose child prints bad UTF-8 on stderr keeps reading. - The log file after a real preload: no line split between the two parent threads. ## Spec dependence - Likely general: window drawing and file writes, none specific to a card. - May depend on our specs: nothing known. - Untested elsewhere: other DPI settings, other fonts (Segoe UI and Microsoft YaHei UI are used), other Windows versions. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). Not run in game; the window not looked at. - [x] This PR contains one change based on `main`: the follow-ups of one PR's review, all in one file. - [ ] The diff follows `docs/asset-policy.md`. (Text only.) - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs (open PRs only; file lists read through the API): #450 and #458 also change `apps/darner/src/preload_ui.rs`. #458 has one hunk (about line 566, in `mod window`), roughly 35 to 55 lines from our nearest hunks. #450 has hunks around the stderr reader and `run` (about lines 372 to 465 on main), several within a few lines of ours, so a textual conflict with #450 is possible. Line numbers come from each PR's own diff. - Replaces or overlaps: none found (no open PR makes these four changes). This change was made with AI assistance (Claude Code).
Follow-ups promised in the #215 thread (TrustNo1's small points, and
superhero-520's 125 % check):
- the module doc names the log darner-preload-<time>-<pid>.log;
- the parent's stdout and stderr threads share one handle behind a lock
  and write each line, newline included, in one write_all;
- the log path is shortened by measuring it (GetTextExtentPoint32W) and
  keeping the label and the file name, instead of DT_PATH_ELLIPSIS, which
  left a 98-character zh-CN path unshortened at 120 dpi;
- the child's output is read as lossy bytes to the end instead of
  stopping at the first line that is not valid UTF-8.

#215 itself is merged; this is a new branch off main.

This change was made with AI assistance (Claude Code).
Contributor

I retested the exact 98-character path from my #215 report on d6e0adf9110d353f53b07fe3b9ea4e05a9b7be34, Windows 11 build 26300.

Path rendering. At 120 DPI in zh-CN (Microsoft YaHei UI), the baseline selected a 694 px string for a 685 px row. None of the final g's 60 pixels appeared. This head shortened the string to 683 px, kept the filename and showed all 60 pixels. I also checked English and zh-CN at 96, 120 and 144 DPI with short, 98- and 260-character paths. All 18 rows on this head kept the label and full filename with no clipped ink. Six deliberately oversized basenames fitted by shortening from the left and keeping the suffix.

The matrix used the real Win32 fonts and the PR's paint code in a memory DC. Captures from the hidden windows' paint buffers matched at 96 and 144 DPI. The final window blit returned 0 in this session; the 120-DPI result is an offscreen rendering, with no physical 125% desktop check.

Log streams. I compiled the actual preload_ui::run from this head and its baseline into a standalone driver with a test child on native Windows pipes. Across six simultaneous stdout/stderr runs this head recorded all 196,662 expected lines, with no extras. It continued to parse progress after invalid UTF-8. The baseline lost subsequent progress in all three mixed-input runs.

One small difference remains in lossy_lines (line 386). On both streams the baseline preserved a payload carriage return in text\r\r\n and a bare \r at EOF; the new reader removes both. If log fidelity is intended, stripping only one LF and its optional preceding CR would preserve those payload bytes. These checks used generated input, without a game run.

I retested the exact 98-character path from my [#215 report](https://git.gtahub.st/TrustNo1/Darner/pulls/215#issuecomment-862196) on `d6e0adf9110d353f53b07fe3b9ea4e05a9b7be34`, Windows 11 build 26300. **Path rendering.** At 120 DPI in zh-CN (Microsoft YaHei UI), the baseline selected a 694 px string for a 685 px row. None of the final `g`'s 60 pixels appeared. This head shortened the string to 683 px, kept the filename and showed all 60 pixels. I also checked English and zh-CN at 96, 120 and 144 DPI with short, 98- and 260-character paths. All 18 rows on this head kept the label and full filename with no clipped ink. Six deliberately oversized basenames fitted by shortening from the left and keeping the suffix. The matrix used the real Win32 fonts and the PR's paint code in a memory DC. Captures from the hidden windows' paint buffers matched at 96 and 144 DPI. The final window blit returned 0 in this session; the 120-DPI result is an offscreen rendering, with no physical 125% desktop check. **Log streams.** I compiled the actual `preload_ui::run` from this head and its baseline into a standalone driver with a test child on native Windows pipes. Across six simultaneous stdout/stderr runs this head recorded all 196,662 expected lines, with no extras. It continued to parse progress after invalid UTF-8. The baseline lost subsequent progress in all three mixed-input runs. One small difference remains in `lossy_lines` (line 386). On both streams the baseline preserved a payload carriage return in `text\r\r\n` and a bare `\r` at EOF; the new reader removes both. If log fidelity is intended, stripping only one LF and its optional preceding CR would preserve those payload bytes. These checks used generated input, without a game run.
Jesper-A force-pushed up-preload-window-log-followups from d6e0adf911 to 97e0190672 2026-12-05 16:40:12 +00:00 Compare
Author
Collaborator

Closing this old-engine PR because post-merge has its own preload window (apps/darner/src/preload.rs); preload_ui.rs, the window this fixes, is not in its tree. It can be redone there if the problem shows.

Written with AI assistance (Claude Code).

Closing this old-engine PR because post-merge has its own preload window (`apps/darner/src/preload.rs`); `preload_ui.rs`, the window this fixes, is not in its tree. It can be redone there if the problem shows. Written with AI assistance (Claude Code).
Jesper-A closed this pull request 2026-12-06 01:26:22 +00:00
Jesper-A reopened this pull request 2026-12-06 01:51:54 +00:00
Author
Collaborator

Reopened: Main is the default branch again, so the close note above no longer applies.

Written with AI assistance (Claude Code).

Reopened: Main is the default branch again, so the close note above no longer applies. Written with AI assistance (Claude Code).
TrustNo1 changed title from WIP: [pr-fix][startup] Preload window: log name in the doc, whole-line log writes, own path shortening, lossy reads to WIP: Preload window: log name in the doc, whole-line log writes, own path shortening, lossy reads 2026-12-06 03:28:39 +00:00
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'up-preload-window-log-followups:Jesper-A-up-preload-window-log-followups'
git switch 'Jesper-A-up-preload-window-log-followups'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'Main'
git merge --no-ff 'Jesper-A-up-preload-window-log-followups'
git switch 'Jesper-A-up-preload-window-log-followups'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-preload-window-log-followups'
git switch 'Jesper-A-up-preload-window-log-followups'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'Jesper-A-up-preload-window-log-followups'
git switch 'Main'
git merge --squash 'Jesper-A-up-preload-window-log-followups'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-preload-window-log-followups'
git switch 'Main'
git merge 'Jesper-A-up-preload-window-log-followups'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
TrustNo1/Darner!467
No description provided.