React-native-navigation: [V1] Cmd-R reload exception after update from 1.1.474 to 1.1.476

Created on 15 Jul 2018  ·  16Comments  ·  Source: wix/react-native-navigation

Issue Description

Cmd-R reload exception after update from 1.1.474 to 1.1.476

Steps to Reproduce / Code Snippets / Screenshots

react-native init TestApp --version="0.55.4"
cd TestApp
yarn add react-native-navigation

XCode:

  • Libraries > Add files to [project name]
  • add libReactNativeNavigation.a
  • $(SRCROOT)/../node_modules/react-native-navigation/ios
  • Change AppDelegate.m

index.js

import { Navigation } from 'react-native-navigation';
import App from './App';

Navigation.registerComponent('example.App', () => App);

Navigation.startSingleScreenApp({
    screen: {
        screen: 'example.App'
    }
});

run:
react-native run-ios

after reload by Cmd-R application crash... if use Cmd-D -> Reload - all ok.

if run over XCode, we have this:

2018-07-15 15:28:28.355 [info][tid:main][RCTCxxBridge.mm:917] Invalidating <RCTCxxBridge: 0x6040001d6170> (parent: <RCTBridge: 0x6040000d7760>, executor: (null))
2018-07-15 15:28:28.355473+0300 TestApp[19683:173397] Invalidating <RCTCxxBridge: 0x6040001d6170> (parent: <RCTBridge: 0x6040000d7760>, executor: (null))
2018-07-15 15:28:28.356 [info][tid:main][RCTCxxBridge.mm:210] Initializing <RCTCxxBridge: 0x6000003cae60> (parent: <RCTBridge: 0x6040000d7760>, executor: (null))
2018-07-15 15:28:28.356429+0300 TestApp[19683:173397] Initializing <RCTCxxBridge: 0x6000003cae60> (parent: <RCTBridge: 0x6040000d7760>, executor: (null))
2018-07-15 15:28:28.359 [warn][tid:main][RCTModuleData.mm:67] Module RCTImageLoader requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-07-15 15:28:28.359091+0300 TestApp[19683:173397] Module RCTImageLoader requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-07-15 15:28:28.362905+0300 TestApp[19683:173397] -[UIView moduleName]: unrecognized selector sent to instance 0x7fc6fbc029a0
2018-07-15 15:28:28.407291+0300 TestApp[19683:173397] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView moduleName]: unrecognized selector sent to instance 0x7fc6fbc029a0'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000110d101e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x000000010f5fc031 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000110d91784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKit                               0x00000001137096db -[UIResponder doesNotRecognizeSelector:] + 295
    4   CoreFoundation                      0x0000000110c92898 ___forwarding___ + 1432
    5   CoreFoundation                      0x0000000110c92278 _CF_forwarding_prep_0 + 120
    6   TestApp                             0x000000010e7f5e01 -[RCCViewController sendGlobalScreenEvent:endTimestampString:shouldReset:] + 225
    7   TestApp                             0x000000010e7f6ad9 -[RCCViewController viewDidDisappear:] + 217
    8   UIKit                               0x0000000113684cf3 -[UIViewController _setViewAppearState:isAnimating:] + 333
    9   UIKit                               0x00000001136857fc -[UIViewController __viewDidDisappear:] + 132
    10  UIKit                               0x00000001136bbf3f -[UINavigationController viewDidDisappear:] + 255
    11  UIKit                               0x0000000113684cf3 -[UIViewController _setViewAppearState:isAnimating:] + 333
    12  UIKit                               0x00000001136857fc -[UIViewController __viewDidDisappear:] + 132
    13  UIKit                               0x0000000113687d7a __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke.1403 + 42
    14  UIKit                               0x0000000113685fdf -[UIViewController _executeAfterAppearanceBlock] + 78
    15  UIKit                               0x00000001134e65ef _runAfterCACommitDeferredBlocks + 634
    16  UIKit                               0x00000001134d571e _cleanUpAfterCAFlushAndRunDeferredBlocks + 388
    17  UIKit                               0x0000000113503ea5 _afterCACommitHandler + 137
    18  CoreFoundation                      0x0000000110cb2607 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    19  CoreFoundation                      0x0000000110cb255e __CFRunLoopDoObservers + 430
    20  CoreFoundation                      0x0000000110c96b81 __CFRunLoopRun + 1537
    21  CoreFoundation                      0x0000000110c9630b CFRunLoopRunSpecific + 635
    22  GraphicsServices                    0x00000001183b6a73 GSEventRunModal + 62
    23  UIKit                               0x00000001134db057 UIApplicationMain + 159
    24  TestApp                             0x000000010e4e6cef main + 111
    25  libdyld.dylib                       0x0000000115812955 start + 1
    26  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

TestApp/main.m

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char * argv[]) {
  @autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); <-- Thread 1: signal SIGABRT
  }
}

Environment

Environment:
  OS: macOS High Sierra 10.13.6
  Node: 10.6.0
  Yarn: 1.7.0
  npm: 6.1.0
  Watchman: 4.9.0
  Xcode: Xcode 9.4.1 Build version 9F2000
  Android Studio: Not Found

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.4 => 0.55.4
  • React Native Navigation version: 1.1.476
  • Device info: Simulator iPhone 6 11.4 Debug
🏚 stale

Most helpful comment

@sytler Thanks I already created a PR. https://github.com/wix/react-native-navigation/pull/3548

All 16 comments

Same here

Same here.

Please fix)

with RN: 0.56 - same problem

Same here with the exact same exception thrown.
Thou reloading from dev menu (Cmd+M) works (sometimes).

Same problem

To fix, change ios/RCCViewController.m as below.
I want you to try it.

208 ~ 209L

if (self.view != nil) {
  RCTRootView *rootView = self.view;

change to

if ([self.view isKindOfClass:[RCTRootView class]]) {
  RCTRootView *rootView = (RCTRootView *)self.view;

223 ~ 226L

if (self.view != nil){
  RCTRootView *rootView = self.view;
  NSString *screenName = [rootView moduleName];

change to

if ([self.view isKindOfClass:[RCTRootView class]]){
  NSString *screenName = [((RCTRootView *)self.view) moduleName];

@NaoyaKurahashi That is not really a good idea because you don't want to commit these files. 😕

It's not working here as well.
Tested on React Native 0.56.
Works on 1.1.474.

Does it work in lower versions?

1.1.474 - all ok, without any changes

@NaoyaKurahashi yep, that worked, u should do the PR

@sytler Thanks I already created a PR. https://github.com/wix/react-native-navigation/pull/3548

Same issue here. Thanks for getting a fix ready so quickly, @NaoyaKurahashi

Same for RN v0.49.5, and @NaoyaKurahashi 's solution works. Thank you :)

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

switchtrue picture switchtrue  ·  3Comments

swingywc picture swingywc  ·  3Comments

charlesluo2014 picture charlesluo2014  ·  3Comments

bdrobinson picture bdrobinson  ·  3Comments

EliSadaka picture EliSadaka  ·  3Comments