Skip to content

[Android] Keep tracking a swipe when the pointer leaves the SwipeView bounds - #40100

Merged
kubaflo merged 3 commits into
dotnet:candidate/11.0.1xx-sr2from
MykhailoDav:fix-37089-swipeview-tracking
Nov 10, 2026
Merged

kubaflo merged 3 commits into
dotnet:candidate/11.0.1xx-sr2from
MykhailoDav:fix-37089-swipeview-tracking

Conversation

@MykhailoDav

Copy link
Copy Markdown
Contributor

Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer leaves the bounds of its content while the gesture is still in progress, and resumes only when the pointer re-enters — small vertical drift during a horizontal swipe keeps "freezing" the gesture (very noticeable with SwipeViews inside a CollectionView).

Root cause

Two guards re-evaluate an already-running gesture as if it were a new one:

  • ProcessTouchMove returns early when the current point is outside the content bounds, even when _isSwiping is already set.
  • OnTouchEvent filters ACTION_MOVE through ShouldInterceptTouch, which recomputes the swipe direction from the total pointer travel — once the vertical drift exceeds the horizontal distance it reclassifies the gesture as Up/Down, finds no items for that direction and drops the move.

Fix

Both checks now only apply before a swipe starts; once _isSwiping is set, moves are processed wherever the pointer is, which is the standard platform gesture behavior (the drawer, for example, keeps tracking past its bounds).

A second commit applies non-animated swipe translations directly instead of going through a zero-duration ViewPropertyAnimator. The zero-duration animator still needs a frame to run, so a programmatic Open(animated: false) followed by detaching the view left a pending animator keeping the view tree alive — which made the existing ItemsDoNotLeak device test order-sensitive. With the direct assignment the SwipeView category is stable across repeated runs.

Tests

SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds (Android device test): starts a swipe with synthetic motion events, moves the pointer below the view bounds while continuing the horizontal drag, and checks the content keeps following.

Without fix With fix
Android emulator (API 37) Fails: The swipe stopped tracking when the pointer left the bounds (TranslationX -52, was -52) Passes. SwipeView category 22/22, three consecutive runs

Issues Fixed

Fixes #37089

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40100

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40100"

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Nov 9, 2026
@azure-pipelines

This comment has been minimized.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@MykhailoDav! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @MykhailoDav! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 9, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 1 finding

Reviewed commit 043f14e.

See inline comments for details.

using (var down = MotionEvent.Obtain(time, time, MotionEventActions.Down, x, y, 0))
platformView.DispatchTouchEvent(down);
using (var move1 = MotionEvent.Obtain(time, time + 50, MotionEventActions.Move, x - 20 * density, y, 0))
platformView.DispatchTouchEvent(move1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[moderate] Regression Prevention and Test Coverage - The out-of-bounds move is sent only after an accepted in-bounds move has set _isSwiping. This test would therefore also pass if the bounds check in ProcessTouchMove were removed entirely, losing the intended protection before recognition. Add a negative case with Down inside the content followed by a first, horizontally dominant Move outside it, asserting that translation remains zero and SwipeStarted is not raised. This discriminates continuing an owned swipe from incorrectly starting one outside the content.

@MauiBot

MauiBot commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@MykhailoDav — existing-test verification for commit 043f14ed.

Result PASSED Platform Android Commit 043f14ed


🧪 Gate analysis — click to expand

✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence.

📱 Device tests
Test group Without fix With fix
SwipeViewTests (SwipeKeepsTrackingWhenThePointerLeavesTheBounds) ✅ Failed as expected (623s) ✅ Passed (340s)
Execution log excerpts

Without fix SwipeViewTests (SwipeKeepsTrackingWhenThePointerLeavesTheBounds)

moryBytes": 8322981888
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.controls.devicetests'..
info: Successfully uninstalled com.microsoft.maui.controls.devicetests
XHarness exit code: 1 (TESTS_FAILED)
  Passed: 0
  Failed: 1
  Skipped: 0
  Total: 1
  Tests completed with exit code: 1

With fix SwipeViewTests (SwipeKeepsTrackingWhenThePointerLeavesTheBounds)

talMemoryBytes": 8322981888
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.controls.devicetests'..
info: Successfully uninstalled com.microsoft.maui.controls.devicetests
XHarness exit code: 1 (TESTS_FAILED)
  Passed: 1
  Failed: 0
  Skipped: 0
  Total: 1
  Tests completed successfully

PR head: 043f14ed.

Without-fix baseline: c7e8239c.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Nov 10, 2026
@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@MykhailoDav — test-failure analysis for commit 043f14e.

Scope CI failures Commit 043f14e


🧪 CI Analysis — click to expand
📊 maui-pr

🧪 maui-pr-devicetests

Five incomplete main samples provide no equivalent diagnosed matches. **Insufficient (redacted) Android Essentials completion unverified; exit 1 alone is not a crash. Wrappers report these failures.


🧪 maui-pr-uitests

🧭 Follow-up — actions and refresh

Next action: Retrieve XHarness/completion evidence; compare unresolved assertions and snapshots.

Maintainers: comment /review tests to refresh this report.

@kubaflo
kubaflo changed the base branch from main to candidate/11.0.1xx-sr2 November 10, 2026 21:40
@kubaflo
kubaflo merged commit 23e1a77 into dotnet:candidate/11.0.1xx-sr2 Nov 10, 2026
173 of 184 checks passed
kubaflo added a commit that referenced this pull request Nov 11, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 13, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 17, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 043f14ed Deployed Nov 9, 2026 by MykhailoDav via conclusion #2847
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-swipeview SwipeView community ✨ Community Contribution platform/android s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SwipeView stops tracking swipe when pointer leaves item bounds during active gesture

3 participants