f111fei / react-native-unity-view

Show an unity view in react native
MIT License
402 stars 102 forks source link

iOS crashes on launch in release builds only #79

Open mtostenson opened 5 years ago

mtostenson commented 5 years ago

Unity version: 2018.2.1f1 React native version: 0.57.8

When running straight out of XCode, it works fine. However, creating a release IPA file results in an immediate crash on launch. We use fastlane to generate an IPA for beta testing, so we don't usually see this problem until then. I tested this using a blank react native project, and a blank unity project, and the crash is there. There are no useful crash logs unfortunately. Has anyone been able to publish an iOS release using this library?

Thanks

UPDATE: Setting "Strip Linked Product" to NO prevents this crash. However, this means the debug symbols are not removed and causes the app size to increase by 30-50%

FURTHER UPDATE The "Strip Linked Product" workaround does not appear to work for iOS 12.1.

Here is an issue I created in the react native repo that describes a possible solution.

Here's the crash report:

Thread 7 name:  com.facebook.react.JavaScript
Thread 7 Crashed:
0   libsystem_kernel.dylib          0x00000001fbbbd104 __pthread_kill + 8
1   libsystem_pthread.dylib         0x00000001fbc3ca00 pthread_kill$VARIANT$armv81 + 296
2   libsystem_c.dylib               0x00000001fbb14d78 abort + 140
3   libsystem_malloc.dylib          0x00000001fbc11768 _malloc_put + 0
4   libsystem_malloc.dylib          0x00000001fbc11924 malloc_report + 64
5   libsystem_malloc.dylib          0x00000001fbc042d0 free + 376
6   libc++.1.dylib                  0x00000001fb1bf120 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string+ 258336 () + 32
7   UnityTest                       0x0000000102de23a4 std::__1::__vector_base<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::~__vector_base() + 730020 (vector:451)
8   UnityTest                       0x0000000103385214 facebook::react::ModuleRegistry::getConfig+ 6640148 (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 100
9   UnityTest                       0x0000000103394168 facebook::react::JSCNativeModules::createModule+ 6701416 (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, OpaqueJSContext const*) + 292
10  UnityTest                       0x0000000103393cc8 facebook::react::JSCNativeModules::getModule+ 6700232 (OpaqueJSContext const*, OpaqueJSString*) + 188
11  UnityTest                       0x000000010338e85c OpaqueJSValue const* (*facebook::react::(anonymous namespace)::exceptionWrapMethod<&(facebook::react::JSCExecutor::getNativeModule(OpaqueJSValue*, OpaqueJSString*))>())(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)::funcWrapper::call+ 6678620 (OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**) + 104
12  JavaScriptCore                  0x0000000203350404 JSC::JSCallbackObject<JSC::JSDestructibleObject>::getOwnPropertySlot+ 574468 (JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&) + 340
13  JavaScriptCore                  0x0000000203a354f0 llint_slow_path_get_by_id + 2008
14  JavaScriptCore                  0x0000000203328928 llint_entry + 11528
15  JavaScriptCore                  0x000000020332d134 llint_entry + 29972
16  JavaScriptCore                  0x000000020332d134 llint_entry + 29972
17  JavaScriptCore                  0x000000020332d134 llint_entry + 29972
18  JavaScriptCore                  0x000000020332d134 llint_entry + 29972
19  JavaScriptCore                  0x000000020332d134 llint_entry + 29972
20  JavaScriptCore                  0x0000000203325a1c vmEntryToJavaScript + 300
21  JavaScriptCore                  0x000000020399bfe4 JSC::Interpreter::executeProgram+ 7176164 (JSC::SourceCode const&, JSC::ExecState*, JSC::JSObject*) + 9620
22  JavaScriptCore                  0x0000000203b77218 JSC::evaluate+ 9122328 (JSC::ExecState*, JSC::SourceCode const&, JSC::JSValue, WTF::NakedPtr<JSC::Exception>&) + 316
23  JavaScriptCore                  0x000000020334e634 JSEvaluateScript + 472
24  UnityTest                       0x000000010336dad0 facebook::react::evaluateScript+ 6544080 (OpaqueJSContext const*, OpaqueJSString*, OpaqueJSString*) + 80
25  UnityTest                       0x000000010338c918 facebook::react::JSCExecutor::loadApplicationScript+ 6670616 (std::__1::unique_ptr<facebook::react::JSBigString const, std::__1::default_delete<facebook::react::JSBigString const> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 528
26  UnityTest                       0x0000000103392ba4 std::__1::__function::__func<facebook::react::NativeToJsBridge::loadApplication(std::__1::unique_ptr<facebook::react::RAMBundleRegistry, std::__1::default_delete<facebook::react::RAMBundleRegistry> >, std::__1::unique_ptr<facebook::react::JSBigString const, std::__1::default_delete<facebook::react::JSBigString const> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0, std::__1::allocator<facebook::react::NativeToJsBridge::loadApplication(std::__1::unique_ptr<facebook::react::RAMBundleRegistry, std::__1::default_delete<facebook::react::RAMBundleRegistry> >, std::__1::unique_ptr<facebook::react::JSBigString const, std::__1::default_delete<facebook::react::JSBigString const> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0>, void (facebook::react::JSExecutor*)>::operator()+ 6695844 (facebook::react::JSExecutor*&&) + 144
27  UnityTest                       0x0000000103393ba8 std::__1::function<void (facebook::react::JSExecutor*)>::operator()+ 6699944 (facebook::react::JSExecutor*) const + 40
28  UnityTest                       0x000000010330c9cc facebook::react::tryAndReturnError(std::__1::function<void + 6146508 ()> const&) + 24
29  UnityTest                       0x0000000103302528 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void + 6104360 ()> const&) + 24
30  CoreFoundation                  0x00000001fbfb6408 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
31  CoreFoundation                  0x00000001fbfb5d08 __CFRunLoopDoBlocks + 272
32  CoreFoundation                  0x00000001fbfb1220 __CFRunLoopRun + 2376
33  CoreFoundation                  0x00000001fbfb05b8 CFRunLoopRunSpecific + 436
34  UnityTest                       0x00000001032e36a4 +[RCTCxxBridge runRunLoop] + 264
35  Foundation                      0x00000001fcad73b0 __NSThread__start__ + 1040
36  libsystem_pthread.dylib         0x00000001fbc412fc _pthread_body + 128
37  libsystem_pthread.dylib         0x00000001fbc4125c _pthread_start + 48
38  libsystem_pthread.dylib         0x00000001fbc44d08 thread_start + 4
alisherakb commented 5 years ago

@alisherakb I was only able to build after downgrading to an older version of Unity 2018.1f2.

However, my initial version of Unity was v2018.3.13 when I encountered the error. react-native-unity-view: v1.3.3

I also made changes to the library's xcconfig file

In my case downgrading react-native-unity-view to 1.2.1 solved the issue. The error was occurring because of the UnityNativeModule.h that appeared in newer versions.

psyrenpark commented 5 years ago

same isuue. I solved it in the following way.

"Undefined symbols for architecture arm64: _OBJCCLASS$_AVPlayerViewController" -> 1: Visit Build phases 2: Add AVKit.framework

Unable to use '@try' with Objective-C exceptions disabled -> 1: Project Navigator -> select project or target -> build settings -> Enable Objective-C Exceptions https://stackoverflow.com/questions/11855382/how-to-enable-objective-c-exceptions-on-xcode-4-2

react-native info

info React Native Environment Info: System: OS: macOS 10.14.5 CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz Memory: 1.06 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 11.14.0 - /usr/local/Cellar/node/11.14.0/bin/node Yarn: 1.15.2 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 IDEs: Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.5 => 0.59.5 npmGlobalPackages: create-react-native-app: 2.0.2 react-native-cli: 2.0.1

techistoner commented 5 years ago

We also have the same issue at iphone XS MAX in ios 12.1.4 also ,still crashed, any idea?

yes i have the same issue at xs max and ipad pro

techistoner commented 5 years ago

I had problems with iOS Ad-Hoc / App Store Builds too. The app crashed immediately without any useful logs. Setting some compiler flags in XCode worked for me. You could give it a try.

ios/rnunitydemo.xcodeproj/project.pbxproj

COPY_PHASE_STRIP = YES;
ENABLE_BITCODE = NO;
STRIP_INSTALLED_PRODUCT = NO;

i have try it ,but still crash in xs max & ipad pro ,but no crash in iphone x & iphone 8plus

techistoner commented 5 years ago

Thread 6 name: com.facebook.react.JavaScript Thread 6 Crashed: 0 libsystem_kernel.dylib 0x0000000202b540cc pthread_kill + 8 1 libsystem_c.dylib 0x0000000202aad14c abort + 144 2 libsystem_malloc.dylib 0x0000000202ba8c84 _malloc_put + 0 3 libsystem_malloc.dylib 0x0000000202ba8e4c malloc_report + 64 4 libsystem_malloc.dylib 0x0000000202b9a520 free + 432 5 libc++.1.dylib 0x000000020219559c std::1::basic_string<char, std::1::char_traits, std::__1::allocator >::~basic_string+ 267676 () + 36 6 hiuni 0x0000000104aa0a64 std::1::vector_base<std::__1::basic_string<char, std::1::char_traits, std::1::allocator >, std::1::allocator<std::1::basic_string<char, std::__1::char_traits, std::1::allocator > > >::~vector_base() + 1411684 (vector:451) 7 hiuni 0x0000000105341f20 facebook::react::ModuleRegistry::getConfig+ 10460960 (std::__1::basic_string<char, std::1::char_traits, std::1::allocator > const&) + 100 8 hiuni 0x00000001053503c0 facebook::react::JSCNativeModules::createModule+ 10519488 (std::1::basic_string<char, std::1::char_traits, std::__1::allocator > const&, OpaqueJSContext const) + 268 9 hiuni 0x000000010534fff4 facebook::react::JSCNativeModules::getModule+ 10518516 (OpaqueJSContext const, OpaqueJSString) + 184 10 hiuni 0x000000010534ae34 OpaqueJSValue const (facebook::react::(anonymous namespace)::exceptionWrapMethod<&(facebook::react::JSCExecutor::getNativeModule(OpaqueJSValue, OpaqueJSString))>())(OpaqueJSContext const, OpaqueJSValue, OpaqueJSString, OpaqueJSValue const*)::funcWrapper::call+ 10497588 (OpaqueJSContext const, OpaqueJSValue, OpaqueJSString, OpaqueJSValue const*) + 104 11 JavaScriptCore 0x000000020a45f69c JSC::JSCallbackObject::getOwnPropertySlot+ 2586268 (JSC::JSObject, JSC::ExecState, JSC::PropertyName, JSC::PropertySlot&) + 344 12 JavaScriptCore 0x000000020aa45fe4 llint_slow_path_get_by_id + 3984 13 JavaScriptCore 0x000000020a42ade4 llint_entry + 31844 14 JavaScriptCore 0x000000020a438838 llint_entry + 87736 15 JavaScriptCore 0x000000020a438838 llint_entry + 87736 16 JavaScriptCore 0x000000020a438838 llint_entry + 87736 17 JavaScriptCore 0x000000020a438838 llint_entry + 87736 18 JavaScriptCore 0x000000020a438a30 llint_entry + 88240 19 JavaScriptCore 0x000000020a422ef4 vmEntryToJavaScript + 276 20 JavaScriptCore 0x000000020a9735b0 JSC::Interpreter::executeProgram+ 7910832 (JSC::SourceCode const&, JSC::ExecState, JSC::JSObject) + 11056 21 JavaScriptCore 0x000000020ab9c67c JSC::evaluate+ 10176124 (JSC::ExecState, JSC::SourceCode const&, JSC::JSValue, WTF::NakedPtr&) + 328 22 JavaScriptCore 0x000000020a45d560 JSEvaluateScript + 636 23 appName 0x000000010532b274 facebook::react::evaluateScript+ 10367604 (OpaqueJSContext const, OpaqueJSString, OpaqueJSString*) + 80 24 appName 0x0000000105348f48 facebook::react::JSCExecutor::loadApplicationScript+ 10489672 (std::1::unique_ptr<facebook::react::JSBigString const, std::1::default_delete >, std::__1::basic_string<char, std::1::char_traits, std::1::allocator >) + 512 25 appName 0x000000010534ef6c std::1::function::func<facebook::react::NativeToJsBridge::loadApplication(std::1::unique_ptr<facebook::react::RAMBundleRegistry, std::__1::default_delete >, std::1::unique_ptr<facebook::react::JSBigString const, std::1::default_delete >, std::__1::basic_string<char, std::1::char_traits, std::1::allocator >)::$_0, std::1::allocator<facebook::react::NativeToJsBridge::loadApplication(std::1::unique_ptr<facebook::react::RAMBundleRegistry, std::1::default_delete >, std::1::unique_ptr<facebook::react::JSBigString const, std::__1::default_delete >, std::1::basic_string<char, std::1::char_traits, std::__1::allocator >)::$_0>, void (facebook::react::JSExecutor)>::operator()+ 10514284 (facebook::react::JSExecutor&&) + 144 26 appName 0x000000010534fe14 std::1::function::func<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::1::function<void (facebook::react::JSExecutor)>)::$_7, std::1::allocator<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::1::function<void (facebook::react::JSExecutor)>)::$_7>, void ()>::operator()+ 10518036 () + 60 27 appName 0x00000001052cc860 facebook::react::tryAndReturnError(std::1::function<void + 9980000 ()> const&) + 40 28 appName 0x00000001052c2e98 facebook::react::RCTMessageThread::tryFunc(std::1::function<void + 9940632 ()> const&) + 24 29 CoreFoundation 0x0000000202f5127c CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 28 30 CoreFoundation 0x0000000202f50b64 CFRunLoopDoBlocks + 276 31 CoreFoundation 0x0000000202f4be58 CFRunLoopRun + 2276 32 CoreFoundation 0x0000000202f4b254 CFRunLoopRunSpecific + 452 33 appName 0x00000001052a4cd4 +[RCTCxxBridge runRunLoop] + 264 34 Foundation 0x0000000203929c4c -[NSThread main] + 72 35 Foundation 0x0000000203a5fe54 NSThreadstart + 988 36 libsystem_pthread.dylib 0x0000000202bc9908 _pthread_body + 132 37 libsystem_pthread.dylib 0x0000000202bc9864 _pthread_start + 48 38 libsystem_pthread.dylib 0x0000000202bd1dcc thread_start + 4

techistoner commented 5 years ago

finally , i find the solution. http://peterfei.me/2019/04/10/%E8%AE%B0IOS%E5%BC%80%E5%8F%91%E4%B9%8B%E6%88%91%E6%98%AF%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3react-native-unity-view%E6%8F%92%E4%BB%B6%E5%9C%A8Product%E6%A8%A1%E5%BC%8F%E9%97%AA%E9%80%80Bug/

alisherakb commented 5 years ago

@JanOwiesniak Hi, have you managed it work with Unity 2018.3.+? I'm experiencing the same issue

Screenshot 2019-08-07 at 5 28 12 PM