[iOS] Preview/Production Build crashes directly after second start of the app

Hello Everyone,

After the update from Expo 45 to 47 I have a problem with the Preview and Production Builld IOS builds of the App. The Android part works fine. When I create an development build (eas build --profile development --platform ios) there is no problem. But the preview and production builds crash directly after opening the App for the second time. The first time the app is opened it works as expected.

…
Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000105004e40
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [726]


Triggered by Thread:  7
…
Thread 7 name:   Dispatch queue: com.apple.root.user-interactive-qos
Thread 7 Crashed:
0   MY_APP_NAME		                         0x105004e40 facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::Around::Around(facebook::react::(anonymous namespace)::ReentrancyCheck&) + 2543168 (decorator.h:748)
1   MY_APP_NAME			                     0x105004dd8 facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::Around::Around(facebook::react::(anonymous namespace)::ReentrancyCheck&) + 2543064 (decorator.h:748)
2   MY_APP_NAME			                     0x105002db8 facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::createObject() + 2534840 (decorator.h:594)
3   MY_APP_NAME			                     0x104e249b0 -[EXJavaScriptRuntime createObject] + 575920 (EXJavaScriptRuntime.mm:77)
4   MY_APP_NAME			                     0x104e26044 -[EXJavaScriptRuntime initializeMainObject] + 581700 (EXJavaScriptRuntime.mm:193)
5   MY_APP_NAME			                     0x104e24900 -[EXJavaScriptRuntime initWithRuntime:callInvoker:] + 575744 (EXJavaScriptRuntime.mm:63)
6   MY_APP_NAME			                     0x104e2ae0c +[EXJavaScriptRuntimeManager runtimeFromBridge:] + 601612 (EXJSIInstaller.mm:0)
7   MY_APP_NAME			                     0x104e6b30c ExpoBridgeModule.javaScriptWillStartExecutingNotification(_:) + 865036 (ExpoBridgeModule.swift:76)
8   MY_APP_NAME			                     0x104e6b5cc @objc ExpoBridgeModule.javaScriptWillStartExecutingNotification(_:) + 865740 (<compiler-generated>:0)
9   CoreFoundation                           0x19862b404 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
10  CoreFoundation                           0x1986d2474 ___CFXRegistrationPost_block_invoke + 88
11  CoreFoundation                           0x1986b5724 _CFXRegistrationPost + 440
12  CoreFoundation                           0x19863fa08 _CFXNotificationPost + 704
13  Foundation                               0x192a38ffc -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
14  MY_APP_NAME			                     0x104f348a0 __51-[RCTCxxBridge executeApplicationScript:url:async:]_block_invoke + 1689760 (RCTCxxBridge.mm:1504)
15  MY_APP_NAME			                     0x104f38c08 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) + 1707016 (function.h:0)
16  MY_APP_NAME			                     0x104f2ee34 -[RCTCxxBridge _tryAndHandleError:] + 1666612 (RCTCxxBridge.mm:344)
17  MY_APP_NAME			                     0x104f34774 -[RCTCxxBridge executeApplicationScript:url:async:] + 1689460 (RCTCxxBridge.mm:1541)
18  MY_APP_NAME			                     0x104f345e4 -[RCTCxxBridge enqueueApplicationScript:url:onComplete:] + 1689060 (RCTCxxBridge.mm:1484)
19  MY_APP_NAME			                     0x104f32614 -[RCTCxxBridge executeSourceCode:sync:] + 1680916 (RCTCxxBridge.mm:1079)
20  MY_APP_NAME			                     0x104f300b8 __21-[RCTCxxBridge start]_block_invoke_2 + 1671352 (RCTCxxBridge.mm:507)
21  libdispatch.dylib                        0x19fbcc4b4 _dispatch_call_block_and_release + 32
22  libdispatch.dylib                        0x19fbcdfdc _dispatch_client_callout + 20
23  libdispatch.dylib                        0x19fbdfb8c _dispatch_root_queue_drain + 684
24  libdispatch.dylib                        0x19fbe0284 _dispatch_worker_thread2 + 164
25  libsystem_pthread.dylib                  0x1e5653dbc _pthread_wqthread + 228
26  libsystem_pthread.dylib                  0x1e5653b98 start_wqthread + 8
…

Expo: 47
Workflow: bare
eas-cli: 2.7.1

{
    "scripts": {
        "start": "expo start",
        "android": "react-native run-android",
        "ios": "react-native run-ios",
        "web": "expo start --web",
        "eject": "expo eject",
        "server": "json-server -w db.json -d 700",
        "test": "jest",
        "devStart": "expo start -p 80",
        "expo-ios": "expo run:ios",
        "eas-android": "eas build --profile development --platform android",
        "eas-android-preview": "eas build --profile preview --platform android",
        "eas-ios": "eas build --profile development --platform ios",
        "eas-ios-preview": "eas build --profile preview --platform ios",
        "eas-ios-production": "eas build --profile production --platform ios",
        "local-prod-build": "npx expo start --no-dev --minify",
        "local-eas-ios-preview": "eas build --platform ios --profile preview --local",
        "local-eas-ios-prod": "eas build --platform ios --profile production --local",
        "postinstall": "patch-package"
    },
    "jest": {
        "preset": "jest-expo",
        "transformIgnorePatterns": [
            "node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)"
        ],
        "collectCoverage": true,
        "coverageReporters": [
            "html"
        ],
        "setupFiles": [
            "./jest/jestSetupFile.js"
        ]
    },
    "dependencies": {
        "@ant-design/icons": "^4.7.0",
        "@babel/runtime": "^7.19.4",
        "@react-native-async-storage/async-storage": "~1.17.3",
        "@react-native-mapbox-gl/maps": "^8.5.0",
        "@react-navigation/drawer": "^6.4.3",
        "@react-navigation/elements": "^1.3.4",
        "@react-navigation/material-top-tabs": "^6.2.2",
        "@react-navigation/native": "^6.0.11",
        "@react-navigation/stack": "^6.2.2",
        "@reduxjs/toolkit": "^1.8.2",
        "@sentry/react-native": "4.2.2",
        "@shopify/flash-list": "~1.3.1",
        "@types/i18n-js": "^3.8.2",
        "@types/react-native-signature-capture": "^0.4.2",
        "@types/react-native-snap-carousel": "^3.8.5",
        "@types/redux-logger": "^3.0.9",
        "axios": "^0.22.0",
        "babel-plugin-transform-remove-console": "^6.9.4",
        "date-fns": "^2.27.0",
        "deprecated-react-native-prop-types": "^2.3.0",
        "expo": "^47.0.8",
        "expo-application": "~5.0.1",
        "expo-asset": "~8.6.2",
        "expo-auth-session": "~3.7.2",
        "expo-barcode-scanner": "~12.1.0",
        "expo-camera": "~13.1.0",
        "expo-constants": "~14.0.2",
        "expo-dev-client": "~2.0.1",
        "expo-device": "~5.0.0",
        "expo-file-system": "~15.1.1",
        "expo-image-manipulator": "~11.0.0",
        "expo-local-authentication": "~13.0.2",
        "expo-location": "~15.0.1",
        "expo-mail-composer": "~12.0.0",
        "expo-media-library": "~15.0.0",
        "expo-modules-autolinking": "~1.0.0",
        "expo-modules-core": "~1.0.3",
        "expo-network": "~5.0.0",
        "expo-random": "~13.0.0",
        "expo-screen-orientation": "~5.0.1",
        "expo-secure-store": "~12.0.0",
        "expo-status-bar": "~1.4.2",
        "expo-updates": "~0.15.6",
        "i18n-js": "^3.9.2",
        "iso8601-duration": "^2.1.1",
        "npm-license-crawler": "^0.2.1",
        "patch-package": "^6.4.7",
        "postinstall-postinstall": "^2.1.0",
        "prop-types": "15.8.1",
        "react": "18.1.0",
        "react-dom": "18.1.0",
        "react-native": "0.70.5",
        "react-native-app-auth": "^6.4.0",
        "react-native-base64": "^0.2.1",
        "react-native-dropdown-picker": "^5.4.0",
        "react-native-elements": "^3.4.2",
        "react-native-gesture-handler": "~2.8.0",
        "react-native-get-random-values": "~1.8.0",
        "react-native-image-picker": "^4.8.5",
        "react-native-logs": "^4.0.1",
        "react-native-pager-view": "6.0.1",
        "react-native-paper": "^4.12.5",
        "react-native-photo-manipulator": "^1.2.7",
        "react-native-reanimated": "~2.12.0",
        "react-native-safe-area-context": "4.4.1",
        "react-native-screens": "~3.18.0",
        "react-native-signature-canvas": "^4.3.0",
        "react-native-snap-carousel": "^3.9.1",
        "react-native-tab-view": "^3.1.1",
        "react-native-vector-icons": "^9.0.0",
        "react-native-web": "~0.18.7",
        "react-native-webview": "11.23.1",
        "react-native-zip-archive": "^6.0.8",
        "react-redux": "^7.2.8",
        "realm": "^11.2.0",
        "redux": "^4.2.0",
        "redux-logger": "^3.0.6",
        "redux-thunk": "^2.4.0",
        "sentry-expo": "~5.0.3",
        "uuid": "^8.3.2"
    },
    "devDependencies": {
        "@babel/core": "^7.19.3",
        "@babel/preset-env": "^7.19.4",
        "@types/jest": "^27.0.2",
        "@types/react": "~17.0.39",
        "@types/react-dom": "~17.0.18",
        "@types/react-native": "~0.70.6",
        "@types/react-native-base64": "^0.2.0",
        "@types/uuid": "^8.3.1",
        "jest": "^26.6.3",
        "jest-expo": "^47.0.0-beta",
        "typescript": "^4.6.3"
    },
    "resolutions": {
        "@types/react": "17.0.39",
        "@types/react-dom": "17.0.18"
    },
    "private": true,
    "name": "MY_APP_NAME",
    "version": "0.0.2"
}


I replaced the code of most of the native iOS files with code from a fresh Expo 47 project to resolve the issue but none worked so far.

I hope some of you have an idea how to solve this. I’m stuck on this Issue for some time now. If you need additional information, ask in the comments.

Thanks in advance :slight_smile:

Hi @ffelten,

Can you share your EAS Build link which you specify crashes the app on the opening it second time? Just to make sure that the Preview or Production build profiles are set up correctly.

Hello,

there are now two new EAS preview builds in the project. I hope as part of the Expo team you can access my account and project (there is only one project in this account). I’m not sure if it is safe to publicly share the link to a build?
Previously I made most EAS builds locally (with --local flag) to safe some time.

The 2 iOS builds I mentioned above only differ in the version number because I thougth that the crash is maybe related to this one iOS builds with old build numbers crash on restart after minor version bump - #14 by wodin but it doesn’t make any difference.

1 Like

In case the content of the eas.json helps.

{
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      },
      "channel": "staging"
    },
    "production": {
      "autoIncrement": true,
      "channel": "production"
    }
  },
  "submit": {
    "production": {}
  },
  "cli": {
    "version": ">= 2.7.1",
    "requireCommit": true,
    "appVersionSource": "local"
  }
}

Link shared are only accessible to Expo team members! However, to respect privacy, if you want to (so that I can confirm I am looking at right versions of the builds), you can DM me on Expo’s discord (chat.expo.dev). My username is amanhimself#5585.

Assuming I am looking at the correct build, there is warning in your build process:

Detected and removed file: ios/.xcode.env.local. This file should not be committed to source control. Learn more: https://expo.fyi/xcode-env-local

Also, your build detects an existing ios directory. Not sure if you are on managed or bare workflow, but if this were not your intention, I’d suggest removing them and re-run the build.

Yes, this is the correct build. I ignored this warning because it states, that the file was removed. Therefore I assumed that the file cannot cause any problems. But I will remove the file from the repo to remove the warning and run the build again. The project is bare workflow, so the already existing ios directory is correct.

Thanks for confirming.

If this is a bare workflow then I think you can leave the ios directory as it is and removing the file is handled by the build process.

Build process seems fine so I’d suggest taking a look at the native error logs which are available from macOS’s Console.app (it can show iPhone logs), that might be the quickest way to find a lead.

I already checked the device logs, but this doesn’t gave me a hint, what the problem is. Can you please tell me for what kind of messages I should look for or share here?

In the initial post I shared a stacktrace, which I got from the device logs via XCode. Do you need more stacktraces? Or more information from this report?

The Console app can potentially give you more information than the above log. You can plug in your phone to your computer, open Console, and record the log messages until the app crashes, and then see what the logs say at the exact moment it crashes.

However, since you’re already in bare workflow, you might consider running the app locally in Xcode or with npx expo run:ios to see if the same error occurs. Then you have the full power of logging, the native debugger, etc. If it doesn’t crash in Debug scheme, you can try the Release scheme.

Another tip when the issue is not present on a development/ running locally is to try the --no-dev flag with npx expo start --dev-client. This will run your JavaScript in a way that more closely simulates a production build.

Finally, be sure to double-check the release notes for both SDK 46 and 47 to verify the upgrade steps- this is especially important in Bare workflow, when you have to upgrade the projects themselves.

I looked at your builds and didn’t see anything obvious that would cause this error, though you may want to look closer into some of the warnings during pod install to see if you can eliminate those.

2 Likes

Thanks for the tips.

I tested most of them already before but checked them again that my answer is up-to-date.

npx expo run:ios works without any problems.

npx expo run:ios --device --configuration Release crashes in the same way the preview or production builds do. But I don’t get any additional output from the logs or crash reports.

npx expo start --no-dev --minify works also without problems.

I checked the migration guide several times. Because that doesn’t help and I wasn’t sure if I migrated everything correctly. I created a new Expo 47 project from the template expo-template-blank-typescript, ejected the project and copied all native ios files to the existing project (with some minor adjustments to fit the current project).

The console app creates a lot of log output, but I cannot find an entry, which indicates what the cause of the crash was. Can you tell me for which messages I should look at? Maybe a filter keyword?

I attached some lines from the log that are marked as ‘error’ during crash time of my app.

error    14:51:11.750313+0100    SpringBoard    Scene FBSceneManager/sceneID:MY_APP_NAME-default update failed: <NSError: 0x280d02010; domain: FBSceneErrorDomain; code: 1 (operation-failed); reason: "Scene update failed."> {

    NSUnderlyingError = <NSError: 0x280c7e490; domain: BSServiceConnectionErrorDomain; code: 3 (OperationFailed); reason: "XPC error received on message reply handler">;

}


error    14:51:11.751020+0100    SpringBoard    Scene FBSceneManager/sceneID:MY_APP_NAME-default update failed: <NSError: 0x280ed47e0; domain: FBSceneErrorDomain; code: 1 (operation-failed); reason: "Scene update failed."> {

    NSUnderlyingError = <NSError: 0x280cdf960; domain: BSServiceConnectionErrorDomain; code: 3 (OperationFailed); reason: "XPC error received on message reply handler">;

}




error    14:51:11.751903+0100    SpringBoard    Scene FBSceneManager/sceneID:MY_APP_NAME-default update failed: <NSError: 0x280c111a0; domain: FBSceneErrorDomain; code: 1 (operation-failed); reason: "Scene update failed."> {

    NSUnderlyingError = <NSError: 0x280c7f990; domain: BSServiceConnectionErrorDomain; code: 3 (OperationFailed); reason: "XPC error received on message reply handler">;

}


error    14:51:11.752945+0100    SpringBoard    Advisor: No handle found for currently focused PID: 762; sceneIdentity: com.apple.frontboard.systemappservices::FBSceneManager:sceneID%3AMY_APP_NAME-default


error    14:51:11.786087+0100    SpringBoard    Ignoring update for invalidated scene: sceneID:MY_APP_NAME-default


standard    14:51:11.800622+0100    SpringBoard    [MY_APP_NAME] MY_APP_NAME application state changed to Terminated

The problem was fixed with the changes from [core] fix installing expo hostobject thread issue on ios hermes by Kudo · Pull Request #20506 · expo/expo · GitHub.

I integrated the changes in my project and used patch-package.

Thanks for the fix.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.