React-native-navigation: [iOS] ExternalComponents with a presenter property crash with Unknown selector error calling `applyOptionsOnWillMoveToParentViewController`

Created on 12 Jul 2019  ·  7Comments  ·  Source: wix/react-native-navigation

Issue Description

We're just migrating from 2.13.0 to the latest 2.22.x. We make heavy use of externalComponents to re-use views across our first party app and our customer SDKs. These views are ViewControllers that have our own presenter objects attached and accessible via a presenter property.

2.22.x is mistaking this presenter for an RNN presenter an attempting to call RNN-specific method on it on init. This manifests as unknown selector crashes.

I can fix the initial error by adding a selector check to UIViewController+LayoutProtocol.m willMoveToParentViewController:

if ([self.presenter respondsToSelector:@selector(applyOptionsOnWillMoveToParentViewController:)]) {
   [self.presenter applyOptionsOnWillMoveToParentViewController:self.resolveOptions];
}

But I'm not confident enough to sort through all the other potential spots to do this.

Steps to Reproduce / Code Snippets / Screenshots

  1. Add a 'presenter' property to a ViewController class that does not respond to applyOptionsOnWillMoveToParentViewController.
  2. Register that VC as an ExternalComponent
  3. setRoot() using the VC as the component

See Unrecognized Selector crash.


Environment

  • React Native Navigation version: 2.22.3
  • React Native version: 0.57.8
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator, iOS 12.x
🏚 stale

Most helpful comment

Any ideas on this? Any additional information I can provide?

All 7 comments

I should say it's important to us to upgrade because we're seeing a significant of our live crashes being caused by https://github.com/wix/react-native-navigation/issues/4836 right now. I was hoping to just try the fix that was shipped in 2.21 before digging through all the discussion on https://github.com/wix/react-native-navigation/issues/3767 to see what applies and what doesn't since we're not using a side menu at all.

Unfortunately this bug is present in 2.21 as well, so there's no clear upgrade path for us to avoid this issue while trying to resolve #4836.

Let me know if there are any more details I can provide. We're happy to test fixes to this as well as we really need to fix for #4836.

Any ideas on this? Any additional information I can provide?

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 Detox and report back. Thank you for your contributions.

I didn't hear anything back on this but it is still definitely an issue. We're still unable to use the latest 2.X versions as indicated because of any presenter property being called without checking it's selectors first.

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 Detox and report back. Thank you for your contributions.

The issue has been closed for inactivity.

For anyone with similar issue in the future. This bug was still present in 3.7.0, but is no longer present in 6.9.0. I don't know precisely which version it was fixed in, but the code in the UIViewController+LayoutProtocol category that was causing this and other issues with presenters on externalComponents has been totally refactored.

If you have this error, upgrade to latest RNN and it should be fixed.

Was this page helpful?
0 / 5 - 0 ratings