Skip to content

iOS: EPUB/PDF reader does not render images or diagrams #352

Closed
5 of 5 issues completed
Closed

Description

@libravault-xyz

Summary

Reported via tester feedback (R): images/diagrams inside EPUB content are not rendered by the iOS reader. Confirmed as a real gap, distinct from the DRM issue (#351).

This is the deferred "rendering fidelity" half of #108, which was explicitly scoped out at the time ("fixing it properly means rendering an AttributedString ... instead of plain text ... it should land separately from the blank-page fix") but never re-filed as its own issue.

Platform status

  • Android: not affected. EpubNavigatorFragment (Readium's WebView-based navigator, see feature/reader/src/main/kotlin/xyz/libravault/feature/reader/epub/EpubReaderScreen.kt) renders full HTML/CSS including <img> tags natively.
  • iOS: real gap. The EPUB/PDF reading path has no image-rendering capability at all:
    • BookContentProvider.chapters(for:) (ios/LibraVaultApp/LibraVault/LibraVault/Sources/Models/BookContentProvider.swift:38-53) produces BookChapter { title, text } — no image field. Contrast with Markdown content, which loads a markdownImages: [String: Data] dictionary eagerly (ReaderView.loadMarkdownImages, lines 302-316).
    • EPUBParser.strippingTags (EPUBParser.swift:251-282) regex-strips all tags, including <img>, with no src/alt capture.
    • ReaderView.paginatedContent / scrollingContent (ReaderView.swift:509-613) render EPUB/PDF chapters as a single flat SwiftUI Text(currentPageText) — there is no image view in this code path, only in the separate MarkdownReaderContent.

Proposed fix

Move iOS's EPUB (and PDF/text) reading path off flat Text(String) onto a content model that preserves inline images — either AttributedString/NSTextAttachment inline images, or a styled block model similar to what MarkdownReaderContent already does. This requires:

  • Extending BookChapter/content extraction to capture image references + asset bytes (similar to markdownAssetData).
  • Extending TextPaginator to account for image block heights when paginating.
  • New rendering code in ReaderView's EPUB/PDF content path.

This is meaningfully larger than a hotfix — feature work, not a quick patch. Should be scoped/estimated before a dev agent picks it up (recommend status:needs-info → human scoping pass, or a design note, before flipping to status:ready-for-dev).

Severity

Medium — books with pure prose are unaffected, but any EPUB with meaningful figures/diagrams (textbooks, illustrated non-fiction, comics) is degraded to missing content on iOS, with no fallback/placeholder indicating an image was dropped.

Related: #108 (closed; blank-page half fixed, "rendering fidelity" half deferred here).

Activity

  1. added
    bug
    feedback
    status:triage
    on Aug 20, 2026
  2. github-actions commented on Aug 20, 2026

    @github-actions
    Contributor

    Triage: confirmed as a real, reproducible gap — verified in the code, not just the report.

    • BookContentProvider.chapters(for:) / BookChapter (Sources/Models/BookContentProvider.swift) carry only { title, text }, no image data.
    • EPUBParser.strippingTags (EPUBParser.swift:251-282) regex-strips all tags including <img>, with no src/alt capture — confirmed by reading the current regex pipeline.
    • ReaderView's EPUB/PDF content path renders a single flat Text(currentPageText); only MarkdownReaderContent has an image-loading path (loadMarkdownImages), and that's a separate content model entirely.
    • Android is unaffected (Readium's WebView-based EpubNavigatorFragment renders <img> natively) — this is iOS-only.

    Not proceeding to implementation. This isn't a case of unclear repro — it's that the fix has at least two materially different, defensible architectures (AttributedString/NSTextAttachment inline images vs. a styled block model mirroring MarkdownReaderContent), and picking one commits the codebase to a direction that should have human input rather than an autonomous choice. It also touches the content model, the paginator, and the renderer together, which is feature-sized work, not a scoped hotfix. The issue author already flagged this and recommended a human scoping pass before status:ready-for-dev — agreed.

    Applying status:needs-info per dev-agent triage criteria (ambiguous scope where two reasonable implementations would look very different). No PR opened.

  3. added
    status:needs-info
    and removed
    status:triage
    on Aug 20, 2026
  4. libravault-xyz commented on Aug 20, 2026

    @libravault-xyz
    CollaboratorAuthor

    Decision: Option B (styled block model, mirroring MarkdownReaderContent) — chosen over AttributedString/NSTextAttachment. Rationale: proven placeholder/alt-text UX already shipped in MarkdownBlockView, no dependency on the HTML importer that caused #108's blank-page bug, and a cleaner shared architecture across formats — traded off against needing genuinely new block-aware pagination (nothing paginates a block model in this codebase today; MarkdownReaderContent is scroll-only).

    Requested for TestFlight build 39.

    Split into 5 sub-issues (linked above), sequential due to shared-file dependencies:

    1. iOS: EPUBParser — parse XHTML into a block model instead of flat text #356 — EPUBParser: XHTML → block model (foundational, unblocked now)
    2. iOS: BookChapter/BookContentProvider — carry EPUB blocks + resolved image data #357 — BookChapter/BookContentProvider: carry blocks + resolved image data (blocked on iOS: EPUBParser — parse XHTML into a block model instead of flat text #356)
    3. iOS: EPUB paginated mode — block-aware pagination (image-height-aware) #359 — EPUB paginated mode: block-aware pagination, image-height-aware (blocked on iOS: BookChapter/BookContentProvider — carry EPUB blocks + resolved image data #357) — the genuinely novel piece
    4. iOS: ReaderView — render EPUB via block model (paginated + scrolling) #360 — ReaderView: render EPUB via block model, paginated + scrolling (blocked on iOS: BookChapter/BookContentProvider — carry EPUB blocks + resolved image data #357, iOS: EPUB paginated mode — block-aware pagination (image-height-aware) #359)
    5. iOS: verify bookmark/TOC/locator compatibility with EPUB block model #361 — Bookmark/TOC/locator compatibility regression pass (blocked on iOS: BookChapter/BookContentProvider — carry EPUB blocks + resolved image data #357, should land no later than iOS: ReaderView — render EPUB via block model (paginated + scrolling) #360)

    PDF is explicitly out of scope — PDFParser/PDFKit already renders real pages with images; only EPUB has the gap despite this issue's title.

    #356 is unblocked and going to dev-agent now. I'll flip each subsequent issue to status:ready-for-dev as its blocker merges, and step in myself on anything dev-agent needs-infos given the build 39 deadline.

  5. removed
    status:needs-info
    on Aug 20, 2026
  6. libravault-xyz commented on Aug 20, 2026

    @libravault-xyz
    CollaboratorAuthor

    All 5 sub-issues merged — closing. Final chain: #356→PR #362, #357→PR #364, #359→PR #366, #361→PR #367, #360→PR #369 (two QA rounds; round 1 caught a real bookmark-locator regression from #369's branch predating #367, fixed properly by wiring in #367's EPUBLocator rather than the ad-hoc replacement it originally shipped with).

    EPUB now renders inline images/diagrams in both paginated and scrolling modes, backed by a shared block model with Markdown. PDF was out of scope throughout — PDFKit already renders images natively.

    Follow-up filed as a process fix, not tracked under this issue: #381 (dev-agent staleness-check + no-self-authorized-regressions rule, prompted directly by the #369 collision).
    Non-blocking cleanup noted by review, not yet filed as an issue: TextPaginator.swift/TextPaginatorTests.swift are now dead code (EPUB was their only consumer).

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

    bugfeedbackios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions