Skip to content
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

Application crashing only in release mode, how to debug this kind of problem? #18680

Closed
vzaffalon opened this issue Apr 3, 2018 · 10 comments
Closed
Labels
Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.

Comments

@vzaffalon
Copy link

vzaffalon commented Apr 3, 2018

Environment

Environment:
OS: macOS High Sierra 10.13
Node: 9.10.1
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: ^16.3.0 => 16.3.0
react-native: ^0.55.0 => 0.55.0

Steps to Reproduce

Follow the steps in https://facebook.github.io/react-native/docs/running-on-device.html, Building your app for production.
Run a release build. Open Xcode. Go to edit schemes. Change the Run build configuration from Debug to Release. Or you can run it from terminal: react-native run-ios --configuration Release

Expected Behavior

JS bundle completes launch and app doesn't crash.

Actual Behavior

App crashes when the JS bundle loads. Here is the crash log:

*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Cannot call a class as a function', reason: 'Unhandled JS Exception: Cannot call a class as a function, stack: classCallCheck@11:648 t@306:876 run@279:617 runApplication@279:2046 value@18:3471 <unknown>@18:956 value@18:2898 value@18:928

My application works fine on release for Android, and also works fine in debug mode on iOS, the problem only appears on iOS release mode. How should i debug problems in release mode? I Tried to reident and look at the lines of code suggested on the error message in the main.jsbundle, but i haven't been able to find the source of the problem anyway.

I tried everything i found on the issues #18647 #16567 and in similar issues. My application code is huge so i cant check every react class to find the problem(although i tried). Should i try to reinstall all my dependencies from zero until i find what is causing the problem? It seems like react native have absolutely no support for this kind of release bugs problem from the other issues i have seen.

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55?

Thank you for your contributions.

@vzaffalon
Copy link
Author

vzaffalon commented Apr 4, 2018

after 5 days looking for the issue i found out the problem was that my index.ios.js was calling my main class like this
AppRegistry.registerComponent('App', App);
when it actually should have been like this
AppRegistry.registerComponent('App', () => App);

For anyone that got stuck in release bugs like me try installing the haul library https://github.com/callstack/haul, it still has many bugs, but it gives much better error messages then the react native core. Debugging this problem would be impossible if i had not found haul.

I also had to use haul to bundle the javascript without minification to be able to find about the bug.

@uusa35
Copy link

uusa35 commented Apr 13, 2018

@vzaffalon how to make a release build without minification please ? !

my app also running so good on debug mode but crashes when i make release. can not figure out where is the error. how to make a release build without minifaction so i can know the exact error ? !
i also installed haul.

thank you in advance .

@vzaffalon
Copy link
Author

use Haul bundle --minify false before running the application, after i found the error i had to uninstal haul because it was causing integration bugs with realm library, suggest you do the same

@uusa35
Copy link

uusa35 commented Apr 13, 2018

@vzaffalon

thank you for your reply i really apperciate.

i did that and now the error message is different

WARNING: Logging before InitGoogleLogging() is written to STDERR

i have no clue what is that.

i also had to remove haul cause it's giving lots of other errors while using redux saga while the debug mode is just working fine.

i also made new question on stack maybe someone can help

https://stackoverflow.com/questions/49815999/app-release-crashes-t-is-not-a-function

thank u

@vzaffalon

This comment has been minimized.

@react-native-bot react-native-bot added the Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. label May 15, 2018
@brunoosilva
Copy link

You can use console.error, will show in Xcode Console

@caosinhan
Copy link

It only crash in release. Debug mode is fine.

@selcukitmis
Copy link

It only crash in release. Debug mode is fine.

++

@ranvirgorai
Copy link

Destructuring of an empty object may be the reason,
ex:
let {}=this.props.result

@facebook facebook locked as resolved and limited conversation to collaborators May 15, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants