Repository navigation
Conversation
A whole-book search restarted its 25 ms budget at every section, so a book of many short sections (FB2 parses each synchronously) searched in one task and an abort waited for the end. Track the budget across sections and pause after loading and after finishing each one.
…arch The pause after a section loads now stops a whole-book search before the section scan, so the long-section case searched one section to keep checking the pause inside it.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Review summaryReviewed head: What I checked
Not verified here: I didn't repeat the browser timing runs; the numbers in the description are the author's. Timer behavior in a hidden tab is also unverified, and the description already names it as a risk. Possible later improvement (not a blocker): where the browser supports it, Validated features: none affected. Ebooks are a beta feature with no cases on the 1.0 validation board. Fit: 9/10 · Readiness: 9/10 — ready Fit: a small, contained fix for a real freeze in the beta ebook reader, made at the place that causes it, with no new settings or API surface. Readiness: the logic matches the old loop apart from the shared budget, and a test that fails on main proves the fix. 🤖 Claude Code (claude-opus-5-5) |
Problem
Closes #4350
Related issue: N/A
Validation tasks: none (ebooks are a beta feature outside the 1.0 validation board)
Other clients: Apple N/A (no ebook reader); Android N/A (the Android reader has no in-book search); Roku N/A (no ebook reader)
In the web ebook reader (beta), searching a book made of many short sections still freezes the page until the whole book has been read. While it runs, clicks wait, so Back or a new search only takes effect afterwards. #4331 made search pause after 25 ms of work, but the clock restarted at every section. A section that finishes inside 25 ms never paused, and when its document loads without a real wait the next section runs in the same task. FB2 always loads this way, because each section is parsed synchronously.
On a synthetic FB2 with 250 sections of about 4,300 characters, a search for a missing word ran as one 420–460 ms task in headless Chromium, and 1.65–1.8 s with the CPU throttled 4x. With this change, a whole-book search pauses at least every 25 ms of work across the book, and an aborted search stops at the next pause.
Approach
In the vendored foliate-js
view.js, a whole-book search now keeps one time budget for all sections. It checks the budget after loading each section's document and after scanning it, pauses for the event loop once 25 ms have passed, and then checks the abort signal. A single-section search keeps its own budget as before. The Silo change is marked in comments.Validation
verify-local-paths,verify-case-collisions,verify-size-ratchet, andverify-bidipass. There are no Go, API, or contract changes, so the Go half and the API contract checks were not run.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-4371/
Surface and build: web app ebook reader, main at 39ad6d9 and this branch, same local server data and synthetic FB2. The search panel looks the same and lists the same results. The difference is whether the page responds while a search runs, so the evidence is timing. It was measured in headless Chromium at 1440px on the production bundle, with a long-task observer, a timer due 50 ms after the search click, and real clicks.
Browser measurements (250-section FB2, search for a missing word, three runs each)
On both builds, a search for a common word still stops at 1,000 matches with the "Showing the first 1,000 matches." note, and a search for "Chapter 237" finds one result that opens and highlights that chapter.
Risks
Checklist
AI Disclosure