Repository navigation
Description
Summary
Reported from TestFlight build 31 (iOS). EPUB rendering is inconsistent, and some pages render completely blank — no text at all, just the background and the page bar.
Reproduced against The Lost Art of Running (15 spine items). Page 8 of 15 renders empty; the same spine item has a full page of prose ("The first time I met Shane Benzie…", the Foreword) when opened in a reference reader.
Observed
| Reference render | LibraVault iOS build 31 | |
|---|---|---|
| Page 8 (Foreword) | Heading + body prose | Blank page |
| Page 5 (Contents) | Hierarchical, indented, styled | Flat undifferentiated line list |
Both screenshots in the reporting thread are the same book, same spine positions.
Two distinct defects
1. Blank pages (the serious one)
EPUBParser.parse builds each chapter with:
let html = (try? extract(href, from: archive)) ?? Data()Any failure to locate the spine item's entry inside the ZIP is silently converted into empty Data(), which becomes an empty chapter, which ReaderView.paginatedContent renders as an empty Text — i.e. a blank page with no error, no placeholder, and no log.
The lookup fails for spine hrefs that are legal EPUB but not literal ZIP entry names:
- Percent-encoded hrefs. OPF hrefs are IRIs, so
Text/chapter%2008.xhtmlis the correct spelling of an entry stored asText/chapter 08.xhtml.archive[path]is an exact string match, so it misses. - Un-normalised relative paths.
../Text/foo.xhtmlin an OPF underOEBPS/is joined toOEBPS/../Text/foo.xhtml, which matches no entry. - Fragments/queries on the href are not stripped before lookup.
Secondary contributor: when NSAttributedString's HTML importer returns nil (it is intolerant of some XHTML — undeclared entities, unusual doctypes), plainText returns "" and the page goes blank even though the bytes were read fine.
Note on the "dark mode" framing: the theme is not causally involved. LibraVaultColorScheme.dark uses warmNeutral100 text on darkSurface0 — the contrast is fine, and extraction runs identically in all three themes. The blank page reproduces in light and sepia too; dark mode is just what the reporter was reading in.
2. Rendering fidelity
ReaderView.paginatedContent renders each chapter as a single flat Text(chapterText(for:)). All structure from the XHTML — headings, list nesting, emphasis, indentation, alignment — is discarded by plainText(fromHTML:) before it reaches the view. That is why the Contents page reads as an undifferentiated list of lines.
This is a known design limitation of the first-pass reader rather than a regression, and fixing it properly means rendering an AttributedString (or a styled block model like the Markdown viewer already uses) instead of plain text. Tracking it here, but it should land separately from the blank-page fix.
Scope
- Blank pages — resolve spine hrefs robustly, stop swallowing extraction failures, fall back when the HTML importer bails
- Rendering fidelity — preserve document structure through to the view (follow-up)
Environment
- iOS TestFlight build 31
ios/LibraVaultApp/LibraVault/LibraVault/Sources/Models/EPUBParser.swiftios/LibraVaultApp/LibraVault/LibraVault/Sources/Features/Reader/ReaderView.swift
Activity
fix(ios): stop EPUB spine items rendering as blank pages (#110)
libravault-xyz commentedon Aug 13, 2026
Blank-page half fixed in #110, squash-merged to
devas09ac3aa.Root cause was
EPUBParserresolving spine items witharchive[href](exact string match) and folding any miss into?? Data()— percent-encoded hrefs, un-normalised../from the OPF base join, and hrefs carrying a fragment all missed and became blank pages. Same bug applied tocontainer.xml'sfull-path, where it would have failed the whole book rather than one page. Secondary contributor wasNSAttributedString's HTML importer returningnilandplainTextturning that into"".To confirm the "dark mode" framing in the report: the theme is not causally involved. Extraction runs identically in all three themes and
LibraVaultColorScheme.darkiswarmNeutral100ondarkSurface0. The blank page reproduced in light and sepia too.23
EPUBParserTestscases pass in CI. The iOS Simulator job was red at merge, but on the pre-existingtestSettingsShowsAllSevenSectionsfailure thatdevitself carries (dev@a4bb9cafails that andtestReadAloudNavigatesToPlayer) — unrelated to this diff, which touches onlyEPUBParserandReaderView.Still open here: the rendering-fidelity half —
paginatedContentrenders each chapter as one flatText, so headings, list nesting and emphasis are discarded before they reach the view. That's what makes the Contents page read as an undifferentiated line list. Needs anAttributedStringor styled block model.Not yet verified on device. The fix is static analysis plus unit tests; it wants a real read-through of The Lost Art of Running on build 32 before we call it confirmed.
feat(ios): parse EPUB XHTML into a MarkdownBlock model (#362)