react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

[v7][iOS] Crash when closing react-native's modal when presentationStyle is pageSheet

Open randomBrainstormer opened this issue 2 years ago • 3 comments

🐛 Bug Report

When using react native's Modal component with presentationStyle="pageSheet" the modal does show and hide, however, when hiding the modal using the "closing gesture" (dragging the view down) the app will crash. If closed through the state change, this does not happen.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

Check out the repo in the "Reproducible Demo" section, or clone the playground application, and simply add presentationStyle="pageSheet" to the modal located in ModalScreen.tsx and try closing the modal by dragging the screen down.

...
{Platform.OS === 'ios' && (
    <Modal
        visible={this.state.modalVisible}
        presentationStyle="pageSheet" //  <--- add this
        onShow={() => console.log('===> YES, THIS IS THE CORRECT MODAL, NOW TRY TO DISMISS IT USING SWIPE GESTURE ;)')}
        onRequestClose={() => this.setState({ modalVisible: false })}
    >
...

In order to trigger this view just press Navigation in the bottom tab, then navigate to Modal or PageSheet modal, finally press "Toggle declared modal" to trigger the default modal.

Expected behavior

Expected the modal would close the same way as when changing the state.

Actual Behavior

Somehow the application crashes, apparently the RRN's modal events get called. Here's the crash dump:

CoreSimulator 783.5 - Device: iPhone 12 mini (********-****-****-****-************) - Runtime: iOS 15.2 (19C51) - DeviceType: iPhone 12 mini
terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
abort() called

Last Exception Backtrace:
0   CoreFoundation                	    0x7fff203feb94 __exceptionPreprocess + 226
1   libobjc.A.dylib               	    0x7fff201a1be7 objc_exception_throw + 48
2   CoreFoundation                	    0x7fff2047ef64 _CFThrowFormattedException + 194
3   CoreFoundation                	    0x7fff2048945a -[__NSPlaceholderDictionary initWithCapacity:].cold.1 + 0
4   CoreFoundation                	    0x7fff2046c940 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 251
5   CoreFoundation                	    0x7fff203fd82b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49
6   myapp                    	            0x10c648747 -[RNNEventEmitter sendModalAttemptedToDismissEvent:] + 119 (RNNEventEmitter.m:135)
7   myapp                    	       0x10c6522d1 -[RNNModalManagerEventHandler attemptedToDismissModal:] + 161 (RNNModalManagerEventHandler.m:21)
8   myapp                    	       0x10c651bd5 -[RNNModalManager presentationControllerDidAttemptToDismiss:] + 133 (RNNModalManager.m:184)
9   UIKitCore                     	    0x7fff24771683 -[UIPresentationController _sendDidAttemptToDismiss] + 119
10  UIKitCore                     	    0x7fff253465f4 __66-[UISheetPresentationController sheetInteraction:didChangeOffset:]_block_invoke.906 + 34
11  libdispatch.dylib             	    0x7fff2011265a _dispatch_call_block_and_release + 12
12  libdispatch.dylib             	    0x7fff2011383a _dispatch_client_callout + 8
13  libdispatch.dylib             	    0x7fff20120c88 _dispatch_main_queue_callback_4CF + 1075
14  CoreFoundation                	    0x7fff2036c84d __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
15  CoreFoundation                	    0x7fff203670aa __CFRunLoopRun + 2772
16  CoreFoundation                	    0x7fff203660f3 CFRunLoopRunSpecific + 567
17  GraphicsServices              	    0x7fff2c995cd3 GSEventRunModal + 139
18  UIKitCore                     	    0x7fff25059f42 -[UIApplication _run] + 928
19  UIKitCore                     	    0x7fff2505eb5e UIApplicationMain + 101
20  myapp                     	           0x10b898fc8 main + 104 (main.m:7)
21  dyld_sim                      	       0x1102d7ee9 start_sim + 10
22  dyld                          	       0x1193ed4fe start + 462

Your Environment

  • React Native Navigation version: 7.25.4
  • React Native version: 0.67.2
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): iOS 15.2

Reproducible Demo

https://github.com/randomBrainstormer/RnnBugExample2

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️   Yes, I have the time, and I know how to start.
  • ✖️   Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✅   No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

randomBrainstormer avatar Feb 16 '22 17:02 randomBrainstormer

Are you sure this issue belongs in this repo? Modal is a component owned by React-Native and not React-Native-Navigation. I may be incorrect though, if you're confident it belongs here no worries.

AdaData avatar Apr 21 '22 20:04 AdaData

This is still not fixed, a componentId is missing which is resulting in a crash. This is caused by React-Native-Navigation. I use this workaround for now: https://wix.github.io/react-native-navigation/api/modal/

zainspresso avatar Aug 06 '22 22:08 zainspresso

Same issue here

geroale avatar Nov 30 '23 08:11 geroale