Skip to content

refactor(epub): rebuild iOS page-curl mode on one web view per chapter - #1237

Merged
everpcpc merged 3 commits into
mainfrom
refactor/epub-curl-single-webview
Oct 9, 2026
Merged

everpcpc merged 3 commits into
mainfrom
refactor/epub-curl-single-webview

Conversation

@everpcpc

@everpcpc everpcpc commented Oct 9, 2026

Copy link
Copy Markdown
Member

What

Rebuilds the iOS page-curl transition on the same single-web-view-per-chapter architecture the cover mode moved to in #1236, instead of one WKWebView per page.

  • One live EpubPageViewController per chapter plus preloaded boundary neighbors (at most 3 web views), replacing the 5-entry per-page controller cache, the pendingControllers/reservedControllers bookkeeping with its 0.3s cleanup timer, and the backside-image LRU.
  • UIPageViewController slots become dumb shells (CurlPageShellViewController): a chapter-internal flip covers the front shell with a snapshot of the current page and migrates the live web view into a pre-sized target shell scrolled to the target page. The curling leaf is a static image, the mirrored back uses the existing PageCurlBacksideViewController, and the reveal plus the committed page are the same live view.
  • Cross-chapter flips keep the live leaf and reveal the preloaded neighbor chapter; roles rotate on commit.
  • Interactive turns commit or restore in didFinishAnimating; programmatic turns commit in their own setViewControllers completion. The internal pan recognizers carry a target that cancels dataSource prefetches abandoned before a curl starts, so a dropped gesture can never wedge the turn state.
  • Tap zones, book-end refusal with onEndReached, RTL spine/semantic mapping, backside style, overlay labels, and progress recording behave as before.

Why

The per-page model held up to 5 whole-chapter DOMs in separate web content processes, and every in-chapter page turn re-injected CSS and re-ran pagination for a chapter already laid out next door. One web view per chapter removes both costs and deletes the compensating bookkeeping around UIPageViewController's opaque retention.

Validation

  • make build passes on all platforms.
  • iOS simulator with an English EPUB: tap turns both directions; interactive curls both directions with mid-gesture captures (static leaf, mirrored leaf back, live revealed page already scrolled to the target); short-drag cancels returning to the exact origin page; cross-chapter curls both directions with the neighbor pre-scrolled to its first/last page; book-start boundary refuses to curl; single-page chapter crossing; rotation reflow.
  • Not covered: RTL books (spine/semantic/direction mapping carried over unchanged) and the book-end onEndReached path (same unchanged boundary check as book start).

Part of #1234

- run one live EpubPageViewController per chapter plus preloaded
  boundary neighbors (at most 3 web views), replacing the 5-entry
  per-page controller cache, the pending/reserved controller
  bookkeeping with its 0.3s cleanup timer, and the backside-image LRU
- UIPageViewController slots become dumb shells: a chapter-internal
  flip covers the front shell with a snapshot of the current page and
  migrates the live web view into a pre-sized target shell scrolled to
  the target page, so the curling leaf is a static image while the
  reveal and the committed page stay the same live view
- cross-chapter flips keep the live leaf and reveal the preloaded
  neighbor chapter, rotating roles on commit
- interactive turns commit or restore in didFinishAnimating,
  programmatic turns in their own setViewControllers completion;
  internal pan recognizers carry a target that cancels dataSource
  prefetches abandoned before the curl starts
- tap zones, book-end refusal with onEndReached, RTL spine/semantic
  mapping, backside style, overlay labels, and progress recording
  behave as before
refreshNeighbors ran before commitLocation, so the coordinator's stale
page index made a cross-chapter commit skip preloading the previous
chapter (and could preload the wrong next chapter); the host's own
sub-page index is already at the committed page.
@everpcpc
everpcpc merged commit 23471f1 into main Oct 9, 2026
3 checks passed
@everpcpc
everpcpc deleted the refactor/epub-curl-single-webview branch October 9, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant