fix(reader): defer zoom state writes out of gesture callbacks - #960
Merged
Conversation
Publishing isZoomed synchronously from scrollViewDidZoom runs while the pinch gesture is still active, which can crash SwiftUI AttributeGraph on iOS 18 (issue #958). Defer the observable write to the next runloop in NativePagedPageContentView and NativeImagePageViewController, matching the existing pattern in PageScrollView, and skip zoom-scale resets while a pinch gesture is in flight.
everpcpc
marked this pull request as ready for review
August 22, 2026 13:32
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
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.
Summary
Fixes the DIVINA reader crashes on iPadOS 18 reported in #958, where the app crashed on the first pinch-to-zoom gesture and on subsequent tap/drag gestures.
Root Cause
scrollViewDidZoomin the paged DIVINA reader (NativePagedPageContentView) and the Page Curl reader (NativeImagePageViewController) publishedviewModel.isZoomedsynchronously from inside the scroll view's zoom gesture callback. This triggers a SwiftUI re-render chain (DivinaReaderViewre-renders → controls hide →updateUIView→ slot content reconfigure/layout) while the pinch gesture is still in flight — a state publication pattern that crashes AttributeGraph on iOS 18.PageScrollViewalready defers this write viaDispatchQueue.main.async; these two zoom hosts were missing that guard.Changes
isZoomedwrite to the next runloop in both remaining zoom hosts (with a stale-value recheck), matching the existingPageScrollViewpattern.NativePagedPageContentView.resetScrollViewportState()while a pinch gesture is.began/.changed, retrying on the next runloop until the gesture settles. Resetting the scale mid-gesture desyncsUIScrollView's internal gesture state. (iOS only;pinchGestureRecognizeris unavailable on tvOS, where zoom is not user-driven anyway.)Validation
make build-ios/make build-macos/make build-tvosall pass.