Skip to content

fix(android): zoom a pinched scroll view out until the fingers meet - #2311

Closed
XiaoMengXinX wants to merge 4 commits into
nsgo-dev:mainfrom
XiaoMengXinX:fix-android-zoom-pinch-in
Closed

XiaoMengXinX wants to merge 4 commits into
nsgo-dev:mainfrom
XiaoMengXinX:fix-android-zoom-pinch-in

Conversation

@XiaoMengXinX

@XiaoMengXinX XiaoMengXinX commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follows #2301, which has merged; this branch is rebased onto main and holds only the pinch change.

On Android, a pinch on a zoomable Scroll stopped zooming out partway. ZoomScroll read pinches through ScaleGestureDetector, which ends a pinch once the fingers' span drops below its minimum span (config_minScalingSpan, about 27mm). Pinching a zoomed picture back out therefore stalled once the fingers came that close, and the rest of the movement did nothing.

ZoomScroll now reads the pinch from the fingers' spread itself. The spread is twice the fingers' mean distance from their middle. A pinch begins once the spread has changed by more than twice the touch slop, then zooms by the ratio of the spread to its last value, around the fingers' middle. When a finger lands or lifts, both the spread and the middle restart from the fingers still down, as the pan's anchor does after #2301. noPinchZoom still turns pinches off.

Dropping the detector also drops Android's one-finger quick scale (double tap, then drag), which ScaleGestureDetector turns on by default. ZoomScroll only ever got it by accident, when its content took no touches, and while it zoomed the same finger also panned the view. iOS's UIScrollView has no such gesture and NsgoView already turns it off for OnPinch, so a zoomable Scroll now zooms with two-finger pinches only; the changelog fragment records this under Changed.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

iOS zooms with UIScrollView's own pinch and does not have this limit. NsgoView's OnPinch element gesture also uses ScaleGestureDetector and may stop the same way. This pull request does not change it; that is left for a follow-up.

Screenshots

None. The change is in how far a pinch zooms, which a still image does not show.

Verification

Run on this branch rebased onto main at 9f2ee7e:

  • go tool nsgo check -target android ./internal/platform/android
  • go tool nsgo test ./internal/platform/android -- -count=1: 154 passed, 9 skipped.
  • go tool nsgo test -target android: not run.

ZoomScrollCheck gains a case that pinches with two fingers. A spread within the slop leaves the zoom at 1. Spreading the fingers from 150 to 450 zooms to 3, and closing them back to 150 returns the zoom to 1. The test stub of ScaleGestureDetector is removed, as nothing uses it now. Against the previous Scrolling.java the case fails with spreading the fingers zoomed to 1.0. That failure shows only that the old code pinched through the detector, because the stub never scales. The 27mm cutoff comes from the platform's own detector, so the JVM test cannot reproduce it.

On a Pixel 9 (Android 17), I ran an app with a runtime built from this Scrolling.java through internal/platform/android/runtime/build.sh. In a picture viewer where pinching out used to stall partway, the pinch now carries on. One-finger pans and double-tap zoom still work. I could not script a two-finger pinch on the device, so how close the fingers can come rests on the JVM test. This pull request leaves classes.dex and classes.jar alone, as AGENTS.md asks.

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md.
  • New third-party code, assets and dependencies name their source and license.

🤖 Claude Opus 5.5

@github-actions github-actions Bot added size/M bug Something isn't working documentation Improvements or additions to documentation Android labels Nov 24, 2026
@houko houko self-assigned this Nov 25, 2026

@houko houko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against the latest origin/main (8d57260). The custom spread tracking in internal/platform/android/java/dev/oneo/nsgo/Scrolling.java addresses the reported pinch-in cutoff, and the expanded ZoomScrollCheck regression passes locally.

Local verification:

  • go tool nsgo check -target android ./internal/platform/android
  • go tool nsgo test -run '^TestZoomScrollBrakingTouch$' ./internal/platform/android -- -count=1

I cannot approve yet because the pull request is 27 commits behind main and its current GitHub checks contain only triage checks. This branch also includes the unmerged #2301 commit as described in the PR body. Rebase onto current main after #2301 is resolved, then publish the repository check/test results.

@XiaoMengXinX
XiaoMengXinX force-pushed the fix-android-zoom-pinch-in branch from 8a0b532 to 87e5cea Compare November 25, 2026 10:01
@XiaoMengXinX

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (28318fe, 0.3.2) on top of the rebased #2301 (4d5f231); the head is now 87e5cea, with no conflicts and no change to the diff. Only that last commit is new here, and I will rebase again once #2301 merges.

Results on the rebased commit, run locally on macOS:

  • go tool nsgo check -target android ./internal/platform/android: passed.
  • go tool nsgo test ./internal/platform/android -- -count=1: 154 passed, 0 failed, 9 skipped.

As on #2301, the Check, Test, Repository quality and CodeQL workflows wait for a maintainer to approve workflow runs from a first-time contributor.

@houko houko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-level review against the pinch-in issue. The PR removes ScaleGestureDetector's minimum-span cutoff and computes a spread from every active pointer. Pinch activation waits for 2 * touchSlop, applies the ratio of successive spreads around the current middle, and resets both spread and anchor when a pointer lands or lifts. This covers the reported case where Android stopped zooming out near its detector threshold. The regression explicitly closes the spread below that threshold and checks that zoom returns to 1. I found no source-level defect. Approval remains blocked by the branch's stale base and incomplete current checks.

@XiaoMengXinX
XiaoMengXinX force-pushed the fix-android-zoom-pinch-in branch from 87e5cea to 4587e40 Compare November 25, 2026 11:51
@XiaoMengXinX

Copy link
Copy Markdown
Contributor Author

Rebased again onto current main (7cf20b5); on top of the rebased #2301 (555e1b2); the head is now 4587e40, with no conflicts and the same diff.

On that commit, locally on macOS:

  • go tool nsgo check -target android ./internal/platform/android: passed.
  • go tool nsgo test ./internal/platform/android -- -count=1: 154 passed, 0 failed, 9 skipped.

main gained 24 commits in the two hours since the previous rebase, so the branch will fall behind again soon. The Check, Test, Repository quality and CodeQL runs for this push are in action_required: they start only after a maintainer approves workflow runs for a first-time contributor, which I cannot do from the fork. Once they are approved I will follow up on any failure.

@XiaoMengXinX
XiaoMengXinX force-pushed the fix-android-zoom-pinch-in branch from 4587e40 to dd86c46 Compare November 25, 2026 13:16
@XiaoMengXinX

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (d52cdb5); on top of the rebased #2301 (1d775ae); the head is now dd86c46, with no conflicts and the same diff.

On that commit, locally on macOS:

  • go tool nsgo check -target android ./internal/platform/android: passed.
  • go tool nsgo test ./internal/platform/android -- -count=1: 154 passed, 0 failed, 9 skipped.

The Check, Test, Repository quality and CodeQL runs for this push still wait for a maintainer to approve workflow runs.

@XiaoMengXinX
XiaoMengXinX force-pushed the fix-android-zoom-pinch-in branch from dd86c46 to 7402c54 Compare November 25, 2026 13:44
@XiaoMengXinX

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (43b504e) on top of the rebased #2301 (a12c6e6); the head is now 7402c54. No conflicts, and the diff is unchanged: main gained 8 commits since the last rebase and none of them touched internal/platform/android.

Locally on macOS:

  • go tool nsgo check -target android ./internal/platform/android: passed.
  • go tool nsgo test ./internal/platform/android -- -count=1: 154 passed, 0 failed, 9 skipped.

Check, Test, Repository quality and CodeQL for this head are still action_required; they start only after a maintainer approves workflow runs for a first-time contributor.

@XiaoMengXinX
XiaoMengXinX force-pushed the fix-android-zoom-pinch-in branch 3 times, most recently from 3907063 to c74c1e6 Compare November 25, 2026 17:12
@XiaoMengXinX

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (9f2ee7e) on top of the rebased #2301 (4993e9d); the head is now c74c1e6. No conflicts, and the diff is unchanged. Locally on macOS:

  • go tool nsgo check -target android ./internal/platform/android: passed.
  • go tool nsgo test ./internal/platform/android -- -count=1: 154 passed, 0 failed, 9 skipped.

@houko your two reviews left only one blocker: the repository checks are not current. Every push puts Check, Test, Repository quality and CodeQL in action_required, because workflow runs from a first-time contributor wait for a maintainer to approve them, and I cannot approve runs from the fork myself. Could you approve the runs for c74c1e6, or point me to someone who can? I will follow up on any failure once they run.

@houko houko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased onto latest main and verified locally with go tool nsgo check -target android ./internal/platform/android and go tool nsgo test ./internal/platform/android -run '^TestZoomScrollBrakingTouch$' -count=1. The spread-based pinch tracking covers pinch-in below the old detector threshold and restarts after pointer-count changes. The targeted regression passes. Approving and enabling merge after required checks.

@houko
houko force-pushed the fix-android-zoom-pinch-in branch from 8c08a0e to f7d2bf3 Compare November 26, 2026 00:30
@github-actions github-actions Bot added size/S and removed size/M labels Nov 26, 2026
@houko

houko commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Superseded by the rebased acceptance PR #2415, which passed all required checks and was merged. Closing this original branch to keep the fix represented once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android bug Something isn't working documentation Improvements or additions to documentation size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants