Repository navigation
Add Shiori, Aizome's PDF reader, drawing with hayro in a worker per document - #135
Conversation
|
Re-pinned Sidestep to Revalidated on wx-workstation against that Sidestep:
Note: 🤖 Generated with Claude Code |
…r per document Shiori 栞 (Documents) reads PDFs in Aizome's look: pages in one column, fit-width/fit-page/stepped zoom with pinches and ❖-scroll about the pointer, the outline and page thumbnails in a sidebar, find with every hit shown, text selection and copy across pages, links, password-locked documents, Get Info, Go to Page, your place and zoom kept per document, and files that change while open read again in place. PDFium was chosen over hayro (the other engine without a GPL/AGPL licence) after drawing the pdf.js corpus with both: equal median speed, a much shorter tail, and the text, search, link, outline and form APIs a reader needs. nixpkgs builds it from source; the package puts it on the run path. Each document gets its own `aizome-shiori --pdfium-worker` process: a file that makes PDFium abort or loop costs a page, and the app starts another worker. The worker asks fontconfig where fonts are, so documents naming fonts they don't embed (CJK) draw on NixOS. Pages are drawn as 1024-pixel tiles for exactly the zoom and scale, by a widget that scrolls by moving pixels (0.23 ms a notch at 2x, from 9.9 ms with a canvas). The pages either side of the view are drawn ahead and kept, the worker is asked again only when the wanted set changes, and the sidebar draws the rows either side of those that show. The evaluation and the corpus runs are recorded in docs/test-results/pdf-engines-2026-10-28.json and desktop/aizome/docs/shiori.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ice pass `aizome-checks.shiori` boots the Aizome session and drives the packaged reader with real keys: a document opens with the package's libpdfium in its worker, find goes through the worker, a SIGKILLed worker is replaced with the window open, and application/pdf defaults to Shiori. The toolbar's "PDFium stopped; Shiori started it again." gives way to the page number after about ten seconds; lasting notices stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stet, pdfrum, pdfboss, pdf_oxide and zpdf all take 2.3 to 6.9 times PDFium's time over the pdf.js corpus; hayro master takes 1.28 times, and a local branch of it with glyph, image and mesh caches takes 0.88 times. Shiori keeps PDFium for now; shiori.md says what moving would need. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Five runs of the pdf.js corpus on wx-workstation, pinned to one CCD, with PDFium, hayro master, the fork before reduced-size JPEGs and the fork now: the fork takes 0.575 of PDFium's total over the 1,189 pages all drew in under 5 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eleven more changes on the fork (aizome-perf at ad5920e6, with a row limit added to the zune-jpeg fork): five runs on wx-workstation put it at 0.521 of PDFium's total over the 1,189 pages all drew in under 5 s, faster on 961 of them and behind on the rest by 149 ms in all. 144 corpus pages change from the build before, by at most 2 levels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fork at 72fd16cb takes 0.50 of PDFium's time over the 1,189 corpus pages all three engines drew, faster on 1,068 and behind on the rest by 89 ms. This round's changes, with instruction counts, the quiet and the loaded runs, the Type 3 cache's glyph-edge changes and the suite results are in the record, and the remaining gaps now give their reasons: meshes, vello_cpu's layers under soft masks, the PostScript interpreter, predefined CJK CMaps, and moxcms building an output curve of 65,536 pow calls for every transform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fork at 30c45b88 takes 0.488 of PDFium's time over the 1,189 corpus pages all three engines drew, faster on 1,077 and behind on the rest by 67 ms, with every page as at 72fd16cb. Predefined CJK CMaps are embedded as tables searched in place, PostScript functions are compiled to instructions on registers, and moxcms (through a fork) computes the sRGB curve once rather than for every transform, so the CJK and PostScript pages and ICC set-up are now faster than PDFium's. The record lists what's left: meshes, vello_cpu's layers under soft masks and nested groups, and the first sRGB curve a Lab space builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shiori's worker now reads documents with bitemyapp/hayro's aizome-perf branch, a memory-safe PDF renderer in Rust about twice as fast as PDFium over the pdf.js corpus, and writes on hayro's parser what PDFium gave the reader: - each page's characters and boxes (pdftext.rs): glyphs in the order the page draws them, boxes a line high, spaces and line ends inferred from gaps and line changes, overprinted glyphs once, /ActualText in place of what it covers, vertical text read down; - find over that text, with white space, ligatures, soft hyphens and case handled, a rectangle for each line a hit crosses; - links, destinations (explicit and named) and the outline (document.rs), metadata as PDF text strings, and an encrypted document's permissions, which the fork now gives; - fonts a document names but doesn't carry: hayro's built-in Foxit fonts, and for Chinese, Japanese and Korean ones whatever fontconfig matches for the language (fonts.rs). A panic costs only the job it was on, and the worker carries on with the document open; one that dies or spends too long on a page is replaced as before. The flag is --worker; the package no longer carries or loads libpdfium, and its Cargo vendoring has hashes for the hayro, zune-image and moxcms forks, the last patched in for the workspace. Over the pdf.js corpus through Shiori's path (examples/corpus.rs), on the same laptop back to back: 993 of 1,012 files opened, drawn, read and searched (PDFium: 985), 14 ms a file at the median and 78 at p99 (24 and 176), 16.4 s over the 981 files both did (30.7 s), and none stopped or crashed its worker (PDFium: 2 stopped at 20 s, 1 crash). The example now treats a document with no pages as done. cargo test -p aizome-shiori passes unchanged (21 unit, 6 worker and 15 headless tests, and the Night and Day goldens PDFium's drawings made), as does the budget test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fork now reads documents encrypted only for their attachments (their stream and string filters Identity), which asked for a password or failed to open, and searches for pages past a page tree that reads as empty. The Nix vendoring failed on two zune-core 0.5.3s (crates.io's for the image crate, the zune-image fork's for hayro); the workspace now patches crates.io's to the fork's branch, so there's one. Over the pdf.js corpus through Shiori's path, back to back with PDFium's worker on the same laptop: 995 of 1,012 files opened, drawn, read and searched (PDFium's: 985), 15 ms a file at the median and 82 at p99 (24 and 136), and 17.4 s over the 983 files both did (29.9 s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker took fontconfig's best match for a Chinese, Japanese or Korean collection's language, which can be a Latin font (Noto Sans, on a system with Noto Sans CJK too): hayro finds a stand-in's glyphs through their Unicode, and a font without them drew the wrong glyphs. It now walks fontconfig's sorted list and takes the first outline font with a character of the language (あ, 中 or 한), and passes the face of a collection without the named instance fontconfig packs above it (Noto Sans CJK is a variable collection), which gave no face at all. pdf.js's vertical_rotated_fallback_glyphs, whose Japanese font isn't embedded, now draws its あ in Noto Sans CJK, down its columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Page Down is within the budget at load average 2 to 3 (3.19 ms p50) and was over it at 10.5; the test measures the window with its drawings already made, so the engine isn't in it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…scape Fixes from review: - A link is followed when the press on it ends where it began; dragged from, it's text to select, so a URL in a paper can be copied and a stray press doesn't open a browser. - Escape empties the find field, then closes Find, then lets the selection go, then leaves full screen (as in Sumi and Shashin). Full screen shows Find while it's open; it used to open out of sight. - Copying a selection over pages whose text hadn't come (passed over with the scroll bar) asks the worker for them and copies once they have; it used to leave them out without a word. The toolbar counts them down meanwhile. - A page that couldn't be drawn is marked at that size only, and asked for at another zoom, unless it has failed at two sizes already. - A search the worker gave up on says it stopped, rather than "Searching…" for good. - The app refuses a drawing larger than it could have asked for before reading its pixels (the worker runs SIMD decoders with unsafe code on the document's bytes), and cuts a page's text whose characters and boxes don't pair up. - The app keeps the text and links of 48 pages, not of every page read. - /ActualText over glyphs that turn keeps those glyphs' text, rather than dropping it. - The docs no longer call hayro memory-safe as Shiori builds it, and the tests no longer say PDFium. Refinements: - Find's hits are yellow and the current one orange with an edge, the same in Night and Day, as pages are paper in both. - The toolbar says where the link under the pointer goes; the page number opens Go to Page when pressed; Previous and Next Page give their shortcuts. - The contents mark the entry being read, or the closed branch it's in. - The sidebar, and its tab, are kept with your place. - The middle button drags the pages, and a horizontal scroll bar shows for pages wider than the window. - A selection held past the window's edge goes on scrolling. - Get Info says when the document was made and changed. cargo test -p aizome-shiori: 26 unit, 26 headless and 6 worker tests pass; the Night and Day goldens are drawn again (hayro, the new highlights and the contents' mark). The budget test: a notch 0.09 ms p50, Page Down 1.25 ms p50 and 2.03 p95 on runnymede. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4a6747e to
6323368
Compare
A zoom step's first frame scaled the last zoom's drawings as the window drew them: bicubic, on one thread, every size there was over each other. At 4K it took 357-533 ms, and while the new tiles came each frame took another 55-77 ms, so zooming felt slow and laggy. - Shiori makes the stand-ins itself (standin.rs): for the part of each tile in view, exactly its size, from the nearest size that has each band of rows (bilinear, reusing each scaled row across the rows it serves; from drawings over twice as large, the mean of four pixels), on up to 16 threads, into the buffers of earlier stand-ins whose images have gone. The window copies them one to one, as it does the drawings, and lets each go as its drawing comes. - Drawings come back without copies: the worker writes its pixmap as it is through a 1 MiB pipe, and the app reads it into the buffer the image keeps. sidestep-ui's Image gains from_premultiplied_rgba and premultiplied_pixels for this. On a 6 MB book of A4 pages in a 3800 x 2000-pixel window, a zoom step's first frame now takes 4.5-5.0 ms, and the tiles in view are sharp 35-53 ms after the key; pinching takes 3.6/4.8 ms a frame (p50/p95) zooming in and 5.4/6.3 zooming out. The budget test (2880 x 1800) gains a zoom step, 4.3-4.4 ms p50 (382 ms before), at the 4 ms budget as every pixel changes, and pinching, 3.5 ms (357 ms before); a step over 16 ms fails it. A headless test checks that a zoom shows stand-ins at once, with their ink where the drawings put it, and lets them go once drawn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… worker sends When an open document's file changed, Shiori replaced its worker with one opening the new file straight away. If that file couldn't be read yet (a LaTeX build that failed, a download still being written), the window kept its old drawings but its only worker had no document, and it answered nothing: a zoom stayed blurred, pages not yet drawn stayed blank, and Find and Copy never finished, until the file changed again. Now the newer file is opened by a worker of its own while the one that read the last version goes on drawing it; the new worker takes over only once it has opened the file and found pages, and otherwise it goes and the last version stays usable. A worker started again after a failure that finds the file unreadable now leaves what showed in place too, rather than replacing the window with an error. JSON has no infinity or NaN, so a link rectangle a document makes infinite (a /Rect of 10^40 points) went out as null; the app couldn't read the reply, took the worker for crashed and restarted it, and four such pages in a minute gave up on the document. The worker now leaves such links and hit rectangles out, gives such characters no box and such pages A4's size. The app checked only a drawing's width and height, so a worker sending a drawing of a page past the last could panic every Shiori window. The engine now also stops a worker that sends a drawing of a page its document hasn't, or of a part past the page's edge, and the app lets go of drawings and search hits for pages its window doesn't have. A document closed while its worker was starting no longer leaves that worker running until Shiori exits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The record of Shiori's hayro worker against its PDFium worker named 52a7ee2 as the PDFium build, a merge with main that the branch's rebase dropped and that won't be on main after a squash merge. It now says so, and names 6edff0e, the commit in the pull request's history whose Shiori that build had, so the comparison can be rebuilt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ages go When a worker started again after a failure couldn't open the file, Shiori kept the window's view and said the file had changed and couldn't be read yet, even when it hadn't: a reopen stopped by the 30-second watchdog under load, or a file that couldn't be read for a moment, was put down to a change, and nothing said that Reload would try again. Shiori now keeps the file's time and size as of the version that shows, says the file changed only when they differ, and otherwise says that the page reader couldn't open the file again (or stopped, or took too long, doing so) and that Reload tries again. A Reload that can't open a file that hasn't changed says the same. A worker started again that opened a changed file with no pages (one being written again, say) was kept, and failed every drawing asked of it, marking pages as unreadable until the next reload. It now goes, as a newer file with no pages does, and what showed stays. The check that stops a worker that starts as its document closes is a function of its own now, with a test of both orders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The workspace's [patch.crates-io] for zune-core and moxcms came in for Shiori's hayro, but Cargo applies it to every crate in the workspace: the compositor, the toolkit and so the shell and every app build image against the forks. DEVELOPERS.md now says so, what to check when moving either fork, how to move each (zune-core is named by branch, so a plain cargo update moves it), and what dropping each would take. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main now has Shiori (#135). The conflicts take both sides, as in the release-candidate tree: the workspace members, lock file, app catalog, icons, module and docs list both apps. Shiori's full-screen test gains the window state's new suspended field from this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds Shiori 栞 (Documents), Aizome's PDF reader: a native Rust app that draws pages with hayro, a PDF renderer in Rust whose own crates forbid
unsafe, from bitemyapp's fork of it. hayro runs in a separate worker process for each open document: a document can panic it or keep it busy, and the SIMD decoders Shiori turns on (hayro-syntax'sunsafefeature) rununsafecode on its bytes.Engine
GPL and AGPL engines are out: MuPDF, Poppler, xpdf and Ghostscript. pdf.js needs a web engine, and parser crates like lopdf don't draw pages. That left PDFium (BSD/Apache) and hayro (MIT/Apache). Over the pdf.js corpus they were as fast as each other at the median, but hayro's tail was much longer, and only PDFium gave a reader character boxes, search, links and the outline. So Shiori first drew with PDFium (
docs/test-results/pdf-engines-2026-10-28.json).The fork (bitemyapp/hayro, branch
aizome-perf) now takes 0.49× PDFium's time over the corpus pages all three engines drew, faster on 1,077 of 1,189 pages (docs/test-results/hayro-fork-2026-10-28.json). This PR now draws with it, and builds what PDFium gave the reader on hayro's parser. PDFium andlibpdfiumare gone from the package.Through Shiori's own path, over the same 1,012 files, back to back on one laptop (
docs/test-results/shiori-hayro-2026-10-28.json):What's in it
aizome-shiori --worker): a watchdog restarts a worker that dies or hangs, and the failure costs at most one page at one size (it's tried again at another zoom, unless it has failed at two). A panic in hayro costs only the job it was on, and the document stays open. The app refuses a drawing it couldn't have asked for (too large, of a page the document hasn't, or past its page's edge) and lets go of drawings and hits for pages the window doesn't have; the worker leaves out geometry JSON can't carry (an infinite or NaN link box), rather than have the app take it for crashed. A worker started again that can't open the file, or finds no pages in it, goes, and what showed stays, with the toolbar saying why. The app keeps the text and links of 48 pages. Workers also usePR_SET_PDEATHSIG,NO_NEW_PRIVSand an 8 GiB address-space limit.pdftext.rs): glyphs in the order the page draws them, with boxes a line high. Spaces and line ends are inferred from gaps and line changes. Overprinted glyphs count once,/ActualTextreplaces the glyphs it covers, and vertical text reads down.document.rs).Pdf::permissions, which the fork added.fonts.rs): hayro's built-in Foxit fonts stand in for Latin ones. For Chinese, Japanese and Korean, the worker takes the first outline font fontconfig lists for the language that actually has its characters (Noto Sans CJK in Aizome's session).standin.rs). While a zoom's tiles come, Shiori makes what stands in for the part of each tile in view, at exactly its size, from the last zoom's drawings (bilinear, on up to 16 threads, into reused buffers), and the window copies it one to one like the drawings. The window used to scale the old drawings itself as it drew, bicubic and on one thread, which took 357–533 ms a step at 4K. Drawings also come back from the worker without copies, through a 1 MiB pipe;sidestep-ui'sImagegainsfrom_premultiplied_rgbaandpremultiplied_pixelsfor this.Cargo.toml.Cargo.lockpins the commit.imagegets them: the compositor, the shell, the toolkit'ssidestep-engineand Shashin.imagestill decodes JPEGs with crates.io zune-jpeg 0.5.15, now compiled against the forked zune-core, and manages colour with the forked moxcms. Shashin's tests pass the same as on main.package.nixhascargoLock.outputHashesfor the three git repositories.application/pdfdefaults to Shiori in Aizome sessions, the app has an icon and a shell catalog entry, and there is anaizome-checks.shioriVM check.DEVELOPERS.mdsays how far the two patches reach, what to check when moving either fork, how to move each (zune-core is named by branch, so a plaincargo updatemoves it;cargo update -p zune-core --precise REVchooses its commit), and what dropping each would take.README.md,desktop/aizome/Cargo.tomlanddesktop/aizome/README.md; it had been rebased on Move Aizome's toolkit into Sekka as Sukumo #139, Clean up Aizome when its login session is terminated #140 and Stop describing a sidestep input in DEVELOPERS.md #143 before. The Sidestep re-pin (22125b1) is gone, as main no longer has Sidestep. Add Utsushi, Aizome's media player, built to spare the battery #136 (Utsushi) conflicts with this PR (Cargo.lock, the workspace members, the mime list, docs and icons): whichever lands second needs a rebase, a regeneratedCargo.lockkeeping both sets of git sources and hashes, and its VM check again.Changed in review
null, which the app read as a crash. A drawing of a page past the last, or past a page's edge, stops the worker in the engine and is let go in the app, as are search hits on such a page; one such drawing could panic every Shiori window.DEVELOPERS.mdnote on the workspace patches above; the corpus record names its PDFium baseline as this PR's 6edff0e (built at the time as 52a7ee2, a merge the rebase dropped); the PR text no longer says Shashin andsidestep-enginedecode JPEGs through the forks.Testing
Component tests, the aizome package and the VM check ran on wx-workstation on this head (893f006), merged with main at d717500. The other results say where and on which head they ran.
cargo test -p aizome-shioripasses: 34 unit, 7 worker and 32 headless tests, and the budget test.aizome-kit's tests pass. Clippy (--all-targets -D warnings, both crates) and rustfmt are clean.sidestep-ui's library tests passed in Sukumo's workspace in an earlier round.layout.rs:205, a worker taken for crashed on a link). One more test covers a worker that dies while the file is half written: the view stays, and the whole file is read once written.chmod 000(its time and size don't change), so it skips itself when run as root.tests/budget.rsgives Page Down 3.2 ms p50 at load average 2 to 3, within the 4 ms budget. It was 5.7 ms at load average 10 before. The test measures the window with its drawings made, so the engine isn't in it. After the review changes, on runnymede: a notch 0.09 ms p50, Page Down 1.25 ms p50 and 2.03 ms p95. It now measures zooming too, at 2880 × 1800: a zoom step 4.3–4.4 ms p50 and 4.4–4.6 ms p95, at the budget because every pixel changes (it was 382 and 508 ms), and pinching 3.5 and 4.0 ms (it was 357 and 474–479 ms). A step over 16 ms fails the test.nix build .#aizome(release-lto, with its check phase: the toolkit, Yukimi,aizome-shellandaizome-syssuites) passes on this head. The package hasaizome-shiori, its desktop file and icon, and no PDFium in its closure. Shashin's tests passed the same as on main with the patched zune-core and moxcms, on ce63cc9, whoseCargo.lockthis head keeps unchanged. A dry run of theDEVELOPERS.mdcommands showed thatcargo update -p zune-core --precisemoves zune-core and hayro's zune-jpeg together, from one repository.nix build .#aizome-checks.shioripassed on 4a6747e on wx-workstation, again on 6323368 (rebased, with the review changes) and cf8c174 (with the zoom work), both on runnymede, and on this head on wx-workstation. It:libpdfiummapped;SIGKILLed worker with the window kept;Not tested
latexmk -pvc) with one build left broken, so the PDF is truncated. The toolbar should say the file changed and can't be read yet, while zoom, scrolling, Find and Copy still work on the last version; the next good build should swap in.xdg-openand a double-click in Hako on a PDF opening Shiori, with a default of your own in~/.config/mimeapps.liststill winning.Limits
issue15590, whose objects have lost their<<and>>, andpoppler-85140-0, where hayro (like qpdf) finds no pages.Page iv), a dark reading mode for pages, and a seccomp or Landlock sandbox for the worker.Open questions
Cargo.lock, the workspace members, the mime list, docs and icons. Whichever is second needs a rebase, a regeneratedCargo.lockkeeping both sets of git sources andoutputHashes, thencargo metadata --locked, theaizomepackage build and its VM check again.a2e9e62, zune-image13f18bce, moxcmsb6329802) so a force-push of their branches can't break fresh fetches of the pins.Follow-ups
watchreloads it, within 1.5 s. Out-of-layout drawings and hits are let go, so this is only cosmetic.The release workflow is untouched.
🤖 Generated with Claude Code