New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UIExplorer] Example won't run #2562

Closed
lowellbander opened this Issue Sep 5, 2015 · 11 comments

Comments

Projects
None yet
@lowellbander

When I run the UIExplorer Example either in the simulator or my device, I receive the following error:

Bridge modules have not yet been initialized. You may be trying to access a module too early in the startup procedure.

My search for solutions to this issue has been wholly unfruitful thus far.

@ide

This comment has been minimized.

Show comment
Hide comment
@ide

ide Sep 5, 2015

Collaborator

I believe this has been fixed in master.

Collaborator

ide commented Sep 5, 2015

I believe this has been fixed in master.

@brentvatne brentvatne changed the title from UIExplorer Example won't run to [UIExplorer] Example won't run Sep 6, 2015

@brentvatne

This comment has been minimized.

Show comment
Hide comment
@brentvatne

brentvatne Sep 6, 2015

Collaborator

Confirmed that this works on master, although I had to close Xcode, run git clean -dfx in the react-native directory, then npm i again, npm start and open up Xcode, clean the build and then compile. Closing this issue but feel free to ping me if it still doesn't work!

Collaborator

brentvatne commented Sep 6, 2015

Confirmed that this works on master, although I had to close Xcode, run git clean -dfx in the react-native directory, then npm i again, npm start and open up Xcode, clean the build and then compile. Closing this issue but feel free to ping me if it still doesn't work!

@brentvatne brentvatne closed this Sep 6, 2015

@chrisnojima

This comment has been minimized.

Show comment
Hide comment
@chrisnojima

chrisnojima Sep 8, 2015

I'm on master and I still have this issue when I run the pre-bundled flow (the server hosted js version works fine). I did a git clean -dfx, npm i, clean (and clean build folder). pre-bundled in sim and device has this issue for me.

I'm on master and I still have this issue when I run the pre-bundled flow (the server hosted js version works fine). I did a git clean -dfx, npm i, clean (and clean build folder). pre-bundled in sim and device has this issue for me.

@ide ide reopened this Sep 8, 2015

@christopherdro

This comment has been minimized.

Show comment
Hide comment
@christopherdro

christopherdro Sep 13, 2015

Contributor

Confirming that this works on master.

@chrisnojima Could it be your trying to run the example on your phone?
If so, you need to make sure update the localhost address inside of your AppDelegate.m folder to your computers network IP address.

sourceURL = [NSURL URLWithString:@"http://localhost:8081/Examples/UIExplorer/UIExplorerApp.ios.bundle?platform=ios&dev=true"];

If this dosn't work, could you possibly provide more information on what the issue is?

Contributor

christopherdro commented Sep 13, 2015

Confirming that this works on master.

@chrisnojima Could it be your trying to run the example on your phone?
If so, you need to make sure update the localhost address inside of your AppDelegate.m folder to your computers network IP address.

sourceURL = [NSURL URLWithString:@"http://localhost:8081/Examples/UIExplorer/UIExplorerApp.ios.bundle?platform=ios&dev=true"];

If this dosn't work, could you possibly provide more information on what the issue is?

@chrisnojima

This comment has been minimized.

Show comment
Hide comment
@chrisnojima

chrisnojima Sep 14, 2015

I was able to get this to work on master now but noticed the url for creating the bundle is no longer valid.

https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorer/AppDelegate.m#L69 says to curl a url but that is actually not valid (due to packager changes requiring the platform?) I get

{
type: "InternalError",
message: "react-packager has encountered an internal error, please check your terminal error output for more details"
}

and

Error: Error validating module options: child "platform" fails because ["platform" is required]
    at /Users/chrisnojima/react-native/packager/react-packager/src/lib/declareOpts.js:60:13
    at /Users/chrisnojima/react-native/packager/react-packager/src/Server/index.js:161:20
    at tryCallOne (/Users/chrisnojima/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/chrisnojima/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/Users/chrisnojima/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)

If i hit http://localhost:8081/Examples/UIExplorer/UIExplorerApp.ios.bundle?platform=ios&dev=false it works fine

I was able to get this to work on master now but noticed the url for creating the bundle is no longer valid.

https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorer/AppDelegate.m#L69 says to curl a url but that is actually not valid (due to packager changes requiring the platform?) I get

{
type: "InternalError",
message: "react-packager has encountered an internal error, please check your terminal error output for more details"
}

and

Error: Error validating module options: child "platform" fails because ["platform" is required]
    at /Users/chrisnojima/react-native/packager/react-packager/src/lib/declareOpts.js:60:13
    at /Users/chrisnojima/react-native/packager/react-packager/src/Server/index.js:161:20
    at tryCallOne (/Users/chrisnojima/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/chrisnojima/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/Users/chrisnojima/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)

If i hit http://localhost:8081/Examples/UIExplorer/UIExplorerApp.ios.bundle?platform=ios&dev=false it works fine

ericduvon added a commit to ericduvon/react-native that referenced this issue Sep 30, 2015

@jedlau

This comment has been minimized.

Show comment
Hide comment
@jedlau

jedlau Oct 2, 2015

Contributor

On 0.11.4, I think I see a race condition between RCTBatchedBridge's invalidate and line 464 within invalidate that sets _modulesByName to nil. When I step through this code in the debugger, I see RCTBridge call invalidate due to a reload. Next, RCTBridge calls [self setUp], which goes through the initialization of the modules again:

        -[RCTModuleData initWithExecutor:moduleID:instance:] + 792                                                                                                                   
        5   Samsara                             0x000000010b217f61                                                                                                                   
        -[RCTBatchedBridge initModules] + 3617                                                                                                                                       
        6   Samsara                             0x000000010b2157da                                                                                                                   
        -[RCTBatchedBridge start] + 282                                                                                                                                              
        7   Samsara                             0x000000010b215660                                                                                                                   
        -[RCTBatchedBridge initWithParentBridge:] + 1744                                                                                                                             
        8   Samsara                             0x000000010b2398b8

But, in the middle of this initialization, the debugger jumps to line 464 in RCTBatchedBridge.m:

  dispatch_group_notify(group, dispatch_get_main_queue(), ^{
    [_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
      [_jsDisplayLink invalidate];
      _jsDisplayLink = nil;

      [_javaScriptExecutor invalidate];
      _javaScriptExecutor = nil;

      if (RCTProfileIsProfiling()) {
        RCTProfileUnhookModules(self);
      }
      _moduleDataByID = nil;
>>>>  _modulesByName = nil;   <<<<
      _frameUpdateObservers = nil;

    }];
  });

This nils out _modulesByName in the middle of initialization. When initialization of the modules continues, [RCTBatchedBridge modules] evaluates the assert, which fails. (self.isValid is YES, but _modulesByName is nil.)

Contributor

jedlau commented Oct 2, 2015

On 0.11.4, I think I see a race condition between RCTBatchedBridge's invalidate and line 464 within invalidate that sets _modulesByName to nil. When I step through this code in the debugger, I see RCTBridge call invalidate due to a reload. Next, RCTBridge calls [self setUp], which goes through the initialization of the modules again:

        -[RCTModuleData initWithExecutor:moduleID:instance:] + 792                                                                                                                   
        5   Samsara                             0x000000010b217f61                                                                                                                   
        -[RCTBatchedBridge initModules] + 3617                                                                                                                                       
        6   Samsara                             0x000000010b2157da                                                                                                                   
        -[RCTBatchedBridge start] + 282                                                                                                                                              
        7   Samsara                             0x000000010b215660                                                                                                                   
        -[RCTBatchedBridge initWithParentBridge:] + 1744                                                                                                                             
        8   Samsara                             0x000000010b2398b8

But, in the middle of this initialization, the debugger jumps to line 464 in RCTBatchedBridge.m:

  dispatch_group_notify(group, dispatch_get_main_queue(), ^{
    [_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
      [_jsDisplayLink invalidate];
      _jsDisplayLink = nil;

      [_javaScriptExecutor invalidate];
      _javaScriptExecutor = nil;

      if (RCTProfileIsProfiling()) {
        RCTProfileUnhookModules(self);
      }
      _moduleDataByID = nil;
>>>>  _modulesByName = nil;   <<<<
      _frameUpdateObservers = nil;

    }];
  });

This nils out _modulesByName in the middle of initialization. When initialization of the modules continues, [RCTBatchedBridge modules] evaluates the assert, which fails. (self.isValid is YES, but _modulesByName is nil.)

@ide

This comment has been minimized.

Show comment
Hide comment
@ide

ide Oct 2, 2015

Collaborator
Collaborator

ide commented Oct 2, 2015

@tadeuzagallo

This comment has been minimized.

Show comment
Hide comment
@tadeuzagallo

tadeuzagallo Oct 2, 2015

Contributor

@jedlinlau I'm not sure I get it, [RCTBatchedBridge invalidate] and [RCTBatchedBridge modules] are called in two different instances during reload and _valid is set to NO right at the top of [RCTBatchedBridge invalidate].

Are you seeing an actual crash? If so, can you provide stack traces?

Contributor

tadeuzagallo commented Oct 2, 2015

@jedlinlau I'm not sure I get it, [RCTBatchedBridge invalidate] and [RCTBatchedBridge modules] are called in two different instances during reload and _valid is set to NO right at the top of [RCTBatchedBridge invalidate].

Are you seeing an actual crash? If so, can you provide stack traces?

@jamesfzhang

This comment has been minimized.

Show comment
Hide comment
@jamesfzhang

jamesfzhang Oct 6, 2015

Contributor

I ran into this exact same error when I forgot to require a native module. The error message, unfortunately, was not very helpful in pinpointing which file was in error.

Contributor

jamesfzhang commented Oct 6, 2015

I ran into this exact same error when I forgot to require a native module. The error message, unfortunately, was not very helpful in pinpointing which file was in error.

@tachim

This comment has been minimized.

Show comment
Hide comment
@tachim

tachim Oct 15, 2015

I'm seeing the same issue:

2015-10-15 11:19:26.745 praxis[80639:4505201] *** Assertion failure in -[RCTBatchedBridge modules](), /Users/tachim/praxis/node_modules/react-native/React/Base/RCTBatchedBridge.m:411
2015-10-15 11:19:26.750 praxis[80639:4505201] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Bridge modules have not yet been initialized. You may be trying to access a module too early in the startup procedure.'
*** First throw call stack:
(
    0   CoreFoundation                      0x017d9a94 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0071de02 objc_exception_throw + 50
    2   CoreFoundation                      0x017d992a +[NSException raise:format:arguments:] + 138
    3   Foundation                          0x0039d454 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 102
    4   praxis                              0x000b0322 -[RCTBatchedBridge modules] + 370
    5   praxis                              0x000e5812 -[RCTBridge(RCTRedBox) redBox] + 50
    6   praxis                              0x000ad59a __31-[RCTBatchedBridge loadSource:]_block_invoke + 458
    7   praxis                              0x000964ea __50+[RCTJavaScriptLoader loadBundleAtURL:onComplete:]_block_invoke + 3466
    8   CFNetwork                           0x0127d04b __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 48
    9   CFNetwork                           0x012915fb __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 353
    10  Foundation                          0x003caf98 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    11  Foundation                          0x002eee6f -[NSBlockOperation main] + 108
    12  Foundation                          0x002cf334 -[__NSOperationInternal _start:] + 697
    13  Foundation                          0x002cf074 -[NSOperation start] + 83
    14  Foundation                          0x002ceeb2 __NSOQSchedule_f + 245
    15  libdispatch.dylib                   0x04e189cd _dispatch_client_callout + 14
    16  libdispatch.dylib                   0x04dfc6d8 _dispatch_queue_drain + 2227
    17  libdispatch.dylib                   0x04dfbb8c _dispatch_queue_invoke + 570
    18  libdispatch.dylib                   0x04dfe843 _dispatch_root_queue_drain + 550
    19  libdispatch.dylib                   0x04dfe616 _dispatch_worker_thread3 + 115
    20  libsystem_pthread.dylib             0x05138270 _pthread_wqthread + 1050
    21  libsystem_pthread.dylib             0x05135f82 start_wqthread + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I see this in my packager, guessing it's related?

TypeError: Cannot read property 'root' of null
    at /Users/tachim/praxis/node_modules/react-native/packager/react-packager/src/DependencyResolver/crawlers/index.js:16:84
    at tryCallOne (/Users/tachim/praxis/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/tachim/praxis/node_modules/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/Users/tachim/praxis/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)

tachim commented Oct 15, 2015

I'm seeing the same issue:

2015-10-15 11:19:26.745 praxis[80639:4505201] *** Assertion failure in -[RCTBatchedBridge modules](), /Users/tachim/praxis/node_modules/react-native/React/Base/RCTBatchedBridge.m:411
2015-10-15 11:19:26.750 praxis[80639:4505201] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Bridge modules have not yet been initialized. You may be trying to access a module too early in the startup procedure.'
*** First throw call stack:
(
    0   CoreFoundation                      0x017d9a94 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0071de02 objc_exception_throw + 50
    2   CoreFoundation                      0x017d992a +[NSException raise:format:arguments:] + 138
    3   Foundation                          0x0039d454 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 102
    4   praxis                              0x000b0322 -[RCTBatchedBridge modules] + 370
    5   praxis                              0x000e5812 -[RCTBridge(RCTRedBox) redBox] + 50
    6   praxis                              0x000ad59a __31-[RCTBatchedBridge loadSource:]_block_invoke + 458
    7   praxis                              0x000964ea __50+[RCTJavaScriptLoader loadBundleAtURL:onComplete:]_block_invoke + 3466
    8   CFNetwork                           0x0127d04b __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 48
    9   CFNetwork                           0x012915fb __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 353
    10  Foundation                          0x003caf98 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    11  Foundation                          0x002eee6f -[NSBlockOperation main] + 108
    12  Foundation                          0x002cf334 -[__NSOperationInternal _start:] + 697
    13  Foundation                          0x002cf074 -[NSOperation start] + 83
    14  Foundation                          0x002ceeb2 __NSOQSchedule_f + 245
    15  libdispatch.dylib                   0x04e189cd _dispatch_client_callout + 14
    16  libdispatch.dylib                   0x04dfc6d8 _dispatch_queue_drain + 2227
    17  libdispatch.dylib                   0x04dfbb8c _dispatch_queue_invoke + 570
    18  libdispatch.dylib                   0x04dfe843 _dispatch_root_queue_drain + 550
    19  libdispatch.dylib                   0x04dfe616 _dispatch_worker_thread3 + 115
    20  libsystem_pthread.dylib             0x05138270 _pthread_wqthread + 1050
    21  libsystem_pthread.dylib             0x05135f82 start_wqthread + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I see this in my packager, guessing it's related?

TypeError: Cannot read property 'root' of null
    at /Users/tachim/praxis/node_modules/react-native/packager/react-packager/src/DependencyResolver/crawlers/index.js:16:84
    at tryCallOne (/Users/tachim/praxis/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/tachim/praxis/node_modules/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/Users/tachim/praxis/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)
@mkonicek

This comment has been minimized.

Show comment
Hide comment
@mkonicek

mkonicek Mar 16, 2016

Contributor

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/uiexplorer-example-wont-run

ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix. We rely on the community to provide
bugfixes as the core team is focused on performance.

Contributor

mkonicek commented Mar 16, 2016

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/uiexplorer-example-wont-run

ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix. We rely on the community to provide
bugfixes as the core team is focused on performance.

@mkonicek mkonicek added the Icebox label Mar 16, 2016

@mkonicek mkonicek closed this Mar 16, 2016

@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.