Make the exit library refresh instant #12

Merged
365DevNet merged 0 commits from refs/pull/12/head into main 2026-08-13 16:15:02 +02:00
365DevNet commented 2026-08-13 16:11:38 +02:00 (Migrated from codeberg.org)

Summary

Exiting after a load or unload blocked for 20 seconds. It turns out that wait
was never measuring anything: the poll loop waited for "Scan total", and
scanner.app prints "Scan finished statistic total all time: [...]". The
marker never matched, so every exit burned all ten 2-second polls.

Measured on the device (PB743K3) on 2026-08-13 with a temporary instrumented
build:

Actual scan 45 ms
Old foreground block 20,010 ms

The ceiling was the wait — about 440x the work.

What changed

  • New pure core/ScanLog holds the completion marker, host-tested against
    output really captured from the device. The old marker was wrong precisely
    because nothing could see it; now a test can.
  • PbLibrary::refresh matches the real line and polls every 50 ms instead of
    every 2 s. The 20 s ceiling stays purely as a backstop for a firmware change.
  • 200 ms settle before SIGKILL, so the scan's last writes land.

Also explains the old waitpid failure

scanner.app is a GUI task — it attaches shm, opens a framebuffer, loads a
theme — and never exits on its own. Waiting on the process waits forever,
which is what the reverted 2026-07-17 attempt hit. The printed line is the only
usable signal, hence match-then-kill.

This corrects the project's own design note, which asserted the scan "genuinely
takes >20s on this device". That was inferred from the ceiling being hit, which
was really the marker mismatch.

Test plan

  • 124 host tests pass
  • Clean ARM cross-build
  • On device: load/unload a book, tap Exit — instant, and the book still
    appears in the native Library

🤖 Generated with Claude Code

## Summary Exiting after a load or unload blocked for 20 seconds. It turns out that wait was never measuring anything: the poll loop waited for `"Scan total"`, and `scanner.app` prints `"Scan finished statistic total all time: [...]"`. The marker never matched, so every exit burned all ten 2-second polls. Measured on the device (PB743K3) on 2026-08-13 with a temporary instrumented build: | | | |---|---| | Actual scan | **45 ms** | | Old foreground block | **20,010 ms** | The ceiling *was* the wait — about 440x the work. ## What changed - New pure `core/ScanLog` holds the completion marker, host-tested against output really captured from the device. The old marker was wrong precisely because nothing could see it; now a test can. - `PbLibrary::refresh` matches the real line and polls every 50 ms instead of every 2 s. The 20 s ceiling stays purely as a backstop for a firmware change. - 200 ms settle before SIGKILL, so the scan's last writes land. ## Also explains the old waitpid failure `scanner.app` is a GUI task — it attaches shm, opens a framebuffer, loads a theme — and **never exits on its own**. Waiting on the process waits forever, which is what the reverted 2026-07-17 attempt hit. The printed line is the only usable signal, hence match-then-kill. This corrects the project's own design note, which asserted the scan "genuinely takes >20s on this device". That was inferred from the ceiling being hit, which was really the marker mismatch. ## Test plan - [x] 124 host tests pass - [x] Clean ARM cross-build - [x] On device: load/unload a book, tap Exit — instant, and the book still appears in the native Library 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
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
365DevNet/PocketBook_Kavita_sync!12
No description provided.