re-natal icon indicating copy to clipboard operation
re-natal copied to clipboard

App crashes running Release with advanced-build

Open olivergeorge opened this issue 6 years ago • 11 comments

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 avatar Dec 22 '18 04:12 olivergeorge

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

olivergeorge avatar Dec 22 '18 04:12 olivergeorge

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 avatar Dec 22 '18 04:12 olivergeorge

@olivergeorge Try doing both this fix https://github.com/drapanjanas/re-natal/issues/208#issuecomment-450976858 and the patch https://github.com/drapanjanas/re-natal/issues/203#issue-383352457.

  • 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?

CalderBot avatar Jan 02 '19 20:01 CalderBot

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 avatar Jan 08 '19 00:01 olivergeorge

@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.

olivergeorge avatar Jan 10 '19 10:01 olivergeorge

@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?

NuclearKev avatar Jun 26 '19 18:06 NuclearKev

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

olivergeorge avatar Jun 27 '19 01:06 olivergeorge

@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).

CalderBot avatar Jun 27 '19 21:06 CalderBot

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

https://clojurescript.org/guides/externs

olivergeorge avatar Jun 28 '19 00:06 olivergeorge

@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!

NuclearKev avatar Jun 28 '19 12:06 NuclearKev

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

solidfox avatar Jul 14 '19 00:07 solidfox