Repository navigation
refactor(epub): rebuild iOS cover mode on one web view per chapter - #1236
Merged
Merged
Conversation
Replace the three-controller deck and the five-entry page-controller cache with chapter-granularity hosts (current + cross-chapter neighbors). Page turns capture a snapshot of the current page: forward turns slide the snapshot away over the live web view already scrolled to the target page, backward turns slide the live web view in over the snapshot. Cross-chapter drags use the preloaded neighbor web view underneath, so only 1-3 web views stay alive instead of up to 5, and a chapter is laid out once instead of once per page. Part of #1234
- scroll reused neighbor hosts to the target page when a cross-chapter slide begins; a host reused after a mid-chapter jump could otherwise reveal a stale page before snapping to the target on commit - keep the origin snapshot covering the live view until the cancel scroll-back lands, so a cancelled same-chapter turn no longer flashes the target page (the backward case also needs the live view kept off-screen since it sits above the snapshot) - remove on-demand cross-chapter hosts that are not registered neighbors when a slide is cancelled, instead of leaving hidden orphans attached to the container - reset rubber-band residue when a slide session begins so a direction reversal at the book boundary starts from a clean frame
This was referenced Oct 9, 2026
everpcpc
added a commit
that referenced
this pull request
Oct 9, 2026
#1237) Rebuild 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. What: - 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 (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, so the curling leaf is a static image while the reveal and the committed page are 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; the internal pan recognizers carry a target that cancels dataSource prefetches abandoned before a curl starts, so a dropped gesture cannot 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 Validation: built all platforms; verified on 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), short-drag cancels, cross-chapter curls both directions with the neighbor pre-scrolled to its first/last page, book-start boundary refusal, single-page chapter crossing, and rotation reflow. RTL books untested (mapping carried over unchanged). Part of #1234
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Rebuilds the iOS EPUB cover mode on the single-web-view-per-chapter + snapshot-transition model that the macOS cover view and the iOS paged-scroll view already use, per #1234:
WKWebViewper page) and the five-entry page-controller cache are gone. At most threeEpubPageViewControllers stay alive: the current chapter plus, only while at a chapter edge, the preloaded next/previous chapter. At steady state mid-chapter exactly one web view is alive, versus up to five whole-chapter DOMs before.onEndReached, RTL mirroring, overlay labels, theme/font live updates, progress recording,preferLastPageOnReadyfor previous-chapter-last-page turns.Why
Per-page web views were the expensive part of the paged modes: every intra-chapter turn re-laid-out a chapter that a neighboring controller had already laid out, and the deck needed cache/eviction bookkeeping to stay alive. Laying a chapter out once and turning pages as JS scrolls removes both.
Validation
make format;make buildgreen on iOS/macOS/tvOS.mainshows identical rotation behavior (landscape lands on an approximate earlier chunk of the chapter on both — pre-existing re-pagination approximation, unchanged by this PR).Part of #1234