Skip to content

Fix pinch-zoom crash when second finger lands in ScrollElement - #1046

Merged
developer-ocansey merged 1 commit into
mainfrom
fix/gsm-3157-typeerror-cannot-read-properties-of-null-reading-x
Jul 24, 2026
Merged

Fix pinch-zoom crash when second finger lands in ScrollElement#1046
developer-ocansey merged 1 commit into
mainfrom
fix/gsm-3157-typeerror-cannot-read-properties-of-null-reading-x

Conversation

@developer-ocansey

Copy link
Copy Markdown
Collaborator

Issue Number

GSM-3157 — runtime crash reported via Sentry.

Overview of PR

Fixes a TypeError: Cannot read properties of null (reading 'x') thrown during two-finger pinch-zoom on touch devices in ScrollElement.

The gesture state machine was internally inconsistent: handleTouchStart nulled singleTouchStart on the second-finger pointerdown, then handleTouchMove's pinch branch dereferenced it via non-null assertions (singleTouchStart!.x) — throwing at runtime.

Changes:

  • Keep singleTouchStart as the pinch anchor for the whole gesture instead of nulling it on the second-finger pointerdown — so the pinch-move reads a valid coordinate and no frame is dropped.
  • Drop the inaccurate ! non-null assertions in the pinch branch.
  • Clear the anchor on touch end.
  • Guard the non-primary start against a missing primary (removes a second latent crash).
  • Bump version to 0.30.0-beta.19 and add a CHANGELOG entry.

Testing:

  • Added a test replaying the exact crash sequence (primary down → second finger down → second finger move); confirmed it fails on main with the original TypeError and passes with the fix.
  • Full suite green (272 tests), typecheck and lint clean.
  • No behavior change to single-finger drag, mouse, or wheel paths.

The two-finger pinch path nulled singleTouchStart on the second-finger
pointerdown, then handleTouchMove dereferenced it via non-null assertions,
throwing 'Cannot read properties of null (reading x)'.

Keep singleTouchStart as the pinch anchor for the whole gesture instead of
nulling it, drop the inaccurate ! assertions, and clear the anchor on touch
end. Also guard the non-primary start against a missing primary. Adds a test
reproducing the crash sequence.
@lnagel
lnagel requested review from PaulOskarSoe and removed request for madisvain July 24, 2026 08:02
@developer-ocansey
developer-ocansey merged commit 5190e5e into main Jul 24, 2026
1 check passed
@developer-ocansey
developer-ocansey deleted the fix/gsm-3157-typeerror-cannot-read-properties-of-null-reading-x branch July 24, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants