Skip to content

[0.81] Add ability to make TurboModules eager init#16095

Open
acoates-ms wants to merge 7 commits intomicrosoft:0.81-stablefrom
acoates-ms:cherrypick81
Open

[0.81] Add ability to make TurboModules eager init#16095
acoates-ms wants to merge 7 commits intomicrosoft:0.81-stablefrom
acoates-ms:cherrypick81

Conversation

@acoates-ms
Copy link
Copy Markdown
Contributor

@acoates-ms acoates-ms commented May 7, 2026

Description

Cherry picking to 0.81:
#16083, #16081, #16074, #16086, #16093

Microsoft Reviewers: Open in CodeFlow

acoates-ms and others added 7 commits May 6, 2026 21:49
* Minor text rendering perf improvement

* Change files
…mpositionEventHandler (microsoft#16081)

* fix: map Windows touch pointer IDs to small JS-safe identifiers in CompositionEventHandler (#1)

* fix: map Windows touch pointer IDs to small JS-safe identifiers in CompositionEventHandler

Windows touch input can assign arbitrarily large pointer IDs (e.g. 2233). The Fabric
  CompositionEventHandler was forwarding these directly as React Native touch identifiers
  via `activeTouch.touch.identifier = pointerId`. React Native's JS touch handler uses
  identifiers as direct array indices and hard-caps them at 20 — large values caused the
  JS layer to back-fill a 2000+ element sparse array, corrupting touch tracking state.

  The symptom: after scrolling a ScrollView/FlatList on a touch screen, Pressables and
  TouchableOpacities would remain stuck in a pressed state. Taps would fire at the
  coordinates where the scroll began rather than where the finger lifted.

  Fix: add `AllocateTouchIdentifier()` which cycles through identifiers [0, 19], skipping
  any slot already claimed by a live touch in `m_activeTouches`. This mirrors the approach
  iOS uses (cycling modulo RCTMaxTouches = 11 in RCTTouchHandler.m). The existing but
  unused `m_touchId` field is repurposed as the cycling base.

  Updated all dependent lookups that previously relied on `touch.identifier == pointerId`
  (which only worked accidentally) to use the `m_activeTouches` map key directly.

  Fixes: microsoft#16047

* fix: prevent unbounded m_touchId growth in CompositionEventHandler fallback path

When all 20 touch slots are occupied, the fallback return in
  AllocateTouchIdentifier used post-increment (`m_touchId++ % kMaxTouchIdentifier`),
  which stored the raw incremented value back into m_touchId without a modulo wrap.
  Repeated hits would grow m_touchId past 19, breaking the cycling logic and
  eventually causing signed-integer overflow (UB).

  Fix by computing the wrapped return value first, then storing the next
  wrapped value back: captures fallback = m_touchId % kMaxTouchIdentifier,
  then m_touchId = (m_touchId + 1) % kMaxTouchIdentifier.

* Create react-native-windows-2c040593-f202-44fc-a55c-5d523c493705.json

* Reserve 1 for mouse

* yarn format
* Implement outline properties on view

* Change files

* hostPlatformColorIsColorMeaningful impl

* update snapshots

* fix background clip

* default black borders should still be rendered.

* fix border sometimes being created behind the background

* snapshots
…touch state (microsoft#16086)

* fix: cancel active touches in onPointerCaptureLost to prevent zombie touch state (#2)

* fix: cancel active touches in onPointerCaptureLost to prevent zombie touch state

When the OS reclaims pointer capture mid-gesture (system back swipe, Alt+Tab,
  another window coming foreground), onPointerCaptureLost fired but never removed
  entries from m_activeTouches or dispatched a touchcancel to React Native JS.
  The result was a zombie active touch — RN JS believed a finger was still down,
  leaving Pressables and TouchableOpacities stuck in a pressed state until the
  next touch happened to reuse the same pointer ID and trigger the stale-touch
  cleanup in onPointerPressed.

  Fix: for each captured pointer in the lost-capture set, copy and erase the
  m_activeTouches entry before calling DispatchSynthesizedTouchCancelForActiveTouch,
  mirroring the pattern already used in onPointerPressed and onPointerReleased.
  The erase-before-dispatch ordering is required because
  DispatchSynthesizedTouchCancelForActiveTouch iterates m_activeTouches internally.

* match the m_pointerCapturingComponentTag != -1 check already used in CapturePointer

* Create react-native-windows-f47bdf2a-0807-483f-b63e-3c2c086bee92.json
* Add ability to register modules as eager init

* Change files
@acoates-ms acoates-ms requested review from a team as code owners May 7, 2026 04:56
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.

3 participants