React Native Expo - Crash on production iOS but working fine on ExpoGo and standalone

165 Views Asked by At

The last update on my app is crashing when hitting the root router (react navigation).

I can't manage to pinpoint the exact problem, even when with XCode and adb logcat. When I run the app on ExpoGO, it works perfectly. Same for standalone .apk, and iOS simulator.

Could it be a memory leak? Or does it have to do with Amplitude Analytics?

It crashes when running the app in production and:

  • I log in, and it redirects me to my logged-in home screen
  • I am already logged in and navigate to one of the restaurants screen

Some background:

Using Expo Managed workflow
eas-cli version: 3.17.01

My debug log:

Incident Identifier: A45A65B2-31AC-47B8-BB57-EF813A977C9F
    Beta Identifier:     A66861AD-7877-459B-AB86-E5BABE9AE0B9
    Hardware Model:      iPhone14,4
    Process:             Foodhi [17532]
    Path:                /private/var/containers/Bundle/Application/6B6E18A9-    ED4A-4D55-8D1F-DC676144DAE5/Foodhi.app/Foodhi
    Identifier:          com.foodhi.foodhiapp
    Version:             1.0.5 (1.0.61)
    AppStoreTools:       14E221
    AppVariant:          1:iPhone14,4:16
    Beta:                YES
    Code Type:           ARM-64 (Native)
    Role:                Foreground
    Parent Process:      launchd [1]
    Coalition:           com.foodhi.foodhiapp [3681]

    Date/Time:           2023-08-02 20:28:54.4107 +0200
    Launch Time:         2023-08-02 18:34:28.3462 +0200
    OS Version:          iPhone OS 16.3.1 (20D67)
    Release Type:        User
    Baseband Version:    2.40.01
    Report Version:      104

    Exception Type:  EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Triggered by Thread:  9

    Application Specific Information:
    abort() called

    ...
    ...

    Thread 9 name:   Dispatch queue: com.facebook.react.AmplitudeReactNativeQueue
    Thread 9 Crashed:
    0   libsystem_kernel.dylib                 0x1d5c13674 __pthread_kill + 8
    1   libsystem_pthread.dylib                0x1e63771ac pthread_kill + 268
    2   libsystem_c.dylib                      0x19f774c8c abort + 180
    3   libc++abi.dylib                        0x1e62b6b8c abort_message + 132
    4   libc++abi.dylib                        0x1e62a6a80 demangling_terminate_handler()     + 336
    5   libobjc.A.dylib                        0x191295d3c _objc_terminate() + 144
    6   Foodhi                                 0x10462af64 0x1043ac000 + 2617188
    7   libc++abi.dylib                        0x1e62b5f28 std::__terminate(void (*)()) +     20
    8   libc++abi.dylib                        0x1e62b5ec4 std::terminate() + 56
    9   libdispatch.dylib                      0x19f710f9c _dispatch_client_callout + 40
    10  libdispatch.dylib                      0x19f718640 _dispatch_lane_serial_drain + 672
    11  libdispatch.dylib                      0x19f71918c _dispatch_lane_invoke + 384
    12  libdispatch.dylib                      0x19f723e10 _dispatch_workloop_worker_thread + 652
    13  libsystem_pthread.dylib                0x1e6370df8 _pthread_wqthread + 288
    14  libsystem_pthread.dylib                0x1e6370b98 start_wqthread + 8

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "postinstall": "patch-package"
  },
  "dependencies": {
    "@amplitude/analytics-react-native": "^1.3.2",
    "@expo-google-fonts/quicksand": "^0.2.0",
    "@expo-google-fonts/rubik": "^0.2.0",
    "@expo/html-elements": "^0.3.1",
    "@expo/ngrok": "^4.1.0",
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-community/datetimepicker": "6.5.2",
    "@react-native-picker/picker": "2.4.8",
    "@react-navigation/drawer": "^6.1.4",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/stack": "^6.0.7",
    "@sentry/react-native": "4.9.0",
    "axios": "^0.21.1",
    "babel-plugin-inline-dotenv": "^1.6.0",
    "base-64": "^1.0.0",
    "dayjs": "^1.11.7",
    "deprecated-react-native-prop-types": "^2.3.0",
    "expo": "^47.0.0",
    "expo-application": "~5.0.1",
    "expo-camera": "~13.1.0",
    "expo-constants": "~14.0.2",
    "expo-dev-client": "~2.0.1",
    "expo-device": "~5.0.0",
    "expo-font": "~11.0.1",
    "expo-image-picker": "~14.0.2",
    "expo-linking": "~3.3.1",
    "expo-location": "~15.0.1",
    "expo-notifications": "~0.17.0",
    "expo-splash-screen": "~0.17.5",
    "expo-status-bar": "~1.4.2",
    "expo-updates": "~0.15.6",
    "formik": "^2.2.9",
    "html-entities": "^2.3.3",
    "jwt-decode": "^3.1.2",
    "moment": "^2.29.4",
    "patch-package": "^6.5.1",
    "postinstall-postinstall": "^2.1.0",
    "react": "18.1.0",
    "react-native": "0.70.8",
    "react-native-bouncy-checkbox": "^3.0.4",
    "react-native-collapsible": "^1.6.0",
    "react-native-dotenv": "^3.2.0",
    "react-native-elements": "^3.4.3",
    "react-native-form-validator": "^0.4.0",
    "react-native-geocoding": "^0.5.0",
    "react-native-gesture-handler": "~2.8.0",
    "react-native-google-places-autocomplete": "^2.4.1",
    "react-native-maps": "1.3.2",
    "react-native-phone-number-input": "^2.1.0",
    "react-native-picker-select": "^8.0.4",
    "react-native-popover-view": "^5.1.7",
    "react-native-reanimated": "~2.12.0",
    "react-native-safe-area-context": "4.4.1",
    "react-native-safe-area-view": "^1.1.1",
    "react-native-screens": "~3.18.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-super-grid": "^4.1.3",
    "react-native-vector-icons": "^9.2.0",
    "react-native-woocommerce-api": "^1.8.8",
    "react-redux": "^7.2.4",
    "redux": "^4.1.1",
    "redux-devtools-extension": "^2.13.9",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.3.0",
    "sentry-expo": "~6.0.0",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@babel/core": "^7.19.3"
  },
  "private": true
}

eas.json

{
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "channel": "development",
      "ios": {
        "resourceClass": "m-medium"
      }
    },
    "preview": {
      "ios": {
        "simulator": true,
        "image": "latest",
        "resourceClass": "m-medium"
      },
      "distribution": "internal",
      "channel": "preview"
    },
    "production": {
      "channel": "production",
      "ios": {
        "resourceClass": "m-medium"
      }
    }
  },
  "cli": {
    "version": ">= 0.52.0"
  }
}


Where Amplitude is being initialised (once the user profile is loaded):

const RootRouter = () => {

    const initStackNavigator = createStackNavigator();

    const dispatch = useDispatch();
    const userLoggedIn = useSelector((state) => state.auth.loggedIn);
    const restaurantProfileId = useSelector((state) => state.restaurantProfile.id);
    const loaded = useSelector(state => state.restaurantProfile.profileLoaded);

    useEffect(() => {
        if (loaded) {
            // GET PROFILE DETAILS
            dispatch(readProfileDetails())
            // PROCESS PUSH NOTIFICATION TOKEN
            pushNotificationsSetUp(userLoggedIn, restaurantProfileId)

            dispatch(setScreenName(navigationRef.current.getCurrentRoute().name)) 
        }
    }, [loaded])

    // INITIALIZE AMPLITUDE ANALYTICS ONCE THE USER ID IS RETREIVED
    useEffect(() => {
        if (restaurantProfileId) {
            init(process.env.AMPLITUDE_API, restaurantProfileId, {
                serverZone: 'EU',
            });
        }
    }, [loaded])

Any help would be greatly appreciated!

0

There are 0 best solutions below