wix-incubator / react-native-controllers

Native IOS Navigation for React Native (navbar, tabs, drawer)
MIT License
611 stars 82 forks source link

React Native 0.31 - NSInternalInconsistencyException when running provided example (iOS) #89

Closed aksonov closed 8 years ago

aksonov commented 8 years ago

Demo doesn't work with latest RN 0.31. #85 mentions this error, but there are also other errors, so let's make one issue - one error.

2016-08-15 14:45:49.123 [warn][tid:main][RCTEventEmitter.m:52] Sending `websocketFailed` with no listeners registered.
2016-08-15 14:45:49.491 [warn][tid:com.facebook.react.JavaScript] Set to default type=MMDrawer animationType=slide
2016-08-15 14:45:49.563 [info][tid:com.facebook.react.JavaScript] Running application "example.FirstTabScreen" with appParams: {"rootTag":1,"initialProps":{"navigatorID":"kl35n032vr37k_nav0","screenInstanceID":"kvcb6dv8zc6ps","navigatorEventID":"kvcb6dv8zc6ps_events"}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2016-08-15 14:45:49.819 example[20067:3165576] *** Assertion failure in -[RCTUIManager registerRootView:withSizeFlexibility:](), /Users/aksonov/Documents/react-native-navigation/example/node_modules/react-native/React/Modules/RCTUIManager.m:375
2016-08-15 14:45:49.840 example[20067:3165576] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Expect all root views to have unique tag. Added 1 twice'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010b3c9d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010a5bedeb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010b3c9bea +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x000000010a208e1e -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 169
    4   example                             0x0000000109df4d78 -[RCTUIManager registerRootView:withSizeFlexibility:] + 1176
    5   example                             0x0000000109d45204 -[RCTRootContentView initWithFrame:bridge:reactTag:sizeFlexiblity:] + 516
    6   example                             0x0000000109d43f4e -[RCTRootView bundleFinishedLoading:] + 286
    7   example                             0x0000000109d43e05 -[RCTRootView javaScriptDidLoad:] + 437
    8   CoreFoundation                      0x000000010b393c8c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    9   CoreFoundation                      0x000000010b3939cb _CFXRegistrationPost + 427
    10  CoreFoundation                      0x000000010b393732 ___CFXNotificationPost_block_invoke + 50
    11  CoreFoundation                      0x000000010b3dc1e2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1986
    12  CoreFoundation                      0x000000010b28b679 _CFXNotificationPost + 633
    13  Foundation                          0x000000010a14acd9 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    14  example                             0x0000000109da0b9c __38-[RCTBatchedBridge executeSourceCode:]_block_invoke.273 + 220
    15  libdispatch.dylib                   0x000000010e856d9d _dispatch_call_block_and_release + 12
    16  libdispatch.dylib                   0x000000010e8773eb _dispatch_client_callout + 8
    17  libdispatch.dylib                   0x000000010e85f1ef _dispatch_main_queue_callback_4CF + 1738
    18  CoreFoundation                      0x000000010b3230f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    19  CoreFoundation                      0x000000010b2e4b99 __CFRunLoopRun + 2073
    20  CoreFoundation                      0x000000010b2e40f8 CFRunLoopRunSpecific + 488
    21  GraphicsServices                    0x000000011038ead2 GSEventRunModal + 161
    22  UIKit                               0x000000010d1d7f09 UIApplicationMain + 171
    23  example                             0x0000000109ceb99f main + 111
    24  libdyld.dylib                       0x000000010e8ab92d start + 1
    25  ???                                 0x0000000000000001 0x0 + 1
)
2016-08-15 14:45:49.845 [info][tid:com.facebook.react.JavaScript] Running application "example.SecondTabScreen" with appParams: {"rootTag":11,"initialProps":{"navigatorID":"kl35n032vr37k_nav1","screenInstanceID":"aphiqj8oa1p8g","navigatorEventID":"aphiqj8oa1p8g_events"}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
winglight commented 8 years ago

I've met another error when compiling the project: RCCNavigationController can't be built correctly with many complicating and declaration errors.

miladebadi commented 8 years ago

I made it to work by changing RCTRootView.m file located in React ios library -> Base-> RCTRootView.m. change:

- (NSNumber *)reactTag
{
  RCTAssertMainQueue();
  if (!super.reactTag) {
    /**
     * Every root view that is created must have a unique react tag.
     * Numbering of these tags goes from 1, 11, 21, 31, etc
     *
     * NOTE: Since the bridge persists, the RootViews might be reused, so the
     * react tag must be re-assigned every time a new UIManager is created.
     */
    self.reactTag = [_bridge.uiManager allocateRootTag];
  }
  return super.reactTag;
}

to

- (NSNumber *)reactTag
{
  RCTAssertMainQueue();
  return self.reactTag = [_bridge.uiManager allocateRootTag];
}

you can temporarily use this hack but I think it is not a good solution. maybe it gives some hints for fixing this issue.

for more info see this commit: https://github.com/facebook/react-native/commit/313d84d507689a78a9f4084b162ac87c09d7d5e3#diff-9bdd6391cd866b37f84e7e9b5f276ff9

DanielZlotin commented 8 years ago

Closing as duplicate of #85