wix / wix/react-native-navigation

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

Open
#7,461 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

needs triage triage: bug
Dominant language
MDX
Stars
13.2k
Forks
2.6k
Avg merge
6d 2h
Merged PRs (30d)
1

Description

🐛 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducible demo and add presentationStyle="pageSheet" in ModalScreen.tsx, then reproduce the swipe dismissal crash. Read the stack-trace locations in RNNEventEmitter.m, RNNModalManagerEventHandler.m, and RNNModalManager.m, especially the modal-attempted-dismiss event path. Done means the modal can be dismissed by the closing gesture without crashing, while state-based dismissal still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.