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

We've surfed all the web and tried so many solutions. This finally worked for us! Try to remove Up Arrows from all dependencies, i.e package.json. As an example: "react-native-unity-view": "^1.2.1" to: "react-native-unity-view": "1.2.1"

mtostenson commented 5 years ago

@alisherakb Interesting, so that fixed your release builds? I gave it a shot but it did not seem to change anything.

alisherakb commented 5 years ago

@mtostenson Yes, it solved the issue. Whenever we archive and install .ipa app it was crashing.

alisherakb commented 5 years ago

@alisherakb Interesting, so that fixed your release builds? I gave it a shot but it did not seem to change anything.

Have you tried to archive .ipa file directly from XCode without Fastlane?

mtostenson commented 5 years ago

@alisherakb Yes, that is how I tested the empty test project, archived into IPA. May I ask what versions of React Native, Unity, Node, and this library are you using?

alisherakb commented 5 years ago

@alisherakb Yes, that is how I tested the empty test project, archived into IPA. May I ask what versions of React Native, Unity, Node, and this library are you using?

Sure. RN: 0.57.3 Unity: 2018.1.3f1 Node: v8.15 RN unity view: 1.2.1

P.S. This issue was reproduced and fixed by following above-mentioned solution on Node v10.14.2

mtostenson commented 5 years ago

Thank you for the help. I'm still not able to get an IPA that doesn't crash. Have you tried using the current version of RN unity view?

alisherakb commented 5 years ago

Thank you for the help. I'm still not able to get an IPA that doesn't crash. Have you tried using the current version of RN unity view?

No. Have you tried to downgrade? Do you generate main.jsbundle correctly and edit AppDelegate.m to use it in release mode before archiving the project?

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

Also, try to set Optimization level in Build Settings to None.

JanOwiesniak 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;
mtostenson commented 5 years ago

@JanOwiesniak I think you solved it. Thank you, I've been trying to fix this for quite a while.

mtostenson commented 5 years ago

This may point to an underlying issue. @f111fei do you have any idea why this library would require setting "Strip Linked Product" to NO in order to avoid this crash? As far as I understand, all this does is removes the debug symbols from the app.

mtostenson commented 5 years ago

@JanOwiesniak We found the problem has reappeared in iOS 12.1 even with the workaround. Is your app working on this version?

richardlinxj commented 5 years ago

@mtostenson Have you solved in iOS12.1.4 ?I have the same issue at iphone XS MAX in ios 12.1.4. "Strip Linked Product" to NO, still crashed.

peterfei commented 5 years ago

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

mtostenson commented 5 years ago

@richardlinxj @peterfei I was able to narrow down where the crash happens in the React Native c++ code. Here's the issue on the React Native Repo. I included a description of how to avoid the crash. In short, you need to hold a reference to the vector that is returned from ModuleRegistry::moduleNames, I just added it as a field in the ModuleRegistry class and that seemed to work. Please join in on the discussion over there.

peterfei commented 5 years ago

@mtostenson Thanks for reply , could u give me more information for it ,or some code for

just added it as a field in the ModuleRegistry class

mtostenson commented 5 years ago

@mtostenson Thanks for reply , could u give me more information for it ,or some code for

just added it as a field in the ModuleRegistry class

Sure. Add this to ModuleRegistry.h under private:: std::vector<std::string> moduleNamesVec_;

Then in ModuleRegistry.cpp in the getConfig function, change the line moduleNames(); into moduleNamesVec_ = moduleNames();

peterfei commented 5 years ago

@mtostenson okay,let me try ~ thank u for a million.

mtostenson commented 5 years ago

@mtostenson okay,let me try ~ thank u for a million.

No problem, please let me know if this does anything.

JanOwiesniak commented 5 years ago

@JanOwiesniak We found the problem has reappeared in iOS 12.1 even with the workaround. Is your app working on this version?

@mtostenson this workaround worked quite well until iPhone XS Max iOS 12.1.4


@mtostenson thanks for the approach, i will give it a try.

JanOwiesniak commented 5 years ago

@mtostenson i changed following lines in react native (is this correct?)

screen shot 2019-02-19 at 12 00 30

These are crash logs without the above patch. For whatever reasons i don't receive crashlogs anymore. App still does not boot on iPhone XS.

Crashlog A

Crashed: com.facebook.react.JavaScript
0  ???                            0x238e390e4 (Missing)
1  ???                            0x238eb1afc (Missing)
2  ???                            0x63240238d8ffb0 (Missing)
3  ???                            0x66ca8238e8ec7c (Missing)
4  ???                            0x67bb8238e8ee48 (Missing)
5  ???                            0x7d8a8238e802c0 (Missing)
6  ???                            0xfa0238471980 (Missing)
7  ???                            0x4e858102c9f168 (Missing)
8  rnunitydemo                    0x1039d8844 facebook::react::ModuleRegistry::getConfig(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
9  rnunitydemo                    0x1039e70d4 facebook::react::JSCNativeModules::createModule(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, OpaqueJSContext const*)
10 rnunitydemo                    0x1039e6c34 facebook::react::JSCNativeModules::getModule(OpaqueJSContext const*, OpaqueJSString*)
11 rnunitydemo                    0x1039e1840 OpaqueJSValue const* (*facebook::react::(anonymous namespace)::exceptionWrapMethod<&(facebook::react::JSCExecutor::getNativeModule(OpaqueJSValue*, OpaqueJSString*))>())(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)::funcWrapper::call(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)
12 ???                            0x24074083c (Missing)
13 ???                            0x71618240e5ec24 (Missing)
14 ???                            0x210a8240716554 (Missing)
15 ???                            0x7dcf824071b39c (Missing)
16 ???                            0x7503824071b39c (Missing)
17 ???                            0x6047024071b39c (Missing)
18 ???                            0x979024071b39c (Missing)
19 ???                            0x14da824071b39c (Missing)
20 ???                            0x5171024071339c (Missing)
21 ???                            0x4d60240db4cc4 (Missing)
22 ???                            0x5f6b0240fa7ad0 (Missing)
23 ???                            0x885824073e73c (Missing)
24 ???                            0x781801039c1538 (Missing)
25 rnunitydemo                    0x1039df8fc facebook::react::JSCExecutor::loadApplicationScript(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> >)
26 rnunitydemo                    0x1039e5b70 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()(facebook::react::JSExecutor*&&)
27 rnunitydemo                    0x1037ad298 std::__1::function<void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*) const (functional:1913)
28 rnunitydemo                    0x1039607bc facebook::react::tryAndReturnError(std::__1::function<void ()> const&)
29 rnunitydemo                    0x103956400 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&)
30 ???                            0x23923c354 (Missing)
31 ???                            0x1fa1823923bc38 (Missing)
32 ???                            0x185b0239236f14 (Missing)
33 ???                            0x4ea202392362e8 (Missing)
34 ???                            0x2b3e81039376c4 (Missing)
35 ???                            0x239c38fc0 (Missing)
36 ???                            0x4a270239d75c44 (Missing)
37 ???                            0x4cfb8238eb0974 (Missing)
38 ???                            0x591f8238eb08d0 (Missing)
39 ???                            0x3ffc0238eb8ddc (Missing)

Crashlog B

Crashed: com.facebook.react.JavaScript
0  ???                            0x238e390e4 (Missing)
1  ???                            0x238eb1afc (Missing)
2  ???                            0x10d78238d8ffb0 (Missing)
3  ???                            0x68b58238e8ec7c (Missing)
4  ???                            0x15cb8238e8ee48 (Missing)
5  ???                            0x43980238e802c0 (Missing)
6  ???                            0x79468238471980 (Missing)
7  ???                            0x6426810307f168 (Missing)
8  rnunitydemo                    0x103db8844 facebook::react::ModuleRegistry::getConfig(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
9  rnunitydemo                    0x103dc70d4 facebook::react::JSCNativeModules::createModule(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, OpaqueJSContext const*)
10 rnunitydemo                    0x103dc6c34 facebook::react::JSCNativeModules::getModule(OpaqueJSContext const*, OpaqueJSString*)
11 rnunitydemo                    0x103dc1840 OpaqueJSValue const* (*facebook::react::(anonymous namespace)::exceptionWrapMethod<&(facebook::react::JSCExecutor::getNativeModule(OpaqueJSValue*, OpaqueJSString*))>())(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)::funcWrapper::call(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)
12 JavaScriptCore                 0x24074083c JSC::JSCallbackObject<JSC::JSDestructibleObject>::getOwnPropertySlot(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&)
13 ???                            0x300c8240e5ec24 (Missing)
14 ???                            0x30c60240716554 (Missing)
15 ???                            0x57a7024071b39c (Missing)
16 ???                            0xa82024071b39c (Missing)
17 ???                            0x29c2824071b39c (Missing)
18 ???                            0x7aae024071b39c (Missing)
19 ???                            0xa7824071b39c (Missing)
20 ???                            0x78f9824071339c (Missing)
21 ???                            0x5cf18240db4cc4 (Missing)
22 ???                            0x43e80240fa7ad0 (Missing)
23 ???                            0x331e824073e73c (Missing)
24 ???                            0x38fa0103da1538 (Missing)
25 rnunitydemo                    0x103dbf8fc facebook::react::JSCExecutor::loadApplicationScript(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> >)
26 rnunitydemo                    0x103dc5b70 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()(facebook::react::JSExecutor*&&)
27 rnunitydemo                    0x103b8d298 std::__1::function<void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*) const (functional:1913)
28 rnunitydemo                    0x103d407bc facebook::react::tryAndReturnError(std::__1::function<void ()> const&)
29 rnunitydemo                    0x103d36400 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&)
30 CoreFoundation                 0x23923c354 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
31 ???                            0xc7823923bc38 (Missing)
32 ???                            0x1ca18239236f14 (Missing)
33 ???                            0x63302392362e8 (Missing)
34 ???                            0x3a590103d176c4 (Missing)
35 Foundation                     0x239c38fc0 -[NSThread main]
36 ???                            0x14e88239d75c44 (Missing)
37 ???                            0x37000238eb0974 (Missing)
38 ???                            0x11100238eb08d0 (Missing)
39 ???                            0x4a400238eb8ddc (Missing)

Has anyone any idea what's the issue here and how to solve it? We are already using this in production so this discovery is really painful for us right now :(

mtostenson commented 5 years ago

@mtostenson i changed following lines in react native (is this correct?)

screen shot 2019-02-19 at 12 00 30

These are crash logs without the above patch. For whatever reasons i don't receive crashlogs anymore. App still does not boot on iPhone XS.

Crashlog A

Crashed: com.facebook.react.JavaScript
0  ???                            0x238e390e4 (Missing)
1  ???                            0x238eb1afc (Missing)
2  ???                            0x63240238d8ffb0 (Missing)
3  ???                            0x66ca8238e8ec7c (Missing)
4  ???                            0x67bb8238e8ee48 (Missing)
5  ???                            0x7d8a8238e802c0 (Missing)
6  ???                            0xfa0238471980 (Missing)
7  ???                            0x4e858102c9f168 (Missing)
8  rnunitydemo                    0x1039d8844 facebook::react::ModuleRegistry::getConfig(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
9  rnunitydemo                    0x1039e70d4 facebook::react::JSCNativeModules::createModule(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, OpaqueJSContext const*)
10 rnunitydemo                    0x1039e6c34 facebook::react::JSCNativeModules::getModule(OpaqueJSContext const*, OpaqueJSString*)
11 rnunitydemo                    0x1039e1840 OpaqueJSValue const* (*facebook::react::(anonymous namespace)::exceptionWrapMethod<&(facebook::react::JSCExecutor::getNativeModule(OpaqueJSValue*, OpaqueJSString*))>())(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)::funcWrapper::call(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)
12 ???                            0x24074083c (Missing)
13 ???                            0x71618240e5ec24 (Missing)
14 ???                            0x210a8240716554 (Missing)
15 ???                            0x7dcf824071b39c (Missing)
16 ???                            0x7503824071b39c (Missing)
17 ???                            0x6047024071b39c (Missing)
18 ???                            0x979024071b39c (Missing)
19 ???                            0x14da824071b39c (Missing)
20 ???                            0x5171024071339c (Missing)
21 ???                            0x4d60240db4cc4 (Missing)
22 ???                            0x5f6b0240fa7ad0 (Missing)
23 ???                            0x885824073e73c (Missing)
24 ???                            0x781801039c1538 (Missing)
25 rnunitydemo                    0x1039df8fc facebook::react::JSCExecutor::loadApplicationScript(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> >)
26 rnunitydemo                    0x1039e5b70 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()(facebook::react::JSExecutor*&&)
27 rnunitydemo                    0x1037ad298 std::__1::function<void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*) const (functional:1913)
28 rnunitydemo                    0x1039607bc facebook::react::tryAndReturnError(std::__1::function<void ()> const&)
29 rnunitydemo                    0x103956400 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&)
30 ???                            0x23923c354 (Missing)
31 ???                            0x1fa1823923bc38 (Missing)
32 ???                            0x185b0239236f14 (Missing)
33 ???                            0x4ea202392362e8 (Missing)
34 ???                            0x2b3e81039376c4 (Missing)
35 ???                            0x239c38fc0 (Missing)
36 ???                            0x4a270239d75c44 (Missing)
37 ???                            0x4cfb8238eb0974 (Missing)
38 ???                            0x591f8238eb08d0 (Missing)
39 ???                            0x3ffc0238eb8ddc (Missing)

Crashlog B

Crashed: com.facebook.react.JavaScript
0  ???                            0x238e390e4 (Missing)
1  ???                            0x238eb1afc (Missing)
2  ???                            0x10d78238d8ffb0 (Missing)
3  ???                            0x68b58238e8ec7c (Missing)
4  ???                            0x15cb8238e8ee48 (Missing)
5  ???                            0x43980238e802c0 (Missing)
6  ???                            0x79468238471980 (Missing)
7  ???                            0x6426810307f168 (Missing)
8  rnunitydemo                    0x103db8844 facebook::react::ModuleRegistry::getConfig(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
9  rnunitydemo                    0x103dc70d4 facebook::react::JSCNativeModules::createModule(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, OpaqueJSContext const*)
10 rnunitydemo                    0x103dc6c34 facebook::react::JSCNativeModules::getModule(OpaqueJSContext const*, OpaqueJSString*)
11 rnunitydemo                    0x103dc1840 OpaqueJSValue const* (*facebook::react::(anonymous namespace)::exceptionWrapMethod<&(facebook::react::JSCExecutor::getNativeModule(OpaqueJSValue*, OpaqueJSString*))>())(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)::funcWrapper::call(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSString*, OpaqueJSValue const**)
12 JavaScriptCore                 0x24074083c JSC::JSCallbackObject<JSC::JSDestructibleObject>::getOwnPropertySlot(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&)
13 ???                            0x300c8240e5ec24 (Missing)
14 ???                            0x30c60240716554 (Missing)
15 ???                            0x57a7024071b39c (Missing)
16 ???                            0xa82024071b39c (Missing)
17 ???                            0x29c2824071b39c (Missing)
18 ???                            0x7aae024071b39c (Missing)
19 ???                            0xa7824071b39c (Missing)
20 ???                            0x78f9824071339c (Missing)
21 ???                            0x5cf18240db4cc4 (Missing)
22 ???                            0x43e80240fa7ad0 (Missing)
23 ???                            0x331e824073e73c (Missing)
24 ???                            0x38fa0103da1538 (Missing)
25 rnunitydemo                    0x103dbf8fc facebook::react::JSCExecutor::loadApplicationScript(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> >)
26 rnunitydemo                    0x103dc5b70 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()(facebook::react::JSExecutor*&&)
27 rnunitydemo                    0x103b8d298 std::__1::function<void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*) const (functional:1913)
28 rnunitydemo                    0x103d407bc facebook::react::tryAndReturnError(std::__1::function<void ()> const&)
29 rnunitydemo                    0x103d36400 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&)
30 CoreFoundation                 0x23923c354 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
31 ???                            0xc7823923bc38 (Missing)
32 ???                            0x1ca18239236f14 (Missing)
33 ???                            0x63302392362e8 (Missing)
34 ???                            0x3a590103d176c4 (Missing)
35 Foundation                     0x239c38fc0 -[NSThread main]
36 ???                            0x14e88239d75c44 (Missing)
37 ???                            0x37000238eb0974 (Missing)
38 ???                            0x11100238eb08d0 (Missing)
39 ???                            0x4a400238eb8ddc (Missing)

Has anyone any idea what's the issue here and how to solve it? We are already using this in production so this discovery is really painful for us right now :(

I feel your pain on that, our releases have been blocked as well. Your hot fix looks correct, I'm surprised it didn't have the same result for you. I have another suggestion for you, it's not pretty but it can be effective. Looking at your crash log, we should focus on ModuleRegistry::GetConfig. Try putting in a logging line after each statement in that function to find the exact line that result in the crash. Example: syslog(LOG_ERR, "TESTING: ModuleRegistry::getConfig 1"); and increment the number at the end with each line. This is how I was able to find our "fix." Just open up the device console and filter on TESTING when you run the production build. I hope this helps.

JanOwiesniak commented 5 years ago

@mtostenson thanks for the debugging approach. Sadly i can't run the app on a simulator because we are using a 3rd party library which can not run on the simulator:

Vuforia Engine applications must be deployed to a device to run; they cannot be run in the iOS simulator. You must enroll in the iOS Developer program to deploy applications to an iOS device.

And i don't have access to this particular device in any physical way. Do you have any other idea how to pin that bug down without access to a physical device or the simulator :)

"puts debugging" would mean:

  1. Add debug statement
  2. Archive App via XCode
  3. Upload to Apple App Store Connect (wait ~ 10 minutes until app is "processed")
  4. Deploy App via TestFlight
  5. Call someone who has a iPhone XS, tell him to download the new build via TestFlight and start it
  6. Hope Crashlytics catches the exception (which it does not for whatever reasons in some cases)
  7. Go back to step 1
JanOwiesniak commented 5 years ago

Sidenote

I just stumbled across Firebase Test Lab and will give it a try. I seems to remove a lot of time consuming steps mentioned earlier.

JanOwiesniak commented 5 years ago

Update

Firebase Test Lab does not include XS or XR models 🤦‍♂️

test-lab

peterfei commented 5 years ago

@mtostenson @JanOwiesniak now i could run it under iPhone XS Max iOS 12.1.4,which use react-native patch yesterday.

JanOwiesniak commented 5 years ago

@peterfei which of these commits include the fix?

peterfei commented 5 years ago

not found commits from issues, but u reply here like this:

JanOwiesniak commented 5 years ago

This works for you? Could you tell me a bit more about your dependencies?

react-native info and current react-native-unity-view would be a great help

daijiangping commented 5 years ago

hello!

Lance-Mao commented 5 years ago

Onlookers !!!

peterfei commented 5 years ago

Sure,

SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 23, 25, 26, 27
        Build Tools: 23.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.2, 27.0.3
    IDEs:
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.0 => 0.57.0
    npmGlobalPackages:
      react-native-unity-view: 1.3.3
      react-native-video: 4.3.1
JanOwiesniak commented 5 years ago

react-native info

  React Native Environment Info:
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        Build Tools: 23.0.1, 26.0.2, 27.0.1, 27.0.3, 28.0.1, 28.0.3
        API Levels: 21, 23, 24, 25, 26, 27, 28
    IDEs:
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.0 => 0.57.0

package.json

"react-native-unity-view": "^1.3.2"


I'm still on react-native-unity-view v1.3.2, everything else looks pretty much the same. The only difference between 1.3.2 and 1.3.3 seems to be this android related commit so i guess this is not the issue here.

peterfei commented 5 years ago

Strange,i'm sure only change the code by this patch......

JanOwiesniak commented 5 years ago

I just received a fresh crash report from Crashlytics. This one look different to me than the previous crashes. Am i still hunting the same bug here or is this something new? I'm a bit lost here right now. Any feedback highly appreciated.

crash_info_entry_0

abort() called

crash_info_entry_1

rnunitydemo(7356,0x16b713000) malloc: *** error for object 0x10d82c460: pointer being freed was not allocated

stacktrace

iOS: 12.1.4 (16D57) Device: iPhone XS

Crashed: com.google.firebase.firestore
0  libsystem_kernel.dylib         0x238e390e4 __pthread_kill + 8
1  libsystem_pthread.dylib        0x238eb1afc pthread_kill + 300
2  ???                            0x4aaf0238d8ffb0 (Missing)
3  ???                            0x60cd8238e8ec7c (Missing)
4  ???                            0x9bd8238e8ee48 (Missing)
5  ???                            0x2b690238e802c0 (Missing)
6  ???                            0x5839823847208c (Missing)
7  ???                            0x37828105696b40 (Missing)
8  rnunitydemo                    0x105696d2c firebase::firestore::local::LevelDbTransaction::Iterator::Seek(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (leveldb_transaction.cc:83)
9  rnunitydemo                    0x105634c38 -[FSTLevelDBMutationQueue allMutationBatchesAffectingDocumentKeys:] (memory:2567)
10 rnunitydemo                    0x10563d360 -[FSTLocalDocumentsView documentsForKeys:] (FSTLocalDocumentsView.mm:84)
11 rnunitydemo                    0x105642a2c -[FSTLocalStore applyRemoteEvent:] (FSTLocalStore.mm:307)
12 rnunitydemo                    0x105678020 -[FSTSyncEngine applyRemoteEvent:] (FSTSyncEngine.mm:352)
13 rnunitydemo                    0x1056693a8 -[FSTRemoteStore raiseWatchSnapshotWithSnapshotVersion:] (FSTRemoteStore.mm:416)
14 rnunitydemo                    0x105668cb0 -[FSTRemoteStore watchStreamDidChange:snapshotVersion:] (FSTRemoteStore.mm:333)
15 rnunitydemo                    0x10569c3d4 firebase::firestore::remote::bridge::WatchStreamDelegate::NotifyDelegateOnChange(FSTWatchChange*, firebase::firestore::model::SnapshotVersion const&) (remote_objc_bridge.mm:306)
16 rnunitydemo                    0x1056a42d8 firebase::firestore::remote::WatchStream::NotifyStreamResponse(grpc::ByteBuffer const&) (watch_stream.mm:93)
17 rnunitydemo                    0x1056a015c firebase::firestore::remote::Stream::OnStreamRead(grpc::ByteBuffer const&) (memory:2583)
18 rnunitydemo                    0x105691238 std::__1::function<void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*) const (functional:1913)
19 rnunitydemo                    0x10568bbdc std::__1::function<void (bool, firebase::firestore::remote::GrpcCompletion const*)>::operator()(bool, firebase::firestore::remote::GrpcCompletion const*) const (functional:1913)
20 rnunitydemo                    0x10568bac8 std::__1::__function::__func<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0, std::__1::allocator<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0>, void ()>::operator()() (grpc_completion.cc:69)
21 rnunitydemo                    0x1055f9118 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) (atomic:921)
22 rnunitydemo                    0x10560014c firebase::firestore::util::internal::DispatchAsync(NSObject<OS_dispatch_queue>*, std::__1::function<void ()>&&)::$_0::__invoke(void*) (executor_libdispatch.mm:58)
23 libdispatch.dylib              0x238cb1134 _dispatch_client_callout + 20
24 ???                            0x75640238cb864c (Missing)
25 ???                            0x43e78238cb9194 (Missing)
26 ???                            0x1a6a8238cc1480 (Missing)
27 ???                            0x71b98238eb2b20 (Missing)
28 ???                            0x2358238eb8dd4 (Missing)
JanOwiesniak commented 5 years ago

@peterfei @mtostenson three more questions which might help me to get closer to the problem:

  1. Are you using XCodes new build system or the legacy build system? (i'm using the old build system)
  2. Are you on macOS High Sierra or macOS Mojave? (i'm on High Sierra)
  3. Which Unity Version you are using? (me: 2018.2.14f1)
peterfei commented 5 years ago

@JanOwiesniak

  1. i used the legacy build system
  2. On maxOS High Sierra.
  3. Unity version was 2017.2.0f3
mtostenson commented 5 years ago

@JanOwiesniak

  1. Legacy build system
  2. High Sierra
  3. 2018.2.1f1 before, but today after I updating to 2018.3.6f1 I am no longer getting a crash on start. This might be a seperate issue to the one I was describing before, but I would suggest trying to this version along with 1.3.3 of this library. You'll probably run into a couple of issues: SplashScreen.mm you'll need to change #include "Classes/Unity/UnitySharedDecls.h" to #include "Unity/UnitySharedDecls.h" You'll also need to remove references to DynamicLibEngineAPI-functions.h and DynamicLibEngineAPI.mm. More about that issue here. If this helps you too I'll probably open a PR to fix those issues and add support for this Unity version.
JanOwiesniak commented 5 years ago

@peterfei @mtostenson thanks for your help.

I will update react-native-unity-view to 1.3.3. and Unity to 2018.3.6. Let's see if this fixes the issue. @mtostenson special thanks for the hotfixes for upcoming issue i will run into :)

peterfei commented 5 years ago

@mtostenson when i used Unity to 2018.3.6, show some error like


: "_OBJC_CLASS_$_AVPlayerViewController", referenced from:

: Objc-class-ref in FullScreenVideoPlayer.o

: Symbol(s) not found for architecture arm64

: Linker command failed with exit code 1 (use -v to see invocation)

any idea?

peterfei commented 5 years ago

Mine fault,should add AVKit.framework ....

JanOwiesniak commented 5 years ago

This is how i fixed it (in a nutshell)

  1. Remove node_modules
  2. Reinstall node_modues via yarn
  3. Update Unity from 2018.2.14f1 to 2018.3.6f1
  4. Build UnityExport
  5. Patch UnityExport (https://github.com/jiulongw/swift-unity/pull/120#issuecomment-456315250, https://github.com/f111fei/react-native-unity-view/issues/79#issuecomment-465819733)
  6. Update react-native-unity-view to 1.3.3
  7. Update react-native to 0.57.8
  8. Patch react-native moduleNames() (https://github.com/f111fei/react-native-unity-view/issues/79#issuecomment-465110101)

react-native info

  React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
      Memory: 1.18 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.15.0 - /usr/local/opt/node@8/bin/node
      Yarn: 1.13.0 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/opt/node@8/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 21, 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 26.0.2, 27.0.1, 27.0.3, 28.0.1, 28.0.3
        System Images: android-21 | Google APIs ARM EABI v7a, android-26 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5199772
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.8 => 0.57.8

@peterfei @mtostenson thanks again for your support.

alisherakb commented 5 years ago

@JanOwiesniak

  1. Legacy build system
  2. High Sierra
  3. 2018.2.1f1 before, but today after I updating to 2018.3.6f1 I am no longer getting a crash on start. This might be a seperate issue to the one I was describing before, but I would suggest trying to this version along with 1.3.3 of this library. You'll probably run into a couple of issues: SplashScreen.mm you'll need to change #include "Classes/Unity/UnitySharedDecls.h" to #include "Unity/UnitySharedDecls.h" You'll also need to remove references to DynamicLibEngineAPI-functions.h and DynamicLibEngineAPI.mm. More about that issue here. If this helps you too I'll probably open a PR to fix those issues and add support for this Unity version.

@mtostenson @JanOwiesniak Hey guys, I'm following your solutions but even not able to run the project in debug:

Screenshot 2019-03-13 at 11 41 13 PM

Have you ever experienced this issue?

Unity -v: 2018.3.2 "react-native": "0.58.6"

mtostenson commented 5 years ago

Did you set up the xcconfig correctly as it shows in the integration guide? It could be that your header search paths aren't set up right.

alisherakb commented 5 years ago

Did you set up the xcconfig correctly as it shows in the integration guide? It could be that your header search paths aren't set up right.

Thanks for the reply. Actually, I changed my xcconfig a bit, followed this commit https://github.com/jiulongw/swift-unity/pull/120/commits/55826261738d7adebe011a7474eec7aa5b898adc

Otherwise, I'm getting a different error on following this library's xcconfig:

Screenshot 2019-03-13 at 11 53 46 PM

What could cause an error?

hoxily commented 5 years ago

I fixed the same crash issue by remove std::move function call around name variable in ModuleRegistry::moduleNames() function body.

hoxily commented 5 years ago

Changing names.push_back(std::move(name)); to names.push_back(name); solves the problem.

OgieBen commented 5 years ago

@alisherakb I am equally experiencing the same issue. Please, how did you fix yours?

alisherakb commented 5 years ago

@OgieBen Hi, can you provide more details about the issue? My last comments here were about the error on running Unity3D 2018.2+ and react-native-unity-view.

OgieBen 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