dominicstop / react-native-ios-context-menu

A react-native component to use context menu's (UIMenu) on iOS 13/14+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iOS crash with NSInternalInconsistencyException, UITargetedPreview

rrebase opened this issue Β· comments

Description

First of all, amazing work on this library πŸ™Œ

I've ran into an issue with unmounting the component that causes a crash on iOS. This can be reproduced by having the context menu open while navigating to a different screen. It should close unmount and close gracefully, but instead it crashes.

At first glance, it seems different from the other reported issues.

Crash

ERROR  Your app just crashed. See the error below.
NSInternalInconsistencyException: This UITargetedPreview initializer requires that the view is in a window, but it is not. Either fix that, or use the other initializer that takes a target. (view: <ReactNativeIosContextMenu.RNIContextMenuView: 0x10d85de00> => <RCTView: 0x10b913ff0> => <RCTView: 0x31f75c510> => <RCTView: 0x31f75b910> => <RCTScrollContentView: 0x31f750f90> => <RCTCustomScrollView: 0x10e286a00> => <RCTScrollView: 0x10e286400> => <RCTView: 0x31f764f60> => <RCTView: 0x31f7652e0> => <RCTView: 0x31f7694a0> => <RNSScreenView: 0x10e13e000> => <UIViewControllerWrapperView: 0x10b913d40> => <UINavigationTransitionView: 0x10b0b12e0> => <UILayoutContainerView: 0x10b0b0f30> => <RNSScreenNavigationContainerView: 0x10b0ad5b0> => <RCTView: 0x10b0c17f0> => <RCTView: 0x10b0c1b70> => <RCTView: 0x10b0c1ef0> => <RNSScreenView: 0x10d235000>)
ios-context-menu-crash.mp4
react-native-ios-context-menu@2.5.1
react-native-ios-utilities@4.4.5

Minimal repro: https://github.com/rrebase/ios-context-menu-crash-demo

Note: have to precise with the tap + long press timing to cause the crash πŸ˜„

The helpful workaround mentioned here works, but not in all cases