Skip to content

fix(ios): never lay out the selection toolbar from non-finite bounds (0.3.6) - #57

Merged
markm39 merged 1 commit into
mainfrom
fix/selection-toolbar-finite-geometry
Oct 2, 2026
Merged

markm39 merged 1 commit into
mainfrom
fix/selection-toolbar-finite-geometry

Conversation

@markm39

@markm39 markm39 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Problem

OpenNotes 1.2 App Store crash group (5 crashes, symbolicated):

CA::Layer::set_position  ->  -[CALayer setFrame:]
MobileInkCanvasView.updateSelectionToolbarFrame()   (MobileInkCanvasView.swift:565)
MobileInkCanvasView.notifySelectionChange()
MobileInkCanvasView.applyBase64Data(_:)

Reason: CALayerInvalidGeometry: CALayer position contains NaN.

  • A pooled canvas slot with a live selection was cleared. The engine's clear() kept the stale selection (fixed at the source in 0.3.5), so getSelectionBounds returned ±FLT_MAX.
  • selectionBoundsInView guarded with rect.width > 0. CGRect.width is the standardized width, so +inf passed the check, midX became inf - inf = NaN, and setFrame aborted.
  • Reproduced exactly: the shipped engine's post-clear() bounds, run through the shipped toolbar math into a real CALayer, raise the same CALayerInvalidGeometry.

Fix

  • selectionBoundsInView rejects non-finite rects, and is now the only place selection bounds are read. Hit-testing (selectionBoundsContain, selectionHandleHitTest, touchesBegan) and notifySelectionChange use it, so onInkSelectionChange sends null bounds instead of NaN to JS.
  • The podspec reads its version from package.json. It was stuck at 0.3.2, so the CocoaPods version and v… source tag no longer drift from the npm package.

Evidence

  • Guard checked with the production input: ±FLT_MAX returns nil, a NaN point returns nil, and a normal selection is unchanged.
  • swiftc -typecheck of the module passes against the iOS 26.5 simulator SDK and the React framework.
  • jest 82/82, typecheck, test:native:selection-smoke and test:native:eraser-smoke pass.
  • pod ipc spec reports version 0.3.6, tag v0.3.6.

Release

0.3.6 with a CHANGELOG entry.

CGRect.width reports the standardized width, so inverted or overflowing
selection bounds passed the existing > 0 guard while the rect's origin
and midpoints were infinite or NaN, and setting the toolbar frame raised
CALayerInvalidGeometry (OpenNotes 1.2 App Store crash group). Reject
non-finite rects. Also derive the podspec version from package.json so
the CocoaPods version and tag never drift. Release 0.3.6.
@markm39
markm39 merged commit 531bcd5 into main Oct 2, 2026
1 check passed
@markm39
markm39 deleted the fix/selection-toolbar-finite-geometry branch October 2, 2026 21: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.

1 participant