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

App crashes running Release with advanced-build #210

Open
olivergeorge opened this issue Dec 22, 2018 · 11 comments
Open

App crashes running Release with advanced-build #210

olivergeorge opened this issue Dec 22, 2018 · 11 comments

Comments

@olivergeorge
Copy link

olivergeorge commented Dec 22, 2018

Steps to repeat

  • re-natal init FutureApp
  • cd future-app
  • lein advanced-build
  • react-native run-ios --configuration Release

Expect: Should build successfully and start running in simulator

Actual: App crashes when starting up in simulator.

re-natal 0.10.0

  "dependencies": {
    "@babel/plugin-external-helpers": "^7.0.0",
    "react": "16.6.1",
    "react-native": "0.57.7"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.45.4",
    "react-test-renderer": "16.6.1"
  },
@olivergeorge
Copy link
Author

#203 sounds similar but the patch doesn't help - code it changes isn't used (based on some basic logging)

@olivergeorge
Copy link
Author

Running release via Xcode provides the following logging

2018-12-22 15:06:45.189 [error][tid:com.facebook.react.JavaScript] Can't find variable: a
2018-12-22 15:06:45.190745+1100 FutureApp[21212:263025] Can't find variable: a
2018-12-22 15:06:45.193 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Can't find variable: a
2018-12-22 15:06:45.192955+1100 FutureApp[21212:263020] Unhandled JS Exception: Can't find variable: a
2018-12-22 15:06:45.193 [error][tid:com.facebook.react.JavaScript] Module AppRegistry is not a registered callable module (calling runApplication)
2018-12-22 15:06:45.193222+1100 FutureApp[21212:263025] Module AppRegistry is not a registered callable module (calling runApplication)
2018-12-22 15:06:45.208412+1100 FutureApp[21212:263020] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Can't find variable: a', reason: 'Unhandled JS Exception: Can't find variable: a, stack:
<unknown>@11:34036
<unknown>@11:34040
<unknown>@11:212799
v@2:1483
d@2:866
global code@317:4
'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010e7931bb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x000000010ce78735 objc_exception_throw + 48
	2   FutureApp                           0x000000010c1940af RCTFormatError + 0
	3   FutureApp                           0x000000010c18fa4c -[RCTExceptionsManager reportFatalException:stack:exceptionId:] + 507
	4   CoreFoundation                      0x000000010e79a03c __invoking___ + 140
	5   CoreFoundation                      0x000000010e7974d5 -[NSInvocation invoke] + 325
	6   CoreFoundation                      0x000000010e797926 -[NSInvocation invokeWithTarget:] + 54
	7   FutureApp                           0x000000010c1a7b41 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 612
	8   FutureApp                           0x000000010c1f0243 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 255
	9   FutureApp                           0x000000010c1effc1 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 78
	10  libdispatch.dylib                   0x00000001119ab595 _dispatch_call_block_and_release + 12
	11  libdispatch.dylib                   0x00000001119ac602 _dispatch_client_callout + 8
	12  libdispatch.dylib                   0x00000001119b3b0b _dispatch_lane_serial_drain + 791
	13  libdispatch.dylib                   0x00000001119b4784 _dispatch_lane_invoke + 428
	14  libdispatch.dylib                   0x00000001119be89a _dispatch_workloop_worker_thread + 733
	15  libsystem_pthread.dylib             0x0000000111d9c60b _pthread_wqthread + 409
	16  libsystem_pthread.dylib             0x0000000111d9c405 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

@olivergeorge olivergeorge changed the title RN 0.57 breaks with advanced compilation App crashes running Release with advanced-build Dec 22, 2018
@CalderBot
Copy link

@olivergeorge Try doing both this fix #208 (comment) and the patch #203 (comment).

  • the 208 fix solves a problem that would occur with either prod-build or advanced-build
  • the 203 fix solves the metro-bundler problem that occurs in advanced-build

Does that work?

@olivergeorge
Copy link
Author

I'm not able to test just now. I need Xcode 9 to get work code building. 203 alone didn't seem to help. Haven't tried the combo.

@olivergeorge
Copy link
Author

@CalderBot Yes, the combination worked. Nice.

If I understand the worker.js patch it's disabling the constantFoldingPlugin which seemed to be the bit which conflicted with the Google Closure optimised code.

@NuclearKev
Copy link

@CalderBot your solution stopped me from getting the Can't find variable: a error but now I'm getting this error:

Assert failed: Component must not be nil
06-26 14:52:05.411 20220 20252 E ReactNativeJS: c
06-26 14:52:05.422 20220 20252 I ReactNativeJS: Running application "appName" with appParams: {"rootTag":1}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON
06-26 14:52:05.425 20220 20252 E ReactNativeJS: Application appName has not been registered.

It was recommended that I try to stop the Metro bundler and reload the app. This didn't work. The only thing I can think of is that I need to make externs for all the JS/react-native libs that I'm using (i.e. react-native-firebase).

Any ideas how to fix this?

@olivergeorge
Copy link
Author

Here's my workaround for the advanced compilation bug... https://github.com/condense/mercury-app/wiki/Fixing-advanced-compilation-bug

@CalderBot
Copy link

@NuclearKev There are many ways that the app name can fail to be registered, but if lein prod-build worked, and lein advanced-build didn't, lack of externs could very well be your problem. In any case, yes, you do have to use externs for each JS library that does not conform to Google Closure Compiler conventions (or you can just not do advanced compilation... that's not so bad).

There are externs for some common libraries https://github.com/google/closure-compiler/wiki/Externs-For-Common-Libraries which includes firebase.

Assert failed: Component must not be nil
06-26 14:52:05.411 20220 20252 E ReactNativeJS: c
06-26 14:52:05.422 20220 20252 I ReactNativeJS: Running application "appName" with appParams: {"rootTag":1}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON
06-26 14:52:05.425 20220 20252 E ReactNativeJS: Application appName has not been registered.

It was recommended that I try to stop the Metro bundler and reload the app. This didn't work. The only thing I can think of is that I need to make externs for all the JS/react-native libs that I'm using (i.e. react-native-firebase).

@olivergeorge
Copy link
Author

I think :infer-externs is a practical alternative to manually managing externs now.

https://clojurescript.org/guides/externs

@NuclearKev
Copy link

@olivergeorge I was unaware of that compile option! Looks like I'd have to through and add some ^js stuff but that's not a big deal. Hopefully it works!

@solidfox
Copy link

solidfox commented Jul 14, 2019

Don’t know if it’s still relevant with infer externs but there’s also oops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants