Defer currentLocation updates while the app is inactive - #6
Draft
raphi011 wants to merge 2 commits into
Draft
Conversation
While the app is backgrounded, iOS renders the app switcher snapshots (running appearance/layout passes for both color schemes) and WebKit may reload or re-lay out the web views. A location computed in that window can reflect a transient scroll position the user never saw; adopting it overwrites currentLocation and misleads any observer persisting the reading progression (the restore family: readium#645, readium#321, readium#309, readium#839). Gate the debounced updateCurrentLocation on the existing isActive flag, symmetric to needsReloadSpreadsOnActive: the pending update is deferred (not dropped) by the execute(when:) predicate and runs once the app becomes active again, against the settled layout. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…leElementLocator() go(to:) on the captured locator lands on the page where that element begins — one page back whenever the visible page starts mid-element (e.g. mid-paragraph in a paginated reflowable publication). Spell this out on the protocol so users of the capture-and-restore idiom pick the right anchor: firstVisibleElementLocator() when the page grid changed, currentLocation when the layout is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
|
Host-app pass done: Kios now pins this branch content (the fix commit cherry-picked onto its integration branch as |
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.
Upstream ticket: readium#841 (maintainers asked for a ticket to agree on the design before an upstream PR — this draft is the reference implementation).
Follow-ups from the corrected analysis of readium#839 (see also the closed spike #5 — its premise was falsified; the drift was app-side).
Changes
1.
EPUBNavigatorViewControllerno longer adoptscurrentLocationwhile the app is inactive.While the app is backgrounded, iOS renders the app switcher snapshots (running appearance/layout passes for both color schemes) and WebKit may reload or re-lay out the web views. A location computed in that window can reflect a transient scroll position the user never saw; adopting it overwrites
currentLocationand misleads any observer persisting the reading progression — the restore family (readium#645, readium#321, readium#309).The fix gates the debounced
updateCurrentLocationon the existingisActiveflag, symmetric toneedsReloadSpreadsOnActive. Deferred, not dropped:execute(when:)polls until the app is active again and then computes the location once, against the settled layout.2. Documented the page-start bias of restoring
firstVisibleElementLocator().go(to:)on the captured locator lands on the page on which that element begins — one page back whenever the visible page starts mid-element (e.g. mid-paragraph in a paginated reflowable publication). The protocol doc now spells out when to prefer it (page grid changed) vscurrentLocation(layout unchanged).Testing
xcodebuild test -scheme Readium-Package— 101 tests, 28 suites, green.needsReloadSpreadsOnActive).Draft: intended to iterate here first, then propose upstream once readium#841 settles the design.
🤖 Generated with Claude Code