[iOS][Fabric] Recognizer of a live handler stays on a recycled view and takes every drag on the component that reuses it
メンテナーはふだん 2 日以内に返信
@nihar777 がすでに取り組んでいます。
2026年11月23日 から。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- objective-c, react-native, typescript
- 領域
- mobile
調査の方向性
Start in the iOS handler manager where reattachHandlersIfNeeded, maybeBindHandler and flushOperations live, and in gestureRecognizer:shouldReceiveTouch: of the RNGestureHandler recognizer delegate. Run the linked repro (hide the box, show the 60-row ScrollView, drag) on the iOS simulator with New Architecture. Done when the list scrolls and the pan callback count stays at 0 after a recycled RCTViewComponentView is reused.
索引モデルが issue の本文から書いたものです。
説明
Description
On iOS with the New Architecture, a gesture handler that is bound by view tag (a GestureDetector without the native detector, or a legacy *GestureHandler component) keeps its UIGestureRecognizer attached to the component view after Fabric unmounts that view.
A common trigger is a display: none parent. Fabric then unmounts the subtree and returns the native views to the recycle pool, while the handler stays mounted and registered on the JS side.
The pooled view is later dequeued for an unrelated component. It still carries the recognizer, so the stale handler:
- receives every touch on the new component and fires its callbacks (
onStartand the others), although its own view is hidden; - blocks an ancestor
ScrollView, whose pan never wins, so the list does not scroll. Taps still work.
RNGestureHandlerManager reattachHandlersIfNeeded is meant to handle this case, but it does not:
- It returns early from
maybeBindHandlerwhen the view forhandler.viewTagisnilor has no superview. - It never removes the recognizer from
handler.recognizer.view, the recycled view. - It runs only from
flushOperations, so nothing runs when the mount that reuses the view queues no gesture-handler operation.
#4440 fixed the same leak for RNGestureHandlerDetector (the native-detector path). The view-tag path is unchanged in 3.5.0.
#4340 reported a related symptom for buttons and was closed without a repro.
Steps to reproduce
Repro repository: https://github.com/KeithMoc/rngh-recycle-repro
- Launch the app on an iOS simulator (New Architecture).
- Tap "1. Hide box". The box's parent gets
display: none. - Tap "2. Show list". A
ScrollViewwith 60 rows mounts. - Drag the list vertically.
Expected: the list scrolls, and "pan events" stays at 0 because the box with the pan is hidden.
Actual: the list does not scroll, and "pan events" counts up on every drag.
Measured on the iOS 26.1 simulator, RN 0.86.3, RNGH 3.5.0, Debug build:
- Steps 2 → 4: 3 of 3 runs FROZEN, at 3 drag positions each. "pan events" reached 3 in every run.
- Control, step 3 only (box stays visible): 3 of 3 runs scroll, with "pan events" at 0.
- In lldb: the stray
RNBetterPanGestureRecognizersits onRCTViewComponentViewtag 524. Its handler'sviewTagis 36.
// App.tsx (core of the repro)
const pan = Gesture.Pan().runOnJS(true).onStart(() => setPanEvents(n => n + 1));
<View style={{display: boxHidden ? 'none' : 'flex'}}>
<GestureDetector gesture={pan}>
<View style={{height: 120, backgroundColor: '#88c'}} />
</GestureDetector>
</View>
{listShown && (
<ScrollView>{ROWS.map(i => <View key={i} style={{height: 56}}><Text>Row {i}</Text></View>)}</ScrollView>
)}
Proposed fix
- Ignore touches on a recycled view.
RNGestureHandler gestureRecognizer:shouldReceiveTouch:returns NO while the recognizer's view is anRCTViewComponentViewwhosetagdiffers fromviewTag. Fabric setsview.tagwhen it dequeues a view, so a mismatch means the view was recycled. This is a single comparison per touch. Measured with only step 1 applied to 3.5.0:- Repro: 3 of 3 runs scroll, with "pan events" at 0. The stray recognizer is still attached but no longer receives touches.
- Visible box: its pan still fires (3 drags, 3 events).
- Control: 2 of 2 runs scroll.
- Detach the recognizer. In
reattachHandlersIfNeeded, remove the recognizer fromrecognizer.viewwhen that view is no longer the view registered forviewTag. KeepviewTagso the handler rebinds when its view returns. - Run the reattach after every mount. Today it runs only from
flushOperations; it should also run after each Fabric mount transaction.
We can open a PR with step 1, or with all three steps, if that direction is acceptable.
Gesture Handler version
3.5.0 (also seen on 3.0.2)
React Native version
0.86.3
Platforms
iOS
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
New Architecture (Fabric)
Build type
Debug mode
Device
iOS simulator
Device model
iPhone 17 Pro simulator, iOS 26.1
- 主要言語
- TypeScript
- スター
- 6.8k
- フォーク
- 1.1k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 28
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
software-mansion/react-native-gesture-handler のほかの issue
-
GestureDetector should bubble touches if all gestures fail (or some other generalized solution)オープンMissing repro Platform: Android Platform: iOS
難易度 5/5 1週間以上 初心者へのやさしさ 39/100
software-mansion/react-native-gesture-handler#4714 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[Web] A pan that starts on a Pressable presses it when the mouse button is released対応中かも @mokshupadhyay が 1 日前に担当しました。 オープンPlatform: Web
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
software-mansion/react-native-gesture-handler#4713 ·
メンテナーはふだん 2 日以内に返信
-
[iOS] Crash at app exit: static `_managers` map destroyed while `flushOperations` reads it対応中かも @beqramo が 5 日前に担当しました。 オープンMissing info Missing repro Platform: iOS Platform: MacOS
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
software-mansion/react-native-gesture-handler#4711 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
[iOS] Button press feedback invisible on quick taps when Reduce Motion is enabled対応中かも @andreialecu が 7 日前に担当しました。 オープンMissing info Platform: iOS Platform: MacOS
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
software-mansion/react-native-gesture-handler#4707 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
Missing info Platform: Android
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
software-mansion/react-native-gesture-handler#4706 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
software-mansion/react-native-gesture-handler の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ehmpathy/rhachet-roles-bhrain#878 ·
メンテナーはふだん 1 日以内に返信
-
Chat UI: Message actions dropdown is cut off beneath composer when message is near bottom of chat対応中かも @koeria が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
milind-soni/OpenMausBot#8023 ·
メンテナーはふだん 1 日以内に返信
-
Windows microphone listing treats words in a device name as DirectShow labels対応中かも @Sujal-chaudhary が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
clipy-recorder/clipy#447 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement from-app needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
nightly-labs/openbot#19162 ·
メンテナーはふだん 1 日以内に返信
-
triage:in-progress
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Cotal-AI/Cotal#11229 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信