Skip to content

fix(gestures): read a finger's lift on the clock its moves came on - #10583

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:gestures-lift-clock
Nov 7, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:gestures-lift-clock

Conversation

@vjeux

@vjeux vjeux commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

User impact

In Linux WebKit, a slow pointerup listener breaks fast gestures. A flick releases at velocity 0, a pinch loses its speed, and a timely tap becomes a long press. Under CI load, page listeners held lifts 43–68 ms.

Problem and solution fit

  • Why it happens: the gesture host reads a finger's moves from pointer events, but read its lift from the touchend. This WebKit stamps that touchend after the pointerup listeners finish.
  • Why it harms: a lift over 40 ms after the last move reads as a still finger. The lift decides pops, pages, coasts, and a tap against a long press.
  • Why it matters: gestures must not depend on unrelated work, and iOS 26.2 Safari stamps both events alike.

Expected behavior and authority

spec:AST-100 FR4: the velocity follows the input events' own timestamps, so a handler that runs late does not change it. FR2: only a still contact releases at 0. No record changes.

Smallest restoration

  • GestureHost: a finger sampled from its pointer events lifts at its pointerup's place and time. The scroll brake's memory starts there too.
  • A finger with no paired pointerup keeps the touchend's, which still cancels the click.
  • A touchend's lifts reach the arena in time order, never raised to a later lift.
  • Follow-up: the arena's global time floor can still raise a held lift after a later move; a per-contact floor fixes that.
  • A stacked harness change reads that lift at the pointerup too; it lands with or after this. No open PR touches these lines.

Evidence

  • Reproduction before the change: the red arm db56b78 (NOT FOR LANDING) runs these tests on main's GestureHost. With a 50 ms pointerup listener in WebKit, a flick released 0, not 1,235–1,267 px/s. A pinch released 0, and the tap became a long press: 5 of 5 each.
  • Result after the change: each case passed 5 of 5, for dragged and scrolling releases.
  • Representative unchanged path: Chromium was identical on both arms in all 80 gestures-spec cases. In the iOS simulator, both events shared one stamp, 6 of 6 runs.
  • Regression test or other mutation-sensitive proof: units per lift reader, an out-of-order touch list, the lift's place, and the leftover audit. The red arm is the touchend-only mutant.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm exec vitest run packages/core/src/gestures packages/core/src/hooks \
  packages/core/src/utils packages/core/src/motion

191 files, 3,965 tests passed. On the red arm, five units fail: the late lift, the tap against a long press, the brake's memory, the out-of-order list and the lift's place.

# WebKit in mcr.microsoft.com/playwright:v1.61.1-noble, --cpus=4, CI=1, one worker
pnpm exec playwright test --config playwright.interaction.config.ts --project=webkit \
  packages/core/src/gestures/__tests__/browser/gestures.interaction.browser.spec.ts \
  --grep 'pointerup listener holds' --repeat-each=5 --retries=0
Engine Red arm This head
WebKit, three busy-lift cases ×5 0 of 15 15 of 15
Chromium, the same ×3 9 of 9 9 of 9
WebKit, whole gestures spec — 68 passed, 12 skipped
Chromium, whole gestures spec 76 passed, 4 skipped identical per case

iOS 26.2 simulator (iPhone 17 Pro), Mobile Safari: real HID swipes through idb on the NavigationStack story, with and without a 60 ms pointerup listener. On the fixed build, the pointerup and the touchend had one timestamp in 6 of 6 runs. With the listener, the touchend reached the page 65–76 ms after that stamp. Every swipe ended as in 12 runs on main: idb's swipe rests 41–64 ms before it lifts, so none pops.

Core types check, and ESLint and Prettier are clean.

GestureHost reads a finger's moves from its pointer events, but read
its lift from the touchend. WebKit stamps that touchend only once the
page's pointerup listeners are done, so a busy listener made a fast
flick read as a resting finger, and a tap lifted in time read as a
long press.

A finger sampled from its pointer events now lifts at its pointerup's
place and time: the lift and the moves share one channel. A finger
with no paired pointerup keeps the touchend's. A touchend's lifts
reach the arena in time order, so none is raised to a later one. iOS
and Chromium stamp both events alike, so nothing changes there.
@vercel

vercel Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 7, 2026 8:33pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 7, 2026
@astracat-bot

astracat-bot Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 7, 2026, 8:50 PM UTC

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · eef65f7

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
Lightbox 111.1 kB (+114 B) · 10.3 kB CSS (0) —
lab/Schedule 104.4 kB (+114 B) · 3.9 kB CSS (0) —
lab/NavigationScreen 79.5 kB (+109 B) · 1.5 kB CSS (0) —
16 more components
Component Size LoC
lab/NavigationStack 79.5 kB (+109 B) · 1.5 kB CSS (0) —
Switch 100.6 kB (+108 B) · 9.9 kB CSS (0) —
ButtonGroup 41.3 kB (+107 B) · 3.7 kB CSS (0) —
lab/TabBar 74.0 kB (+107 B) · 1.8 kB CSS (0) —
AlertDialog 104.1 kB (+106 B) · 14.3 kB CSS (0) —
DateInput 182.4 kB (+106 B) · 16.7 kB CSS (0) —
Toast 97.0 kB (+105 B) · 10.2 kB CSS (0) —
Slider 106.0 kB (+101 B) · 8.7 kB CSS (0) —
lab/Comments 324.6 kB (+101 B) · 2.5 kB CSS (0) —
PowerSearch 281.3 kB (+99 B) · 23.5 kB CSS (0) —
TimeInput 158.3 kB (+99 B) · 15.7 kB CSS (0) —
lab/PageControl 72.7 kB (+98 B) · 709 B CSS (0) —
DateTimeInput 204.0 kB (+97 B) · 18.4 kB CSS (0) —
SegmentedControl 92.4 kB (+94 B) · 6.8 kB CSS (0) —
lab/CommentThread 319.5 kB (+87 B) · 2.4 kB CSS (0) —
lab/TabBarItem 3.8 kB (0) · 1.8 kB CSS (0) —

Package size: @astryxdesign/core 6.92 MB packed (+729 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 21 rows, core 33 rows; run pnpm api:report.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot 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.

Approved pending CI: CI has not run on this head yet. This is a draft from a fork, so CI starts once it is marked ready for review and a maintainer adds the ci:run label.

Taking a touch-paired finger's lift from its pointerup restores the release velocity and the long-press deadline when a slow pointerup listener delays WebKit's touchend, and the new WebKit tests fail without the change and pass with it. Two optional wording suggestions for the new source comments are inline.

[Automated review]

* A paired finger's lift, at its `pointerup`: the place and clock its moves
* came on. Linux WebKit stamps the `touchend` that follows only after the
* page's pointerup listeners finish. A busy listener would then make a flick
* read as a resting finger. Read at the touchend, dropped with the finger.

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.

Optional, comment style: "Read at the touchend, dropped with the finger." restates what onTouchEnd and forgetContact already show, in passive form. A version that keeps only the quirk:

/**
 * A paired finger's lift, from its `pointerup`: the channel its moves come from.
 * Linux WebKit stamps the `touchend` only after the page's pointerup listeners
 * finish. A busy listener then makes a flick read as a resting finger.
 */

if (event.pointerType === 'touch' && this.usesTouchEvents) {
// The lift itself is the touchend's: it alone can cancel the click.
// The lift itself is the touchend's: it alone can cancel the click. Its
// place and time are this event's, where the finger's moves were read.

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.

Optional, comment style: "where the finger's moves were read" is passive. For example:

// The lift itself is the touchend's: it alone can cancel the click. Its
// place and time come from this event, on the channel the finger's moves use.

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 7, 2026
@vjeux
vjeux marked this pull request as ready for review November 7, 2026 21:45
@cixzhang
cixzhang merged commit f543ec7 into meta:main Nov 7, 2026
127 checks passed
@vjeux
vjeux deleted the gestures-lift-clock branch November 8, 2026 15:03

This branch was successfully deployed

1 active deployment
Preview — eef65f7d Deployed Nov 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants