realm-js: 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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (6 by maintainers)
Hey @takameyer thanks for clarifying that. Confirmed that this crash still occurs with
realm@11.0.0-rc.1
and Expo 45 and hermes, but withrealm@11.0.0-rc.1
and Expo 46 and hermes it works perfectly, with no crash!Probably means this issue can be closed.
Double-checking that
realm@11.0.0-rc.1
+ Expo 46 will also solve https://github.com/realm/realm-js/issues/4639 for Android, yeah?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.
Since
v11
has support forhermes
we are bound to specific version ofreact-native
.realm@11.0.0-rc.2
is only compatible withreact-native@0.70.0
. Expo SDK 45 only supportsreact-native@69.4
. Therefore you will have to userealm@11.0.0-rc.1
in order to use Expo. Please consult our Compatibility Matrix to determine which version of the-rc
to use.@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.
OK I confirmed that this does NOT work with
realm@10.20.0-beta.5
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: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? 🤔