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

[V6][iOS] modalPresentationStyle popover results in app crash - UIPopoverPresentationController should have a non-nil sourceView

Open WillemPCIO opened this issue 4 years ago • 11 comments

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

WillemPCIO avatar Jun 28 '20 12:06 WillemPCIO

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!

jinshin1013 avatar Jun 29 '20 05:06 jinshin1013

Hi @jinshin1013,

These are the exact steps I'm following to reproduce:

  1. Download this repo
  2. yarn install
  3. pod install
  4. Open file ./playground/src/screens/ModalScreen.js
  5. Edit method showModal by adding options prop containing modalPresentationStyle: ’popover' (as per initial post)
  6. yarn start
  7. Open in xCode and run on emulator or device
  8. 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:

  1. a RNN issue; or
  2. 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
  3. some additional option/s that should be sent in to showModal when using modalPresentationStyle:'popover'; or
  4. A platform version specific thing (we have tried iOS 13.3 and 12.4 with exact same results so doubtful)

Hope this helps.

WillemPCIO avatar Jun 29 '20 11:06 WillemPCIO

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',
      },
    },
  });
};

popover

It'd be helpful if you could provide a minimal reproduction on Github.

jinshin1013 avatar Jul 01 '20 00:07 jinshin1013

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.

ezgif com-video-to-gif

RodolfoGS avatar Jul 07 '20 13:07 RodolfoGS

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

WillemPCIO avatar Jul 07 '20 13:07 WillemPCIO

Hey guys, sorry for the delayed response 😓. Really appreciate the clip demonstrating the problem. I'll add this to the backlog!

jinshin1013 avatar Jul 23 '20 10:07 jinshin1013

same issue, please fix it. thanks

vuongductuanktmt avatar Dec 04 '20 09:12 vuongductuanktmt

"UIPopoverPresentationController (<UIPopoverPresentationController: 0x11933de40>) should have a non-nil sourceView or barButtonItem set before the presentation occurs. ???? iOS 14 Xcode 12.2 ipad pro

gahlot3 avatar Feb 09 '21 06:02 gahlot3

Any solution to this?

meharoofnajeeb avatar May 19 '22 07:05 meharoofnajeeb

Same here, let's fix it please

agestaun avatar Dec 19 '22 11:12 agestaun

still facing this issue

Abhishek2250 avatar Jan 24 '23 07:01 Abhishek2250