react-native-navigation
react-native-navigation copied to clipboard
[V6][iOS] modalPresentationStyle popover results in app crash - UIPopoverPresentationController should have a non-nil sourceView
Issue Description
When setting modalPresentationStyle to popover the application crashes when opening a modal.
xCode reports following: *** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<UIPopoverPresentationController: 0x7f9dfa32d200>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'
Steps to Reproduce / Code Snippets / Screenshots
Following is directly from playground ModalScreen.js with the options modalPresentationStyle set to popover
showModal = () => {
Navigation.showModal({
component: {
name: Screens.Modal,
passProps: {
modalPosition: this.getModalPosition() + 1,
previousModalIds: concat([], this.props.previousModalIds || [], this.props.componentId)
},
options: {
modalPresentationStyle: 'popover'
}
}
});
}
Environment
- React Native Navigation version: 6.7.5 & 6.8.0
- React Native version: 0.62.2
- Platform(s) (iOS, Android, or both?): iOS
- Device info (Simulator/Device? OS version? Debug/Release?): Simulator 13.3 / Device 13.3
Hi @WillemPCIO I couldn't reproduce this on the latest Playground app. Would you be able to provide a minimal reproduction so that I can better understand what's going on? Cheers!
Hi @jinshin1013,
These are the exact steps I'm following to reproduce:
- Download this repo
- yarn install
- pod install
- Open file ./playground/src/screens/ModalScreen.js
- Edit method showModal by adding options prop containing modalPresentationStyle: ’popover' (as per initial post)
- yarn start
- Open in xCode and run on emulator or device
- In playground application -> navigation bottom tab -> Modal button -> Show Modal Button -> app crashes with "should have a non-nil sourceView or barButtonItem set before the presentation occurs."
The expectation is that a popover is shown. Above approach works fine on Android however crashes on iOS and we are not sure if we are missing something in setting up the popover specifically for iOS or whether this is an actual issue. Within playground app, productive apps being upgraded to RNN V6, barebones vanilla app any showModal with modalPresentationStyle:'popover' crashes hence we don't think this is a repo related thing but rather:
- a RNN issue; or
- some pre-requisite on the component for iOS that is not documented e.g. what should the render method, props etc look like - basic component works fine on Android, perhaps iOS needs something else; or
- some additional option/s that should be sent in to showModal when using modalPresentationStyle:'popover'; or
- A platform version specific thing (we have tried iOS 13.3 and 12.4 with exact same results so doubtful)
Hope this helps.
Hi @WillemPCIO, thanks for providing detailed steps to reproduce the issue. I've followed your instruction but could not reproduce the same error you are seeing, see the code/clip below:
showModal = () => {
Navigation.showModal({
component: {
name: Screens.Modal,
passProps: {
modalPosition: this.getModalPosition() + 1,
previousModalIds: concat([], this.props.previousModalIds || [], this.props.componentId),
},
options: {
modalPresentationStyle: 'popover',
},
},
});
};
It'd be helpful if you could provide a minimal reproduction on Github.
I could reproduce following the @WillemPCIO steps, the bug only appears on iPad (no iPhone). @jinshin1013 your code is correct, that crash, just test it on iPad.
@RodolfoGS, Yes, that is correct it is on iPad that we are seeing this. Thanks for the repro and gif :) Much appreciated.
@jinshin1013 - sorry I've been swamped and haven't been able to put up a minimal reproduction. As per Rodolfo's comment - this appears to only happen on iPad and the code you had initially should reproduce on an iPad.
Hey guys, sorry for the delayed response 😓. Really appreciate the clip demonstrating the problem. I'll add this to the backlog!
same issue, please fix it. thanks
"UIPopoverPresentationController (<UIPopoverPresentationController: 0x11933de40>) should have a non-nil sourceView or barButtonItem set before the presentation occurs. ???? iOS 14 Xcode 12.2 ipad pro
Any solution to this?
Same here, let's fix it please
still facing this issue