realm-js
realm-js copied to clipboard
Crash in Expo 44 iOS app immediately upon app launch — RealmReact.setBridge > RJSInitializeInContext > EXC_BAD_ACCESS
How frequently does the bug occur?
All the time
Description
When I open my Expo app built using eas build
and choose the Expo development server, the app crashes instantly, before the JS bundle loads from the Expo development server. This occurs on the simulator or a real iOS device.
When I do this in the simulator, it produces a .crash
log file in ~/Library/Logs/DiagnosticReports
that includes the full stacktrace (see below).
Stacktrace & log output
Here is the stacktrace from the relevant thread from the .crash
file:
Crashed Thread: 35 com.facebook.react.JavaScript
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000103898420
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Bus error: 10
Termination Reason: Namespace SIGNAL, Code 0xa
Terminating Process: exc handler [77960]
...
Thread 35 Crashed:: com.facebook.react.JavaScript
0 com.apple.JavaScriptCore 0x00007fff3331ca87 JSC::JSLockHolder::JSLockHolder(JSC::VM&) + 7
1 com.apple.JavaScriptCore 0x00007fff328f20c3 JSContextGetGlobalObject + 35
2 life.digdeep.digdeep 0x000000010427017e RJSInitializeInContext + 62
3 life.digdeep.digdeep 0x0000000103c393b9 _initializeOnJSThread(OpaqueJSContext* () block_pointer, std::__1::function<void ()>) + 473
4 life.digdeep.digdeep 0x0000000103c39b3b __24-[RealmReact setBridge:]_block_invoke + 395
5 life.digdeep.digdeep 0x000000010396715e decltype(std::__1::forward<void () block_pointer __strong&>(fp)()) std::__1::__invoke<void () block_pointer __strong&>(&&, decltype(std::__1::forward<void () block_pointer __strong&>(fp)())&&...) + 30
6 life.digdeep.digdeep 0x000000010396710d void std::__1::__invoke_void_return_wrapper<void, true>::__call<void () block_pointer __strong&>(void () block_pointer __strong&) + 29
7 life.digdeep.digdeep 0x00000001039670dd std::__1::__function::__alloc_func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() + 29
8 life.digdeep.digdeep 0x0000000103965ce9 std::__1::__function::__func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() + 25
9 life.digdeep.digdeep 0x00000001037ca462 std::__1::__function::__value_func<void ()>::operator()() const + 50
10 life.digdeep.digdeep 0x00000001037ca425 std::__1::function<void ()>::operator()() const + 21
11 life.digdeep.digdeep 0x0000000103980c25 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) + 21
12 life.digdeep.digdeep 0x000000010394cf2b -[RCTCxxBridge _tryAndHandleError:] + 91
13 com.apple.Foundation 0x00007fff20845992 __NSThreadPerformPerform + 179
14 com.apple.CoreFoundation 0x00007fff2036ce15 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15 com.apple.CoreFoundation 0x00007fff2036cd0d __CFRunLoopDoSource0 + 180
16 com.apple.CoreFoundation 0x00007fff2036c1e2 __CFRunLoopDoSources0 + 242
17 com.apple.CoreFoundation 0x00007fff20366941 __CFRunLoopRun + 875
18 com.apple.CoreFoundation 0x00007fff203660f3 CFRunLoopRunSpecific + 567
19 life.digdeep.digdeep 0x000000010394cd22 +[RCTCxxBridge runRunLoop] + 962
20 com.apple.Foundation 0x00007fff20845550 __NSThread__start__ + 1025
21 libsystem_pthread.dylib 0x00007fff6da2b8fc _pthread_start + 224
22 libsystem_pthread.dylib 0x00007fff6da27443 thread_start + 15
Here is a link to the entire .crash
file: https://gist.github.com/tsheaff/96f5ac062ffe0a7b20e39bd1f59d2450
Here is my package.json
file:
{
"name": "dig-deep",
"version": "1.0.0",
"scripts": {
"local": "expo start --dev-client",
"start": "yarn local",
"lint": "eslint . --ext .jsx --ext .js --ext .tsx --ext .ts",
"lint:strict": "yarn lint --max-warnings=0",
"lint:fix": "yarn lint --fix",
"tsc": "tsc --project tsconfig.json",
"build:local": "export $(cat .env | xargs) && eas build --profile local --platform ios",
"build:dev": "export $(cat .env | xargs) && eas build --profile development",
"build:dev:ios": "yarn build:dev --platform ios",
"build:dev:android": "yarn build:dev --platform android",
"build:prod": "export $(cat .env | xargs) && eas build"
},
"dependencies": {
"@amplitude/react-native": "^2.12.1",
"@babel/preset-typescript": "^7.18.6",
"@expo/metro-config": "^0.3.17",
"@react-native-async-storage/async-storage": "~1.15.0",
"@react-native-community/netinfo": "7.1.3",
"@stripe/stripe-react-native": "0.2.3",
"axios": "^0.27.2",
"color": "^4.2.3",
"dotenv": "^16.0.1",
"envalid": "^7.3.1",
"expo": "^44.0.0",
"expo-application": "~4.0.1",
"expo-asset": "~8.4.6",
"expo-av": "~10.2.0",
"expo-blur": "~11.0.0",
"expo-constants": "~13.0.1",
"expo-dev-client": "~0.8.6",
"expo-device": "~4.1.0",
"expo-file-system": "~13.1.4",
"expo-font": "~10.0.4",
"expo-linear-gradient": "~11.0.3",
"expo-localization": "~12.0.0",
"expo-network": "~4.1.0",
"expo-secure-store": "~11.1.0",
"expo-splash-screen": "~0.14.1",
"expo-sqlite": "~10.1.0",
"expo-status-bar": "~1.2.0",
"expo-updates": "~0.11.7",
"fp-ts": "^2.12.1",
"io-ts": "^2.2.16",
"lodash": "^4.17.21",
"luxon": "^2.4.0",
"react": "17.0.1",
"react-dom": "17.0.2",
"react-native": "0.64.3",
"react-native-get-random-values": "~1.7.0",
"react-native-logs": "^4.0.1",
"react-native-network-info": "^5.2.1",
"react-native-reanimated": "~2.3.1",
"react-native-safe-area-context": "3.3.2",
"react-native-svg": "12.1.1",
"react-native-web": "0.17.7",
"realm": "^10.19.3",
"uuid": "^8.3.2",
"yargs": "^17.5.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@types/color": "^3.0.3",
"@types/lodash": "^4.14.182",
"@types/luxon": "^2.3.2",
"@types/node": "^17.0.35",
"@types/react": "17.0.30",
"@types/react-native": "~0.66.13",
"@types/uuid": "^8.3.4",
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-react-native": "^4.0.0",
"typescript": "~4.3.5"
},
"resolutions": {
"@types/react": "17.0.30"
},
"private": true
}
Here is my eas.json
, this is for the local
profile (yarn build:local
per the package.json
):
{
"cli": {
"version": ">= 0.52.0"
},
"build": {
"local": {
"developmentClient": true,
"env": {
"LOG_LEVEL": "debug",
"NODE_ENV": "local",
"API_URL": "http://local.digdeep.life:9000"
},
"ios": {
"simulator": true
}
}
}
}
And here is the app.config.ts
file:
import 'dotenv/config';
import * as envalid from 'envalid';
const { LOG_LEVEL, NODE_ENV, API_URL } = envalid.cleanEnv(process.env, {
LOG_LEVEL: envalid.str(),
NODE_ENV: envalid.str(),
API_URL: envalid.url(),
});
export default {
expo: {
name: 'Dig Deep',
slug: 'dig-deep',
owner: 'dig-deep',
version: '2022.06.30',
orientation: 'portrait',
icon: './assets/icon.png',
userInterfaceStyle: 'light',
splash: {
image: './assets/splash.png',
resizeMode: 'contain',
backgroundColor: '#000000',
},
jsEngine: 'hermes',
updates: {
fallbackToCacheTimeout: 0,
},
assetBundlePatterns: [
'**/*',
],
ios: {
supportsTablet: true,
bundleIdentifier: 'life.digdeep.digdeep',
infoPlist: {
UIBackgroundModes: [
'audio',
],
NSMicrophoneUsageDescription: 'Record yourself for Dig Deep',
},
},
android: {
adaptiveIcon: {
foregroundImage: './assets/adaptive-icon.png',
backgroundColor: '#000000',
},
package: 'life.digdeep.digdeep',
},
plugins: [
[
'@stripe/stripe-react-native',
{
merchantIdentifier: ['merchant.life.digdeep.digdeep'],
enableGooglePay: true,
},
],
],
extra: {
LOG_LEVEL,
NODE_ENV,
API_URL,
},
},
};
### Can you reproduce the bug?
Yes, always
### Reproduction Steps
Open the app built using `eas build` and the development server running via `expo start --dev-client`
Occurs before the JS bundle even loads
### Version
10.19.3
### What SDK flavour are you using?
Local Database only
### Are you using encryption?
No, not using encryption
### Platform OS and version(s)
Expo 44.0.6, iOS 12 simulator
### Build environment
Expo
### Cocoapods version
Not sure, but I'm on eas-cli/0.52.0 and it's being built in the cloud and hosted at expo.dev website
I've confirmed that this is indeed an error with this package.
By running yarn remove realm
and commenting out just the ~20 lines of code where my app references this package, by re-running eas build
with the project otherwise identical, the app launches with no issues at all.
Not sure if there's something about my combination of Expo and realm-js, or perhaps the presence of another package I'm using that's interacting poorly with realm-js, but just removing this one package resolves it. Maybe this could be solved by changing my package versions, but I know that Expo 45 (the latest) doesn't work with RealmJS on Android per https://github.com/realm/realm-js/issues/4639 which is why I downgraded to Expo 44 to get it working.
But this is a fatal issue for me and means the whole library is unuseable. Would love to hear if anyone else has this same issue.
@tsheaff Thanks for reporting this. We will investigate.
@tsheaff The stack trace shows that it seems to crash binding Realm to the JSC engine context. I would be curious to see if what happens when using [email protected]
. In this branch we are binding in a different way. Can you see if that works?
@takameyer do you want me to try [email protected]
against Expo 45 or Expo 44?
I'm testing the latest official release [email protected]
, and [email protected]
, against Expo 45.
If either of those work I'll test that version against Expo 44, since I know Expo 45 still isn't working with Android (I'm testing on iOS)
Hey @fronck @takameyer I'm able to confirm that this bug still occurs with [email protected] and [email protected] with the exact same stack trace reported here (this initial ticket was with [email protected] and Expo 44).
However, with Expo 45.0.6 the [email protected] does not crash in this way. I haven't tried [email protected] and Expo 44 yet.
Biggest mystery is why this isn't occurring for everyone. For me it happens on the simulator and the real device every time. Based on the stack trace, the fact that upgrading just Realm fixes it, and the fact that removing just Realm fixes it, it doesn't seem like something related to an interaction with other packages. Am I the first one to report this? 🤔
OK I confirmed that this does NOT work with [email protected]
and Expo 44. The crash in that case is slightly different stack trace, but still happens immediately on app launch, before the JS bundle is even compiled:
Thread 37 Crashed:: com.facebook.react.JavaScript
0 dev.hermesengine.iphoneos 0x000000010e36a777 0x10e321000 + 300919
1 dev.hermesengine.iphoneos 0x000000010e329030 facebook::hermes::HermesRuntimeImpl::getProperty(facebook::jsi::Object const&, facebook::jsi::String const&) + 94
2 life.digdeep.digdeep 0x0000000109cb40fb facebook::jsi::RuntimeDecorator<facebook::jsi::Runtime, facebook::jsi::Runtime>::getProperty(facebook::jsi::Object const&, facebook::jsi::String const&) + 59
3 life.digdeep.digdeep 0x0000000109cb23dd facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::getProperty(facebook::jsi::Object const&, facebook::jsi::String const&) + 77
4 life.digdeep.digdeep 0x0000000109fd29f7 facebook::jsi::Object::getProperty(facebook::jsi::Runtime&, facebook::jsi::String const&) const + 55
5 life.digdeep.digdeep 0x0000000109fcd729 facebook::jsi::Object::getProperty(facebook::jsi::Runtime&, char const*) const + 89
6 life.digdeep.digdeep 0x0000000109fcceb8 facebook::jsi::Object::getPropertyAsObject(facebook::jsi::Runtime&, char const*) const + 72
7 life.digdeep.digdeep 0x0000000109fcd178 facebook::jsi::Object::getPropertyAsFunction(facebook::jsi::Runtime&, char const*) const + 72
8 life.digdeep.digdeep 0x000000010a686005 realm::js::realmjsi::ObjectWrap<realm::js::ObservableClass<realm::js::realmjsi::Types> >::create_constructor(realm::js::JsiEnv) + 469
9 life.digdeep.digdeep 0x000000010a683454 realm::js::RealmClass<realm::js::realmjsi::Types>::create_constructor(realm::js::JsiEnv) + 36
10 life.digdeep.digdeep 0x000000010a6832dd realm_jsi_init + 29
11 life.digdeep.digdeep 0x000000010a053531 __24-[RealmReact setBridge:]_block_invoke + 513
12 life.digdeep.digdeep 0x0000000109d8243e decltype(std::__1::forward<void () block_pointer __strong&>(fp)()) std::__1::__invoke<void () block_pointer __strong&>(&&, decltype(std::__1::forward<void () block_pointer __strong&>(fp)())&&...) + 30
13 life.digdeep.digdeep 0x0000000109d823ed void std::__1::__invoke_void_return_wrapper<void, true>::__call<void () block_pointer __strong&>(void () block_pointer __strong&) + 29
14 life.digdeep.digdeep 0x0000000109d823bd std::__1::__function::__alloc_func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() + 29
15 life.digdeep.digdeep 0x0000000109d80fc9 std::__1::__function::__func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() + 25
16 life.digdeep.digdeep 0x0000000109be5302 std::__1::__function::__value_func<void ()>::operator()() const + 50
17 life.digdeep.digdeep 0x0000000109be52c5 std::__1::function<void ()>::operator()() const + 21
18 life.digdeep.digdeep 0x0000000109d9bf05 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) + 21
19 life.digdeep.digdeep 0x0000000109d681eb -[RCTCxxBridge _tryAndHandleError:] + 91
20 com.apple.Foundation 0x00007fff20845992 __NSThreadPerformPerform + 179
21 com.apple.CoreFoundation 0x00007fff2036ce15 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 com.apple.CoreFoundation 0x00007fff2036cd0d __CFRunLoopDoSource0 + 180
23 com.apple.CoreFoundation 0x00007fff2036c1e2 __CFRunLoopDoSources0 + 242
24 com.apple.CoreFoundation 0x00007fff20366941 __CFRunLoopRun + 875
25 com.apple.CoreFoundation 0x00007fff203660f3 CFRunLoopRunSpecific + 567
26 life.digdeep.digdeep 0x0000000109d67fe2 +[RCTCxxBridge runRunLoop] + 962
27 com.apple.Foundation 0x00007fff20845550 __NSThread__start__ + 1025
28 libsystem_pthread.dylib 0x00007fff6da2b8fc _pthread_start + 224
29 libsystem_pthread.dylib 0x00007fff6da27443 thread_start + 15
Because Android doesn't work with Expo 45, it seems there's no solution at the moment that works on iOS and Android until https://github.com/realm/realm-js/issues/4639 is fixed? 🤔
@tsheaff any updates on this please? facing same issues on Android w Expo 44
@tsheaff Not an ideal workaround, but if you're willing to sacrifice reanimated for realm, you can disable hermes and you should no longer see this issue. It's not ideal, but may be a short term workaround.
same
@takameyer @fronck any update here? This is the stack trace I get on [email protected]
with [email protected]
and jsEngine: "hermes"
:
Thread 12 Crashed:: com.facebook.react.JavaScript
0 hermes 0x109f468a8 0x109f40000 + 26792
1 hermes 0x109f468a0 0x109f40000 + 26784
2 DigDeep 0x104d3168c facebook::jsi::RuntimeDecorator<facebook::jsi::Runtime, facebook::jsi::Runtime>::utf8(facebook::jsi::String const&) + 52
3 DigDeep 0x104d2f904 facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::utf8(facebook::jsi::String const&) + 64
4 DigDeep 0x1056daca0 facebook::jsi::Value facebook::jsi::Function::call<char const (&) [11], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(facebook::jsi::Runtime&, char const (&) [11], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) const + 96
5 DigDeep 0x1056cc184 realm::js::realmjsi::ObjectWrap<realm::js::ObservableClass<realm::js::realmjsi::Types> >::create_constructor(realm::js::JsiEnv) + 548
6 DigDeep 0x1056ca0f0 realm::js::RealmClass<realm::js::realmjsi::Types>::create_constructor(realm::js::JsiEnv) + 44
7 DigDeep 0x1056c9f2c realm_jsi_init + 184
8 DigDeep 0x104eb4eac __24-[RealmReact setBridge:]_block_invoke + 644
9 DigDeep 0x104a9378c decltype(static_cast<void () block_pointer __strong&>(fp)()) std::__1::__invoke<void () block_pointer __strong&>(&&, decltype(static_cast<void () block_pointer __strong&>(fp)())&&...) + 32
10 DigDeep 0x104a9373c void std::__1::__invoke_void_return_wrapper<void, true>::__call<void () block_pointer __strong&>(void () block_pointer __strong&) + 28
11 DigDeep 0x104a93714 std::__1::__function::__alloc_func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() + 28
12 DigDeep 0x104a9213c std::__1::__function::__func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() + 28
13 DigDeep 0x1049ea1a8 std::__1::__function::__value_func<void ()>::operator()() const + 60
14 DigDeep 0x1049ea160 std::__1::function<void ()>::operator()() const + 24
15 DigDeep 0x104aaec7c facebook::react::tryAndReturnError(std::__1::function<void ()> const&) + 24
16 DigDeep 0x104a7d514 -[RCTCxxBridge _tryAndHandleError:] + 80
17 Foundation 0x180bf2d28 __NSThreadPerformPerform + 124
18 CoreFoundation 0x180371070 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
19 CoreFoundation 0x180370fb8 __CFRunLoopDoSource0 + 172
20 CoreFoundation 0x180370728 __CFRunLoopDoSources0 + 232
21 CoreFoundation 0x18036ae68 __CFRunLoopRun + 756
22 CoreFoundation 0x18036a75c CFRunLoopRunSpecific + 584
23 DigDeep 0x104a7d35c +[RCTCxxBridge runRunLoop] + 764
24 Foundation 0x180bf29d8 __NSThread__start__ + 704
25 libsystem_pthread.dylib 0x1ae5626c8 _pthread_start + 116
26 libsystem_pthread.dylib 0x1ae55d910 thread_start + 8
Thread 12 crashed with ARM Thread State (64-bit):
x0: 0x000000016c00d3f0 x1: 0x000000016c00d3b8 x2: 0x0000000000000000 x3: 0x000000016c00d498
x4: 0x0000000000000000 x5: 0x0000000000000030 x6: 0x000000016c00d400 x7: 0x000000016c00be00
x8: 0x754665766974616e x9: 0x0000000136b8ce00 x10: 0x0000000000000004 x11: 0x0000600000ab32e8
x12: 0x0000000136700000 x13: 0x0000000000000000 x14: 0x000000007a9290fe x15: 0x00000000000023d8
x16: 0x00000001ae5572c0 x17: 0x000000000023d89a x18: 0x0000000000000000 x19: 0x000000016c00d588
x20: 0x000060000014f500 x21: 0x0000000105d7adb6 x22: 0x000000016c00d6e8 x23: 0x0000000105d7adb6
x24: 0x0000600001a90f10 x25: 0x0000000000000001 x26: 0x0000000000000000 x27: 0x00000000211200d5
x28: 0x0000000000000000 fp: 0x000000016c00d4f0 lr: 0x0000000109f468a0
sp: 0x000000016c00d3f0 pc: 0x0000000109f468a8 cpsr: 0x60001000
far: 0x754665766974617e esr: 0x92000004 (Data Abort) byte read Translation fault
Does this mean there was a regression on this between [email protected]
and [email protected]
?
Since v11
has support for hermes
we are bound to specific version of react-native
. [email protected]
is only compatible with [email protected]
. Expo SDK 45 only supports [email protected]
. Therefore you will have to use [email protected]
in order to use Expo.
Please consult our Compatibility Matrix to determine which version of the -rc
to use.
OK got it, thanks for the fast reply, I'll try [email protected]
with Expo 45 and hermes and report back.
When v11 comes out officially (e.g. [email protected]
) will it support the latest Expo? I see that even Expo 46 is still not on RN 0.70.0 (still 0.69.5)
Not directly, one would have to update React Native in the project manually, as that is a hard dependency for us. The newest Expo would eventually support the newest React Native, which is what we always aim to support.
I also just realized there is an error in that matrix. [email protected]
is compatible with Expo 46. [email protected]
is compatible with Expo 45.
Hey @takameyer thanks for clarifying that. Confirmed that this crash still occurs with [email protected]
and Expo 45 and hermes, but with [email protected]
and Expo 46 and hermes it works perfectly, with no crash!
Probably means this issue can be closed.
Double-checking that [email protected]
+ Expo 46 will also solve https://github.com/realm/realm-js/issues/4639 for Android, yeah?
Double-checking that [email protected] + Expo 46 will also solve https://github.com/realm/realm-js/issues/4639 for Android, yeah?
Yes, this is solved. Happy its working for you! I will close this issue.