react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Crash] Can't start my app after upgrading to v0.6.0-rc

Open grin opened this issue 11 years ago • 33 comments

Tested in iOS simulator, here is the console output:

2015-06-12 13:59:56.066 [error][tid:com.facebook.React.JavaScript] "Error: undefined is not an object (evaluating 'RCTScrollViewConsts.KeyboardDismissMode.None')
 stack: 
  <unknown>       index.ios.bundle:24120
  require         index.ios.bundle:244
  <unknown>       index.ios.bundle:23173
  require         index.ios.bundle:244
  <unknown>       index.ios.bundle:1144
  require         index.ios.bundle:244
  <unknown>       index.ios.bundle:1112
  require         index.ios.bundle:244
  applyWithGuard  index.ios.bundle:880
  require         index.ios.bundle:195
  <unknown>       index.ios.bundle:47474
 URL: http://localhost:8081/index.ios.bundle
 line: 24120
 message: undefined is not an object (evaluating 'RCTScrollViewConsts.KeyboardDismissMode.None')"
2015-06-12 13:59:56.087 [error][tid:com.facebook.React.BridgeMethodQueue][RCTBridge.m:432]
 RCTDataManager.queryData was called with 4 arguments, but expects 3

grin avatar Jun 12 '15 12:06 grin

I'm getting the exact same error after update. @brentvatne: seems to be related to #1578

chirag04 avatar Jun 12 '15 15:06 chirag04

FYI: It's helpful if you include the stack trace with sourcemaps (a screenshot of the redbox should be sufficient).

But I think this is just from a breaking API change - replace usage of RCTScrollViewConsts.KeyboardDismissMode.None in your code with just the string 'none'

sahrens avatar Jun 12 '15 23:06 sahrens

please re-open if there is something else going on.

sahrens avatar Jun 12 '15 23:06 sahrens

@sahrens I'm not using keyboardDismissMode in my app at all. I'm using using <ScrollView>....</ScrollView>

After some debugging, this error seems to be coming from react-native code itself. Here: https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollView/ScrollView.js#L323

It expects RCTScrollView.Constants to export KeyboardDismissMode. However only DecelerationRate is exported. Hence the error.

re-open ?

chirag04 avatar Jun 13 '15 17:06 chirag04

That code is only in the "if (Platform.OS === 'android')" branch which isn't used in OSS yet... On Sat, Jun 13, 2015 at 10:13 AM Chirag [email protected] wrote:

@sahrens https://github.com/sahrens I'm not using keyboardDismissMode in my app at all. I'm using using ....

After some debugging, this error seems to be coming from react-native code itself. Here:

https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollView/ScrollView.js#L323

It expects RCTScrollView.Constants to export KeyboardDismissMode. However only DecelerationRate is exported. Hence the error.

— Reply to this email directly or view it on GitHub https://github.com/facebook/react-native/issues/1606#issuecomment-111730680 .

sahrens avatar Jun 13 '15 18:06 sahrens

Ok. I took the latest master. I have attached the screenshots.

Error seems to come from line 24289 in the bundle. I have attached the screenshot of those lines in the bundle. Not where how are these constants coming here.

Let me know if you need more info.

ios simulator screen shot jun 13 2015 2 52 30 pm screen shot 2015-06-13 at 2 52 48 pm

chirag04 avatar Jun 13 '15 18:06 chirag04

Hmm, do the source maps ever work for you? Looks like they didn't load here. cc @frantic, @amasad

I'll dig into the actual failure...not sure how it could be so broken... On Sat, Jun 13, 2015 at 11:56 AM Chirag [email protected] wrote:

Ok. I took the latest master. I have attached the screenshots.

Error seems to come from line 24289 in the bundle. I have attached the screenshot of those lines in the bundle. Not where how are these constants coming here.

Let me know if you need more info.

[image: ios simulator screen shot jun 13 2015 2 52 30 pm] https://cloud.githubusercontent.com/assets/954063/8145604/f9d4a3dc-11db-11e5-98ce-c9b50f0655c4.png [image: screen shot 2015-06-13 at 2 52 48 pm] https://cloud.githubusercontent.com/assets/954063/8145605/fc6bb996-11db-11e5-9d2f-eb301c0476f2.png

— Reply to this email directly or view it on GitHub https://github.com/facebook/react-native/issues/1606#issuecomment-111740134 .

sahrens avatar Jun 13 '15 19:06 sahrens

As a matter of fact, the project was generated before react-native 0.4 i guess. Not sure if that has got anything to do here.

chirag04 avatar Jun 13 '15 19:06 chirag04

Do you have sourcemaps turned off in chrome?

amasad avatar Jun 15 '15 20:06 amasad

yes. I have it turned off in chrome.

chirag04 avatar Jun 15 '15 20:06 chirag04

I just tried react-native init, then upgraded to 0.6.0-rc and npm installed again, recompiled, and everything still works with scrollview and I don't see any references to KeyboardDismissMode outside of that android-gated code.

You should turn them back on in chrome so we can see what your stack trace is. Also, not sure why they aren't working in the RedBox - separate issue, but your setup definitely has some breakage.

Did you make sure to do a clean and recompile in Xcode (cmd+shift+K, cmd+R) after upgrading? Also maybe try restarting the packager server with --reset-cache?

sahrens avatar Jun 15 '15 23:06 sahrens

Here are some observations:

  1. if you use any recent versions of react-native init to scaffold, you will not have this problem
  2. if you just go into the Examples/SampleApp and start hacking the code there to create your app -- you eventually will have this problem
  3. you will ONLY have this problem if you git clone'd the repo and are working off source

Clues:

  1. if you used recent versions of react-native init to scaffold - you WILL HAVE package.json in the app directory, and 'npm install' will place all the node_modules dependencies under the app directory; if you use npm start to run the packager -- the packager will only search from your app directory downwards ... it will never see the root react-native git-cloned source directory
  2. if you just hacked the Examples/SampleApp - even in today's master - there is no package.json, and no node_modules in the app directory ... instead, the compiled code running in the emulator is somehow wired to ask the packager for a search from the root git-cloned react-native source directory for the .js files

Sing-Li avatar Jun 16 '15 01:06 Sing-Li

I think --reset-cache did it.

chirag04 avatar Jun 16 '15 02:06 chirag04

@amasad: Sounds like we're not properly clearing cache/restarting the server on upgrade - something you can fix?

sahrens avatar Jun 16 '15 17:06 sahrens

Is the --reset-cache option undocumented on packager?

With --help it shows:

> [email protected] start /Users/sam/dev/react-native
> ./packager/packager.sh --help

Options:
  --port                                                                           [default: 8081]
  --root           add another root(s) to be used by the packager in this project
  --assetRoots     specify the root directories of app assets                    
  --platform       Specify the platform-specific blacklist (ios, android, web).    [default: "ios"]
  --skipflow       Disable flow checks                                           
  --nonPersistent  Disable file watcher

With source map enabled on chrome debugger - exception was first caught here:

reactnbug

zooming to stack trace:

reactnbug2

Then later leading to the 'red box exception:

reactnbug3

Please lmk if a gzipped index.ios.bundle + index.ios.map may be helpful.

Sing-Li avatar Jun 17 '15 02:06 Sing-Li

In my case this issue was caused by the react-native-viewport dependency in my app which itself depended on an older version of react-native. It was all fixed after I bumped it to v0.6.0-rc (https://github.com/pjjanak/react-native-viewport/pull/5) and re-linked it to my project.

grin avatar Jun 18 '15 09:06 grin

@grin THANKS!! That's the vital clue.

Issue isolated!

The packager seems to just recursively spider from the root git-cloned react-native directory down to scan for dependencies (avoiding only explicitly blacklisted dirs) and will load any old version of node-modules/react-native lying around.

So if you go to your root git-cloned react-native directory and then do a:

find . -name 'react-native' -print

... you will see any old react-native npm-installs lying around that the packager might decide to load, and cause the problem.

From my previous post on the 'observations' , you will see a mix of:

  • pre- '0.4.x' generated scaffolds that do not use package.json
  • post - '0.4.x' generated scaffolds that use package.json

The problem is that for post-'0.4.x' generated projects, UNDER THE react-native/Examples directory (which the Facebook testers will almost never have with fresh git-clones, but most devs tinkering with react-native are likely to hastily create), there might be node-modules/react-native lying around that are not 0.6.0-rc! The packager gladly load it into the ios.js.bundle - causing the problem.

I suppose other than the Examples directory, one can also have copies of stale node-modules/react-native from anything that one did npm install react-native-latest-and-greatest-component -g on.

I suppose it can also cause #1646 , and #1578 .

For my case, the bypass for now is to search-and-destroy any old node-modules/react-native lying around manually. Or blacklist the Examples directory.

Sing-Li avatar Jun 18 '15 11:06 Sing-Li

after successfully updating my packages, i was able to start the app... but I get this warning in XCode

instance method 'eventDispatcher' in category from >/Users/jawad/Library/Developer/Xcode/DerivedData/VoxIosApp->azaijsjijhyvgacmwwmnuorswkql/Build/Products/Debug->iphonesimulator/libReact.a(RCTEventDispatcher.o) overrides method from class in >/Users/jawad/Library/Developer/Xcode/DerivedData/VoxIosApp->azaijsjijhyvgacmwwmnuorswkql/Build/Products/Debug-iphonesimulator/libReact.a(RCTBridge.o)

On trying to validate the app ...

archive validation

jawadrehman avatar Jun 18 '15 12:06 jawadrehman

@jawadrehman - that shouldn't cause any problems, related to #1562 - PR welcome :smile:

brentvatne avatar Jun 18 '15 13:06 brentvatne

@brentvatne even the first message on xCode isn't going to cause problems ?

jawadrehman avatar Jun 18 '15 13:06 jawadrehman