Repository navigation
Conversation
vsheyanov
pushed a commit
to vsheyanov/react-native-gesture-handler
that referenced
this pull request
Apr 1, 2021
chy101010
pushed a commit
to chy101010/react-native-gesture-handler
that referenced
this pull request
Oct 18, 2021
…egardless-of-force Update ForceTouchGestureHandler.ts
Closed
1 task
1 task
m-bert
added a commit
that referenced
this pull request
Nov 9, 2026
## Description Fixes a rare crash during native screen detachment on iOS: ```text Tag should be defined when dispatching an event ``` This crash may occur one in hundreds of times when navigation removes a gesture-containing screen from its window while its React component remains mounted. This detachment still triggers gesture-handler cleanup. > When dismissing screen with gesture (or a native back button), the native screen will be removed before React component unmount. If it still remains (not unmounted yet in that short time), it will trigger crash. So it occurs very rarely, I've reproduced it multiple times by torture testing the hover gesture. <details> <summary>Crash Log 1</summary> ``` 0 APP.debug.dylib 0x000000010f0c7f60 -[RNGestureHandler handleGesture:inState:fromManualStateChange:] + 320 1 APP.debug.dylib 0x000000010f0c7aec -[RNGestureHandler handleGesture:fromReset:fromManualStateChange:] + 860 2 APP.debug.dylib 0x000000010f0c7750 -[RNGestureHandler handleGesture:fromReset:] + 84 3 APP.debug.dylib 0x000000010f0c76bc -[RNGestureHandler handleGesture:] + 64 4 APP.debug.dylib 0x000000010f11497c -[RNBetterHoverGestureRecognizer handleGesture:] + 156 5 UIKitCore 0x00000001be673494 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 124 6 UIKitCore 0x00000001be673308 _UIGestureRecognizerSendTargetActions + 92 7 UIKitCore 0x00000001be6730ec _UIGestureRecognizerSendActions + 256 8 UIKitCore 0x00000001bede0684 -[UIGestureRecognizer _updateGestureForActiveEvents] + 432 9 UIKitCore 0x00000001bede40e8 -[UIGestureRecognizer gestureNode:didUpdatePhase:] + 300 10 Gestures 0x00000001a936093c GFGestureNodeDefaultValue + 3744 11 Gestures 0x00000001a96d4aa4 block_destroy_helper.6 + 65420 12 Gestures 0x00000001a96d3634 block_destroy_helper.6 + 60188 13 Gestures 0x00000001a96de478 block_destroy_helper.6 + 104800 14 Gestures 0x00000001a96d66bc block_destroy_helper.6 + 72612 15 Gestures 0x00000001a96d2db8 block_destroy_helper.6 + 58016 16 Gestures 0x00000001a96d2f6c block_destroy_helper.6 + 58452 17 Gestures 0x00000001a96cf864 block_destroy_helper.6 + 44364 18 Gestures 0x00000001a96d87a0 block_destroy_helper.6 + 81032 19 Gestures 0x00000001a96cf90c block_destroy_helper.6 + 44532 20 Gestures 0x00000001a935bc8c __swift_destroy_boxed_opaque_existential_1 + 520 21 UIKitCore 0x00000001bedde7f4 -[UIGestureRecognizer _updateContainer:] + 92 22 UIKitCore 0x00000001bedde8cc -[UIGestureRecognizer setContainer:] + 80 23 UIKitCore 0x00000001beeae910 _UIGestureRecognizerUnregisterFromContainer + 84 24 UIKitCore 0x00000001bf796f50 -[UIView(Internal) _removeGestureRecognizer:] + 88 25 UIKitCore 0x00000001be56333c -[UIView(UIViewGestures) removeGestureRecognizer:] + 68 26 APP.debug.dylib 0x000000010f0c6b5c -[RNGestureHandler unbindFromView] + 1108 27 APP.debug.dylib 0x000000010f114f60 -[RNHoverGestureHandler unbindFromView] + 156 28 APP.debug.dylib 0x000000010f110a74 -[RNGestureHandlerRegistry detachHandlerWithTag:fromHostDetector:] + 296 29 APP.debug.dylib 0x000000010f0e0dec -[RNGestureHandlerDetector detachAllHandlers] + 816 30 APP.debug.dylib 0x000000010f0e0964 -[RNGestureHandlerDetector willMoveToWindow:] + 64 31 UIKitCore 0x00000001be50d140 -[UIView(Hierarchy) _willMoveToWindow:] + 796 32 UIKitCore 0x00000001be4d6e78 _makeSubTreePerformSelector + 460 33 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 34 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 35 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 36 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 37 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 38 UIKitCore 0x00000001be4df14c __UIViewWillBeRemovedFromSuperview + 564 39 UIKitCore 0x00000001be4dee18 -[UIView(Hierarchy) removeFromSuperview] + 112 40 UIKitCore 0x00000001bea94a18 -[UINavigationController _didEndTransitionFromView:toView:wasCustom:] + 384 41 UIKitCore 0x00000001beaa3bc0 -[UINavigationController transitionConductor:didEndCustomTransitionWithContext:didComplete:] + 536 42 UIKit 0x00000002cf4a3b1c -[UINavigationControllerAccessibility transitionConductor:didEndCustomTransitionWithContext:didComplete:] + 136 43 UIKitCore 0x00000001bf3ec2bc __63-[_UIViewControllerTransitionConductor _startCustomTransition:]_block_invoke + 72 44 UIKitCore 0x00000001be51fdd0 -[_UIViewControllerTransitionContext completeTransition:] + 192 45 UIKitCore 0x00000001beb66018 __81-[_UINavigationParallaxTransition _animateOrCreatePropertyAnimatorForTransition:]_block_invoke_4 + 560 46 UIKitCore 0x00000001bfe69ffc __swift_closure_destructor.153 + 88 47 UIKitCore 0x00000001bfe683a4 get_enum_tag_for_layout_string So24_UIIntrusionDebugOverlayC5UIKitE9IntrusionO + 13352 48 UIKitCore 0x00000001bfe695d0 get_enum_tag_for_layout_string So24_UIIntrusionDebugOverlayC5UIKitE9IntrusionO + 18004 49 UIKitCore 0x00000001bfe6a098 __swift_closure_destructor.161Tm + 84 50 UIKitCore 0x00000001bfb49b68 __swift_closure_destructorTm + 100 51 UIKitCore 0x00000001bf90ebf0 __swift_closure_destructor.251 + 600 52 AnimationKit 0x000000027367d83c __swift_closure_destructor + 11844 53 UIKitCore 0x00000001bfce149c __swift_closure_destructor.41 + 280 54 UIKitCore 0x00000001bf793980 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ + 36 55 UIKitCore 0x00000001be5f1c80 -[UIViewAnimationBlockDelegate _sendDeferredCompletion:] + 92 56 libdispatch.dylib 0x000000019836ca34 _dispatch_call_block_and_release + 32 57 libdispatch.dylib 0x00000001983865a0 _dispatch_client_callout + 16 58 libdispatch.dylib 0x00000001983a49cc _dispatch_main_queue_drain.cold.6 + 832 59 libdispatch.dylib 0x000000019837bb0c _dispatch_main_queue_drain + 176 60 libdispatch.dylib 0x000000019837ba4c _dispatch_main_queue_callback_4CF + 44 61 CoreFoundation 0x00000001975ee9a8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 62 CoreFoundation 0x00000001975b0638 __CFRunLoopRun + 1980 63 CoreFoundation 0x000000019768ac10 _CFRunLoopRunSpecificWithOptions + 536 64 HIToolbox 0x00000001a1d685e0 RunCurrentEventLoopInMode + 320 65 HIToolbox 0x00000001a1d6b96c ReceiveNextEventCommon + 492 66 HIToolbox 0x00000001a1ef1db8 _BlockUntilNextEventMatchingListInMode + 48 67 AppKit 0x000000019d59c8c0 _DPSBlockUntilNextEventMatchingListInMode + 292 68 AppKit 0x000000019d25b59c _DPSNextEvent + 576 69 AppKit 0x000000019d9f25f8 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 832 70 AppKit 0x000000019d9f20e8 -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:] + 344 71 AppKit 0x000000019d24e920 -[NSApplication run] + 396 72 AppKit 0x000000019d226cec NSApplicationMain + 880 73 AppKit 0x000000019d471014 +[NSWindow _savedFrameFromString:] + 0 74 UIKitMacHelper 0x00000001ba3b94c4 UINSApplicationMain + 924 75 UIKitCore 0x00000001be48f3cc UIApplicationMain + 148 76 UIKitCore 0x00000001bfd57a24 block_destroy_helper.31 + 11856 77 APP.debug.dylib 0x000000010dbfa500 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 128 78 APP.debug.dylib 0x000000010dbfa470 $s4APP11AppDelegateC5$mainyyFZ + 44 79 APP.debug.dylib 0x000000010dbfb288 __debug_main_executable_dylib_entry_point + 28 80 dyld 0x0000000193318d7c start + 6652 E1107 05:49:16.682924 6902528 RNGestureHandler.mm: 497] react_native_assert failure: tag != nil && "Tag should be defined when dispatching an event" Assertion failed: (tag != nullptr && "Tag should be defined when dispatching an event"), function -[RNGestureHandler handleGesture:inState:fromManualStateChange:], file RNGestureHandler.mm, line 497. Assertion failed: (tag != nullptr && "Tag should be defined when dispatching an event"), function -[RNGestureHandler handleGesture:inState:fromManualStateChange:], file RNGestureHandler.mm, line 497. ``` </details> <details> <summary>Crash Log 2</summary> ``` E1107 03:41:29.851653 6902528 RNGestureHandler.mm:497] react_native_assert failure: tag != nil && "Tag should be defined when dispatching an event" Assertion failed: (tag != nullptr && "Tag should be defined when dispatching an event"), function -[RNGestureHandler handleGesture:inState:fromManualStateChange:], file RNGestureHandler.mm, line 497. Assertion failed: (tag != nullptr && "Tag should be defined when dispatching an event"), function -[RNGestureHandler handleGesture:inState:fromManualStateChange:], file RNGestureHandler.mm, line 497. Thread 1 Queue : com.apple.main-thread (serial) #0 0x00000001933b0650 in __pthread_kill () #1 0x00000001933ec960 in pthread_kill () #2 0x0000000193480480 in abort () #3 0x000000019347f6c8 in __assert_rtn () #4 0x000000010c50347c in -[RNGestureHandler handleGesture:inState:fromManualStateChange:] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:497 #5 0x000000010c502f88 in -[RNGestureHandler handleGesture:fromReset:fromManualStateChange:] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:460 #6 0x000000010c502c34 in -[RNGestureHandler handleGesture:fromReset:] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:400 #7 0x000000010c502ba0 in -[RNGestureHandler handleGesture:] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:395 #8 0x000000010c54fd00 in -[RNBetterHoverGestureRecognizer handleGesture:] at node_modules/react-native-gesture-handler/apple/Handlers/RNHoverHandler.m:51 #9 0x00000001be673494 in -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] () #10 0x00000001be673308 in _UIGestureRecognizerSendTargetActions () #11 0x00000001be6730ec in _UIGestureRecognizerSendActions () #12 0x00000001bede0684 in -[UIGestureRecognizer _updateGestureForActiveEvents] () #13 0x00000001bede40e8 in -[UIGestureRecognizer gestureNode:didUpdatePhase:] () #14 0x00000001a936093c in ___lldb_unnamed_symbol_1965005bc () #15 0x00000001a96d4aa4 in ___lldb_unnamed_symbol_19687499c () #16 0x00000001a96d3634 in ___lldb_unnamed_symbol_196873534 () #17 0x00000001a96de478 in ___lldb_unnamed_symbol_19687e2c8 () #18 0x00000001a96d66bc in ___lldb_unnamed_symbol_19687633c () #19 0x00000001a96d2db8 in ___lldb_unnamed_symbol_196872d6c () #20 0x00000001a96d2f6c in ___lldb_unnamed_symbol_196872de0 () #21 0x00000001a96cf864 in ___lldb_unnamed_symbol_19686f79c () #22 0x00000001a96d87a0 in ___lldb_unnamed_symbol_196878754 () #23 0x00000001a96cf90c in Gestures.GestureNode.container.setter : Swift.Optional<Gestures.GestureNodeContainer> () #24 0x00000001a935bc8c in ___lldb_unnamed_symbol_1964fbba8 () #25 0x00000001bedde7f4 in -[UIGestureRecognizer _updateContainer:] () #26 0x00000001bedde8cc in -[UIGestureRecognizer setContainer:] () #27 0x00000001beeae910 in _UIGestureRecognizerUnregisterFromContainer () #28 0x00000001bf796f50 in -[UIView(Internal) _removeGestureRecognizer:] () #29 0x00000001be56333c in -[UIView(UIViewGestures) removeGestureRecognizer:] () #30 0x000000010c502170 in -[RNGestureHandler unbindFromView] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:344 #31 0x000000010c5502e4 in -[RNHoverGestureHandler unbindFromView] at node_modules/react-native-gesture-handler/apple/Handlers/RNHoverHandler.m:115 #32 0x000000010c54bdf8 in -[RNGestureHandlerRegistry detachHandlerWithTag:fromHostDetector:] at node_modules/react-native-gesture-handler/apple/RNGestureHandlerRegistry.m:140 #33 0x000000010c51c170 in -[RNGestureHandlerDetector detachAllHandlers] at node_modules/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm:80 #34 0x000000010c51bce8 in -[RNGestureHandlerDetector willMoveToWindow:] at node_modules/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm:48 #35 0x00000001be50d140 in -[UIView(Hierarchy) _willMoveToWindow:] () #36 0x00000001be4d6e78 in _makeSubTreePerformSelector () #37 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #38 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #39 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #40 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #41 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #42 0x00000001be4df14c in __UIViewWillBeRemovedFromSuperview () #43 0x00000001be4dee18 in -[UIView(Hierarchy) removeFromSuperview] () #44 0x00000001bea94a18 in -[UINavigationController _didEndTransitionFromView:toView:wasCustom:] () #45 0x00000001beaa3bc0 in -[UINavigationController transitionConductor:didEndCustomTransitionWithContext:didComplete:] () #46 0x00000002cf4a3b1c in -[UINavigationControllerAccessibility transitionConductor:didEndCustomTransitionWithContext:didComplete:] () #47 0x00000001bf3ec2bc in __63-[_UIViewControllerTransitionConductor _startCustomTransition:]_block_invoke () #48 0x00000001be51fdd0 in -[_UIViewControllerTransitionContext completeTransition:] () #49 0x00000001beb66018 in __81-[_UINavigationParallaxTransition _animateOrCreatePropertyAnimatorForTransition:]_block_invoke_4 () #50 0x00000001bfe69ffc in ___lldb_unnamed_symbol_1ad009fdc () #51 0x00000001bfe683a4 in ___lldb_unnamed_symbol_1ad0082a0 () #52 0x00000001bfe695d0 in ___lldb_unnamed_symbol_1ad009560 () #53 0x00000001bfe6a098 in ___lldb_unnamed_symbol_1ad00a084 () #54 0x00000001bfb49b68 in ___lldb_unnamed_symbol_1acce9b44 () #55 0x00000001bf90ebf0 in ___lldb_unnamed_symbol_1acaaebb0 () #56 0x000000027367d83c in ___lldb_unnamed_symbol_26081d7d0 () #57 0x00000001bfce149c in ___lldb_unnamed_symbol_1ace81464 () #58 0x00000001bf793980 in __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ () #59 0x00000001be5f1c80 in -[UIViewAnimationBlockDelegate _sendDeferredCompletion:] () #60 0x000000019836ca34 in _dispatch_call_block_and_release () #61 0x00000001983865a0 in _dispatch_client_callout () #62 0x00000001983a49cc in _dispatch_main_queue_drain.cold.6 () #63 0x000000019837bb0c in _dispatch_main_queue_drain () #64 0x000000019837ba4c in _dispatch_main_queue_callback_4CF () #65 0x00000001975ee9a8 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ () #66 0x00000001975b0638 in __CFRunLoopRun () #67 0x000000019768ac10 in _CFRunLoopRunSpecificWithOptions () #68 0x00000001a1d685e0 in RunCurrentEventLoopInMode () #69 0x00000001a1d6b96c in ReceiveNextEventCommon () #70 0x00000001a1ef1db8 in _BlockUntilNextEventMatchingListInMode () #71 0x000000019d59c8c0 in _DPSBlockUntilNextEventMatchingListInMode () #72 0x000000019d25b59c in _DPSNextEvent () #73 0x000000019d9f25f8 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] () #74 0x000000019d9f20e8 in -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:] () #75 0x000000019d24e920 in -[NSApplication run] () #76 0x000000019d226cec in NSApplicationMain () #77 0x000000019d471014 in _NSApplicationMainWithInfoDictionary () #78 0x00000001ba3b94c4 in UINSApplicationMain () #79 0x00000001be48f3cc in UIApplicationMain () #80 0x00000001bfd57a24 in UIApplicationMain () #81 0x000000010b036500 in static UIApplicationDelegate.main() () #82 0x000000010b036470 in static AppDelegate.$main() () #83 0x000000010b037288 in main () #84 0x0000000193318d7c in start () ``` </details> Investigation showed this sequence (RN 0.88.1, RNGH 4.5.0, RN Screens 4.30.1): 1. A hover gesture is active and attached to view `<id>`. 2. `unbindFromView` finalizes the gesture as `CANCELLED` while the view is still available. 3. During `removeGestureRecognizer:`, UIKit synchronously invokes the recognizer’s action again, after `recognizer.view` becomes `nil`. 4. RNGH processes that stale callback and attempts to resolve its event target. The target is missing, causing the assertion, even though cancellation was already finalized. This is synchronous re-entry during teardown, not concurrent execution on different threads. While #4321 ensures an interrupted gesture gets its final cancellation **before detachment**, it does not handle UIKit invoking the recognizer again **during removal**, after `recognizer.view` becomes `nil`. That stale callback still attempts event-target lookup and crashes—even though cancellation already finished. The assertion remains enabled. Attached native/virtual detectors without a `reactTag` remain supported; no cached tag is reused to dispatch a stale event. <img width="2780" height="1641" alt="000" src="https://github.com/user-attachments/assets/390a6f6a-8657-4512-8e88-9e85b2670a1b" /> > Note that line numbers are not match because the debugging log is added at a time. ## Test plan - The original failure was investigated using native lifecycle logging and its crash stack. Source checks confirm that existing finalization and assertion logic are unchanged. - Test the same reproduced way (intensive mount/unmount the screen with hover gesture active) on iPad with trackpad and Mac Catalyst, does not crash so far. --------- Co-authored-by: Michał <michal.bert@swmansion.com> Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
m-bert
added a commit
that referenced
this pull request
Dec 1, 2026
## Description Fixes a rare crash during native screen detachment on iOS: ```text Tag should be defined when dispatching an event ``` This crash may occur one in hundreds of times when navigation removes a gesture-containing screen from its window while its React component remains mounted. This detachment still triggers gesture-handler cleanup. > When dismissing screen with gesture (or a native back button), the native screen will be removed before React component unmount. If it still remains (not unmounted yet in that short time), it will trigger crash. So it occurs very rarely, I've reproduced it multiple times by torture testing the hover gesture. <details> <summary>Crash Log 1</summary> ``` 0 APP.debug.dylib 0x000000010f0c7f60 -[RNGestureHandler handleGesture:inState:fromManualStateChange:] + 320 1 APP.debug.dylib 0x000000010f0c7aec -[RNGestureHandler handleGesture:fromReset:fromManualStateChange:] + 860 2 APP.debug.dylib 0x000000010f0c7750 -[RNGestureHandler handleGesture:fromReset:] + 84 3 APP.debug.dylib 0x000000010f0c76bc -[RNGestureHandler handleGesture:] + 64 4 APP.debug.dylib 0x000000010f11497c -[RNBetterHoverGestureRecognizer handleGesture:] + 156 5 UIKitCore 0x00000001be673494 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 124 6 UIKitCore 0x00000001be673308 _UIGestureRecognizerSendTargetActions + 92 7 UIKitCore 0x00000001be6730ec _UIGestureRecognizerSendActions + 256 8 UIKitCore 0x00000001bede0684 -[UIGestureRecognizer _updateGestureForActiveEvents] + 432 9 UIKitCore 0x00000001bede40e8 -[UIGestureRecognizer gestureNode:didUpdatePhase:] + 300 10 Gestures 0x00000001a936093c GFGestureNodeDefaultValue + 3744 11 Gestures 0x00000001a96d4aa4 block_destroy_helper.6 + 65420 12 Gestures 0x00000001a96d3634 block_destroy_helper.6 + 60188 13 Gestures 0x00000001a96de478 block_destroy_helper.6 + 104800 14 Gestures 0x00000001a96d66bc block_destroy_helper.6 + 72612 15 Gestures 0x00000001a96d2db8 block_destroy_helper.6 + 58016 16 Gestures 0x00000001a96d2f6c block_destroy_helper.6 + 58452 17 Gestures 0x00000001a96cf864 block_destroy_helper.6 + 44364 18 Gestures 0x00000001a96d87a0 block_destroy_helper.6 + 81032 19 Gestures 0x00000001a96cf90c block_destroy_helper.6 + 44532 20 Gestures 0x00000001a935bc8c __swift_destroy_boxed_opaque_existential_1 + 520 21 UIKitCore 0x00000001bedde7f4 -[UIGestureRecognizer _updateContainer:] + 92 22 UIKitCore 0x00000001bedde8cc -[UIGestureRecognizer setContainer:] + 80 23 UIKitCore 0x00000001beeae910 _UIGestureRecognizerUnregisterFromContainer + 84 24 UIKitCore 0x00000001bf796f50 -[UIView(Internal) _removeGestureRecognizer:] + 88 25 UIKitCore 0x00000001be56333c -[UIView(UIViewGestures) removeGestureRecognizer:] + 68 26 APP.debug.dylib 0x000000010f0c6b5c -[RNGestureHandler unbindFromView] + 1108 27 APP.debug.dylib 0x000000010f114f60 -[RNHoverGestureHandler unbindFromView] + 156 28 APP.debug.dylib 0x000000010f110a74 -[RNGestureHandlerRegistry detachHandlerWithTag:fromHostDetector:] + 296 29 APP.debug.dylib 0x000000010f0e0dec -[RNGestureHandlerDetector detachAllHandlers] + 816 30 APP.debug.dylib 0x000000010f0e0964 -[RNGestureHandlerDetector willMoveToWindow:] + 64 31 UIKitCore 0x00000001be50d140 -[UIView(Hierarchy) _willMoveToWindow:] + 796 32 UIKitCore 0x00000001be4d6e78 _makeSubTreePerformSelector + 460 33 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 34 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 35 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 36 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 37 UIKitCore 0x00000001be4d6eb4 _makeSubTreePerformSelector + 520 38 UIKitCore 0x00000001be4df14c __UIViewWillBeRemovedFromSuperview + 564 39 UIKitCore 0x00000001be4dee18 -[UIView(Hierarchy) removeFromSuperview] + 112 40 UIKitCore 0x00000001bea94a18 -[UINavigationController _didEndTransitionFromView:toView:wasCustom:] + 384 41 UIKitCore 0x00000001beaa3bc0 -[UINavigationController transitionConductor:didEndCustomTransitionWithContext:didComplete:] + 536 42 UIKit 0x00000002cf4a3b1c -[UINavigationControllerAccessibility transitionConductor:didEndCustomTransitionWithContext:didComplete:] + 136 43 UIKitCore 0x00000001bf3ec2bc __63-[_UIViewControllerTransitionConductor _startCustomTransition:]_block_invoke + 72 44 UIKitCore 0x00000001be51fdd0 -[_UIViewControllerTransitionContext completeTransition:] + 192 45 UIKitCore 0x00000001beb66018 __81-[_UINavigationParallaxTransition _animateOrCreatePropertyAnimatorForTransition:]_block_invoke_4 + 560 46 UIKitCore 0x00000001bfe69ffc __swift_closure_destructor.153 + 88 47 UIKitCore 0x00000001bfe683a4 get_enum_tag_for_layout_string So24_UIIntrusionDebugOverlayC5UIKitE9IntrusionO + 13352 48 UIKitCore 0x00000001bfe695d0 get_enum_tag_for_layout_string So24_UIIntrusionDebugOverlayC5UIKitE9IntrusionO + 18004 49 UIKitCore 0x00000001bfe6a098 __swift_closure_destructor.161Tm + 84 50 UIKitCore 0x00000001bfb49b68 __swift_closure_destructorTm + 100 51 UIKitCore 0x00000001bf90ebf0 __swift_closure_destructor.251 + 600 52 AnimationKit 0x000000027367d83c __swift_closure_destructor + 11844 53 UIKitCore 0x00000001bfce149c __swift_closure_destructor.41 + 280 54 UIKitCore 0x00000001bf793980 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ + 36 55 UIKitCore 0x00000001be5f1c80 -[UIViewAnimationBlockDelegate _sendDeferredCompletion:] + 92 56 libdispatch.dylib 0x000000019836ca34 _dispatch_call_block_and_release + 32 57 libdispatch.dylib 0x00000001983865a0 _dispatch_client_callout + 16 58 libdispatch.dylib 0x00000001983a49cc _dispatch_main_queue_drain.cold.6 + 832 59 libdispatch.dylib 0x000000019837bb0c _dispatch_main_queue_drain + 176 60 libdispatch.dylib 0x000000019837ba4c _dispatch_main_queue_callback_4CF + 44 61 CoreFoundation 0x00000001975ee9a8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 62 CoreFoundation 0x00000001975b0638 __CFRunLoopRun + 1980 63 CoreFoundation 0x000000019768ac10 _CFRunLoopRunSpecificWithOptions + 536 64 HIToolbox 0x00000001a1d685e0 RunCurrentEventLoopInMode + 320 65 HIToolbox 0x00000001a1d6b96c ReceiveNextEventCommon + 492 66 HIToolbox 0x00000001a1ef1db8 _BlockUntilNextEventMatchingListInMode + 48 67 AppKit 0x000000019d59c8c0 _DPSBlockUntilNextEventMatchingListInMode + 292 68 AppKit 0x000000019d25b59c _DPSNextEvent + 576 69 AppKit 0x000000019d9f25f8 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 832 70 AppKit 0x000000019d9f20e8 -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:] + 344 71 AppKit 0x000000019d24e920 -[NSApplication run] + 396 72 AppKit 0x000000019d226cec NSApplicationMain + 880 73 AppKit 0x000000019d471014 +[NSWindow _savedFrameFromString:] + 0 74 UIKitMacHelper 0x00000001ba3b94c4 UINSApplicationMain + 924 75 UIKitCore 0x00000001be48f3cc UIApplicationMain + 148 76 UIKitCore 0x00000001bfd57a24 block_destroy_helper.31 + 11856 77 APP.debug.dylib 0x000000010dbfa500 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 128 78 APP.debug.dylib 0x000000010dbfa470 $s4APP11AppDelegateC5$mainyyFZ + 44 79 APP.debug.dylib 0x000000010dbfb288 __debug_main_executable_dylib_entry_point + 28 80 dyld 0x0000000193318d7c start + 6652 E1107 05:49:16.682924 6902528 RNGestureHandler.mm: 497] react_native_assert failure: tag != nil && "Tag should be defined when dispatching an event" Assertion failed: (tag != nullptr && "Tag should be defined when dispatching an event"), function -[RNGestureHandler handleGesture:inState:fromManualStateChange:], file RNGestureHandler.mm, line 497. Assertion failed: (tag != nullptr && "Tag should be defined when dispatching an event"), function -[RNGestureHandler handleGesture:inState:fromManualStateChange:], file RNGestureHandler.mm, line 497. ``` </details> <details> <summary>Crash Log 2</summary> ``` E1107 03:41:29.851653 6902528 RNGestureHandler.mm:497] react_native_assert failure: tag != nil && "Tag should be defined when dispatching an event" Assertion failed: (tag != nullptr && "Tag should be defined when dispatching an event"), function -[RNGestureHandler handleGesture:inState:fromManualStateChange:], file RNGestureHandler.mm, line 497. Assertion failed: (tag != nullptr && "Tag should be defined when dispatching an event"), function -[RNGestureHandler handleGesture:inState:fromManualStateChange:], file RNGestureHandler.mm, line 497. Thread 1 Queue : com.apple.main-thread (serial) #0 0x00000001933b0650 in __pthread_kill () #1 0x00000001933ec960 in pthread_kill () #2 0x0000000193480480 in abort () #3 0x000000019347f6c8 in __assert_rtn () #4 0x000000010c50347c in -[RNGestureHandler handleGesture:inState:fromManualStateChange:] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:497 #5 0x000000010c502f88 in -[RNGestureHandler handleGesture:fromReset:fromManualStateChange:] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:460 #6 0x000000010c502c34 in -[RNGestureHandler handleGesture:fromReset:] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:400 #7 0x000000010c502ba0 in -[RNGestureHandler handleGesture:] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:395 #8 0x000000010c54fd00 in -[RNBetterHoverGestureRecognizer handleGesture:] at node_modules/react-native-gesture-handler/apple/Handlers/RNHoverHandler.m:51 #9 0x00000001be673494 in -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] () #10 0x00000001be673308 in _UIGestureRecognizerSendTargetActions () #11 0x00000001be6730ec in _UIGestureRecognizerSendActions () #12 0x00000001bede0684 in -[UIGestureRecognizer _updateGestureForActiveEvents] () #13 0x00000001bede40e8 in -[UIGestureRecognizer gestureNode:didUpdatePhase:] () #14 0x00000001a936093c in ___lldb_unnamed_symbol_1965005bc () #15 0x00000001a96d4aa4 in ___lldb_unnamed_symbol_19687499c () #16 0x00000001a96d3634 in ___lldb_unnamed_symbol_196873534 () #17 0x00000001a96de478 in ___lldb_unnamed_symbol_19687e2c8 () #18 0x00000001a96d66bc in ___lldb_unnamed_symbol_19687633c () #19 0x00000001a96d2db8 in ___lldb_unnamed_symbol_196872d6c () #20 0x00000001a96d2f6c in ___lldb_unnamed_symbol_196872de0 () #21 0x00000001a96cf864 in ___lldb_unnamed_symbol_19686f79c () #22 0x00000001a96d87a0 in ___lldb_unnamed_symbol_196878754 () #23 0x00000001a96cf90c in Gestures.GestureNode.container.setter : Swift.Optional<Gestures.GestureNodeContainer> () #24 0x00000001a935bc8c in ___lldb_unnamed_symbol_1964fbba8 () #25 0x00000001bedde7f4 in -[UIGestureRecognizer _updateContainer:] () #26 0x00000001bedde8cc in -[UIGestureRecognizer setContainer:] () #27 0x00000001beeae910 in _UIGestureRecognizerUnregisterFromContainer () #28 0x00000001bf796f50 in -[UIView(Internal) _removeGestureRecognizer:] () #29 0x00000001be56333c in -[UIView(UIViewGestures) removeGestureRecognizer:] () #30 0x000000010c502170 in -[RNGestureHandler unbindFromView] at node_modules/react-native-gesture-handler/apple/RNGestureHandler.mm:344 #31 0x000000010c5502e4 in -[RNHoverGestureHandler unbindFromView] at node_modules/react-native-gesture-handler/apple/Handlers/RNHoverHandler.m:115 #32 0x000000010c54bdf8 in -[RNGestureHandlerRegistry detachHandlerWithTag:fromHostDetector:] at node_modules/react-native-gesture-handler/apple/RNGestureHandlerRegistry.m:140 #33 0x000000010c51c170 in -[RNGestureHandlerDetector detachAllHandlers] at node_modules/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm:80 #34 0x000000010c51bce8 in -[RNGestureHandlerDetector willMoveToWindow:] at node_modules/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm:48 #35 0x00000001be50d140 in -[UIView(Hierarchy) _willMoveToWindow:] () #36 0x00000001be4d6e78 in _makeSubTreePerformSelector () #37 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #38 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #39 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #40 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #41 0x00000001be4d6eb4 in _makeSubTreePerformSelector () #42 0x00000001be4df14c in __UIViewWillBeRemovedFromSuperview () #43 0x00000001be4dee18 in -[UIView(Hierarchy) removeFromSuperview] () #44 0x00000001bea94a18 in -[UINavigationController _didEndTransitionFromView:toView:wasCustom:] () #45 0x00000001beaa3bc0 in -[UINavigationController transitionConductor:didEndCustomTransitionWithContext:didComplete:] () #46 0x00000002cf4a3b1c in -[UINavigationControllerAccessibility transitionConductor:didEndCustomTransitionWithContext:didComplete:] () #47 0x00000001bf3ec2bc in __63-[_UIViewControllerTransitionConductor _startCustomTransition:]_block_invoke () #48 0x00000001be51fdd0 in -[_UIViewControllerTransitionContext completeTransition:] () #49 0x00000001beb66018 in __81-[_UINavigationParallaxTransition _animateOrCreatePropertyAnimatorForTransition:]_block_invoke_4 () #50 0x00000001bfe69ffc in ___lldb_unnamed_symbol_1ad009fdc () #51 0x00000001bfe683a4 in ___lldb_unnamed_symbol_1ad0082a0 () #52 0x00000001bfe695d0 in ___lldb_unnamed_symbol_1ad009560 () #53 0x00000001bfe6a098 in ___lldb_unnamed_symbol_1ad00a084 () #54 0x00000001bfb49b68 in ___lldb_unnamed_symbol_1acce9b44 () #55 0x00000001bf90ebf0 in ___lldb_unnamed_symbol_1acaaebb0 () #56 0x000000027367d83c in ___lldb_unnamed_symbol_26081d7d0 () #57 0x00000001bfce149c in ___lldb_unnamed_symbol_1ace81464 () #58 0x00000001bf793980 in __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ () #59 0x00000001be5f1c80 in -[UIViewAnimationBlockDelegate _sendDeferredCompletion:] () #60 0x000000019836ca34 in _dispatch_call_block_and_release () #61 0x00000001983865a0 in _dispatch_client_callout () #62 0x00000001983a49cc in _dispatch_main_queue_drain.cold.6 () #63 0x000000019837bb0c in _dispatch_main_queue_drain () #64 0x000000019837ba4c in _dispatch_main_queue_callback_4CF () #65 0x00000001975ee9a8 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ () #66 0x00000001975b0638 in __CFRunLoopRun () #67 0x000000019768ac10 in _CFRunLoopRunSpecificWithOptions () #68 0x00000001a1d685e0 in RunCurrentEventLoopInMode () #69 0x00000001a1d6b96c in ReceiveNextEventCommon () #70 0x00000001a1ef1db8 in _BlockUntilNextEventMatchingListInMode () #71 0x000000019d59c8c0 in _DPSBlockUntilNextEventMatchingListInMode () #72 0x000000019d25b59c in _DPSNextEvent () #73 0x000000019d9f25f8 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] () #74 0x000000019d9f20e8 in -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:] () #75 0x000000019d24e920 in -[NSApplication run] () #76 0x000000019d226cec in NSApplicationMain () #77 0x000000019d471014 in _NSApplicationMainWithInfoDictionary () #78 0x00000001ba3b94c4 in UINSApplicationMain () #79 0x00000001be48f3cc in UIApplicationMain () #80 0x00000001bfd57a24 in UIApplicationMain () #81 0x000000010b036500 in static UIApplicationDelegate.main() () #82 0x000000010b036470 in static AppDelegate.$main() () #83 0x000000010b037288 in main () #84 0x0000000193318d7c in start () ``` </details> Investigation showed this sequence (RN 0.88.1, RNGH 4.5.0, RN Screens 4.30.1): 1. A hover gesture is active and attached to view `<id>`. 2. `unbindFromView` finalizes the gesture as `CANCELLED` while the view is still available. 3. During `removeGestureRecognizer:`, UIKit synchronously invokes the recognizer’s action again, after `recognizer.view` becomes `nil`. 4. RNGH processes that stale callback and attempts to resolve its event target. The target is missing, causing the assertion, even though cancellation was already finalized. This is synchronous re-entry during teardown, not concurrent execution on different threads. While #4321 ensures an interrupted gesture gets its final cancellation **before detachment**, it does not handle UIKit invoking the recognizer again **during removal**, after `recognizer.view` becomes `nil`. That stale callback still attempts event-target lookup and crashes—even though cancellation already finished. The assertion remains enabled. Attached native/virtual detectors without a `reactTag` remain supported; no cached tag is reused to dispatch a stale event. <img width="2780" height="1641" alt="000" src="https://github.com/user-attachments/assets/390a6f6a-8657-4512-8e88-9e85b2670a1b" /> > Note that line numbers are not match because the debugging log is added at a time. ## Test plan - The original failure was investigated using native lifecycle logging and its crash stack. Source checks confirm that existing finalization and assertion logic are unchanged. - Test the same reproduced way (intensive mount/unmount the screen with hover gesture active) on iPad with trackpad and Mac Catalyst, does not crash so far. --------- Co-authored-by: Michał <michal.bert@swmansion.com> Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This merge request introduces hitSlop property support. This property allows for extending touchable area of the gesture handler. It is added to the base gesturehandler class which means that it can be used for all gesture handlers (including native component wrapper handler)