React-native-navigation: showModal while ActionSheetIOS is displayed crashes app

Created on 30 Jul 2020  路  9Comments  路  Source: wix/react-native-navigation

Issue Description

On iOS, if showModal is called while an action sheet (React Native ActionSheetIOS) is displayed, the app crashes with the following stack trace:

Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x600000c4fd80 "_UIAlertControllerView:0x7fa157557320.centerX"> and <NSLayoutXAxisAnchor:0x600000cbb8c0 "UITransitionView:0x7fa15740ebc0.centerX"> because they have no common ancestor.  Does the constraint or its anchors reference items in different view hierarchies?  That's illegal.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23e3de6e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff512539b2 objc_exception_throw + 48
    2   Foundation                          0x00007fff25adb6d6 -[NSLayoutConstraint setActive:] + 0
    3   Foundation                          0x00007fff25adb9ec __55+[NSLayoutConstraint _addOrRemoveConstraints:activate:]_block_invoke + 57
    4   Foundation                          0x00007fff25ac3778 -[NSISEngine withBehaviors:performModifications:] + 84
    5   Foundation                          0x00007fff25adb8c4 +[NSLayoutConstraint _addOrRemoveConstraints:activate:] + 431
    6   UIKitCore                           0x00007fff4889f8f7 +[UIAlertControllerVisualStyleActionSheet positionContentsOfAlertController:alertContentView:availableSpaceView:visualStyle:updatableConstraints:] + 708
    7   UIKitCore                           0x00007fff4888b1d0 -[_UIAlertControllerPresentationController _updateConstraintsIfNecessary] + 278
    8   UIKitCore                           0x00007fff4982d351 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1803
    9   QuartzCore                          0x00007fff2b4e9260 -[CALayer layoutSublayers] + 255
    10  QuartzCore                          0x00007fff2b4ef3eb _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 523
    11  QuartzCore                          0x00007fff2b4faa8a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
    12  QuartzCore                          0x00007fff2b443a7c _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
    13  QuartzCore                          0x00007fff2b477467 _ZN2CA11Transaction6commitEv + 649
    14  QuartzCore                          0x00007fff2b477df9 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 79
    15  CoreFoundation                      0x00007fff23da1087 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    16  CoreFoundation                      0x00007fff23d9bb3e __CFRunLoopDoObservers + 430
    17  CoreFoundation                      0x00007fff23d9c08a __CFRunLoopRun + 1226
    18  CoreFoundation                      0x00007fff23d9b8a4 CFRunLoopRunSpecific + 404
    19  GraphicsServices                    0x00007fff38c39bbe GSEventRunModal + 139
    20  UIKitCore                           0x00007fff49325968 UIApplicationMain + 1605
    21  playground                          0x0000000104204e5f main + 271
    22  libdyld.dylib                       0x00007fff520ce1fd start + 1
)

The real-world scenario in our case is that the app handles a universal link (e.g. from an email) by showing a modal, and at that point in time the app may happen to be showing an action sheet.

Steps to Reproduce / Code Snippets / Screenshots


Here's a commit that adds a button to the playground app demonstrating the crash:
https://github.com/brsaylor2/react-native-navigation/commit/3909809a79b18c32e8269a59cad6ba142fbdd6e7
(from this branch: https://github.com/brsaylor2/react-native-navigation/tree/actionsheet-crash)

Tap the button labeled "ActionSheetIOS + Modal = Crash".


Environment

  • React Native Navigation version: 6.7.5
  • React Native version: 0.62.2
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): simulator or device, many different iOS devices, iOS 12-13
iOS acceptebug requires reproduction 馃彋 stale

All 9 comments

Can reproduce

  • React Native Navigation version: 6.11.0
  • React Native version: 0.62.2
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): iPhone XS iOS 13

I just tried this with newer rn (0.63.2) and rnn (6.12.0) versions and it works just fine in my project.

Thanks for taking the time to look into this one @danilobuerger 馃敟
@brsaylor2 if you could fork the library and push a reproduction to the Playground app we would continue looking into this issue.

@danilobuerger Were you able to get the playground app working with RN 0.63.2? I'm getting an error:

npm install [email protected]
cd playground/ios
pod install
Ignoring unf_ext-0.0.7.6 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.6
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `glog` from `../../node_modules/react-native/third-party-podspecs/glog.podspec`
[!] CocoaPods could not find compatible versions for pod "ReactCommon/callinvoker":
  In Podfile:
    ReactCommon/callinvoker (from `../../node_modules/react-native/ReactCommon`)

None of your spec sources contain a spec satisfying the dependency: `ReactCommon/callinvoker (from `../../node_modules/react-native/ReactCommon`)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

@brsaylor2 Podfile was updated for rn 63.

Thanks. I rebased onto current master and cleaned and rebuilt, and this is still happening for me.

https://github.com/brsaylor2/react-native-navigation/tree/actionsheet-crash-rn0.63

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.

The issue has been closed for inactivity.

This is still an issue

Was this page helpful?
0 / 5 - 0 ratings