Skip to content

iOS: EPUB pages render blank and rendering is inconsistent (build 31) #108

Closed

Description

@libravault-xyz

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.xhtml is the correct spelling of an entry stored as Text/chapter 08.xhtml. archive[path] is an exact string match, so it misses.
  • Un-normalised relative paths. ../Text/foo.xhtml in an OPF under OEBPS/ is joined to OEBPS/../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.swift
  • ios/LibraVaultApp/LibraVault/LibraVault/Sources/Features/Reader/ReaderView.swift

Activity

  1. added
    feedback
    TestFlight
    on Aug 13, 2026
  2. libravault-xyz commented on Aug 13, 2026

    @libravault-xyz
    CollaboratorAuthor

    Blank-page half fixed in #110, squash-merged to dev as 09ac3aa.

    Root cause was EPUBParser resolving spine items with archive[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 to container.xml's full-path, where it would have failed the whole book rather than one page. Secondary contributor was NSAttributedString's HTML importer returning nil and plainText turning 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.dark is warmNeutral100 on darkSurface0. The blank page reproduced in light and sepia too.

    23 EPUBParserTests cases pass in CI. The iOS Simulator job was red at merge, but on the pre-existing testSettingsShowsAllSevenSections failure that dev itself carries (dev @ a4bb9ca fails that and testReadAloudNavigatesToPlayer) — unrelated to this diff, which touches only EPUBParser and ReaderView.

    Still open here: the rendering-fidelity half — paginatedContent renders each chapter as one flat Text, 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 an AttributedString or 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.

  3. added
    bug
    on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    TestFlightbugfeedbackios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions