facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.4k stars 24.25k forks source link

0.69.4 hermes crashes with use_frameworks! enabled #34381

Closed billnbell closed 8 months ago

billnbell commented 2 years ago

Description

Using RN 0.69.4 and enabled hermes causes crash.

Able to get it working with Podfile changes, or disabling hermes.

  $static_library += [
    'React-hermes'
  ]

  pre_install do |installer|
      Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
      installer.pod_targets.each do |pod|
        bt = pod.send(:build_type)
        if $static_library.include?(pod.name)
          puts "Overriding the build_type to static_library from static_framework for #{pod.name}"
          def pod.build_type;
            Pod::BuildType.static_library
          end
        end
      end
      installer.pod_targets.each do |pod|
        bt = pod.send(:build_type)
        puts "#{pod.name} (#{bt})"
        puts "  linkage: #{bt.send(:linkage)} packaging: #{bt.send(:packaging)}"
        puts "  dynamic_library #{bt.send(:dynamic_library?)}"
        puts "  dynamic_framework #{bt.send(:dynamic_framework?)}"
        puts "  static_library #{bt.send(:static_library?)}"
        puts "  static_framework #{bt.send(:static_framework?)}"
      end
  end

It crashes at Could not get BatchedBridge, make sure your bundle is packaged correctly:

void JSIExecutor::bindBridge() {
  std::call_once(bindFlag_, [this] {
    SystraceSection s("JSIExecutor::bindBridge (once)");
    Value batchedBridgeValue =
        runtime_->global().getProperty(*runtime_, "__fbBatchedBridge");
    if (batchedBridgeValue.isUndefined() || !batchedBridgeValue.isObject()) {
      throw JSINativeException(
          "Could not get BatchedBridge, make sure your bundle is packaged correctly");
    }

Is this acceptable solution or is there another work-around?

Version

0.69.4

Output of npx react-native info

info Fetching system and libraries information... System: OS: macOS 12.4 CPU: (10) arm64 Apple M1 Max Memory: 159.59 MB / 32.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.16.0 - /usr/local/bin/node Yarn: 1.22.18 - /usr/local/bin/yarn npm: 8.11.0 - /usr/local/bin/npm Watchman: 2022.03.21.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 25, 26, 27, 28, 29, 30, 31 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0 System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Intel x86 Atom_64, android-31 | Google APIs ARM 64 v8a, android-31 | Google APIs Intel x86 Atom_64, android-32 | Google APIs ARM 64 v8a, android-R | Google APIs Intel x86 Atom, chromeos-67 | Chrome OS 67 Android NDK: 22.1.7171670 IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 11.0.16 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

See above desc.

Snack, code example, screenshot, or link to a repository

Nothing more.

waheed471 commented 2 years ago

Comment out use_flipper in podFile then its working fine

use_fipper is not working with use_framework!

billnbell commented 2 years ago

Yeah I have that commented out.

#    use_flipper!()

I cannot get it to not crash without -

  $static_library += [
    'React-hermes'
  ]

Is something missing in the fix for hermes?

billnbell commented 2 years ago

My package.json:

{
  "name": "TheClub",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "pod": "npx pod-install",
    "prettier": "npx prettier --write src",
    "ios": "unset PREFIX && npx react-native run-ios",
    "android": "NODE_OPTIONS=\"--stack-trace-limit=1000 --max_old_space_size=8192\" && APPCENTER_BUILD_ID=1 && npx react-native run-android",
    "start": "npx react-native start --reset-cache",
    "test": "JEST=1 PASSWORD=password npx jest --coverage=true --maxWorkers 2",
    "lint": "npx eslint --ext ts,tsx,js ./src && npx tsc --pretty"
  },
  "resolutions": {
    "@types/react": "18.0.15",
    "@types/react-dom": "18.0.6",
    "cheerio": "1.0.0-rc.12"
  },
  "dependencies": {
    "@formatjs/intl-datetimeformat": "^6.0.3",
    "@formatjs/intl-getcanonicallocales": "^2.0.2",
    "@formatjs/intl-locale": "^3.0.3",
    "@formatjs/intl-numberformat": "^8.0.4",
    "@formatjs/intl-pluralrules": "^5.0.3",
    "@notifee/react-native": "^5.6.0",
    "@react-native-async-storage/async-storage": "^1.17.8",
    "@react-native-community/cameraroll": "^4.1.2",
    "@react-native-community/checkbox": "^0.5.12",
    "@react-native-community/datetimepicker": "^6.3.1",
    "@react-native-community/netinfo": "^9.3.0",
    "@react-native-cookies/cookies": "^6.2.1",
    "@react-native-firebase/analytics": "^14.11.1",
    "@react-native-firebase/app": "^14.11.1",
    "@react-native-firebase/auth": "^14.11.1",
    "@react-native-firebase/crashlytics": "^14.11.1",
    "@react-native-firebase/firestore": "^14.11.1",
    "@react-native-firebase/messaging": "^14.11.1",
    "@react-native-firebase/remote-config": "^14.11.1",
    "@react-native-picker/picker": "^2.4.3",
    "@react-navigation/bottom-tabs": "^6.3.2",
    "@react-navigation/core": "^6.2.2",
    "@react-navigation/elements": "^1.3.4",
    "@react-navigation/native": "^6.0.11",
    "@react-navigation/stack": "^6.2.2",
    "@stream-io/flat-list-mvcp": "^0.10.2",
    "algoliasearch": "^4.14.2",
    "axios": "^0.27.2",
    "buffer": "^6.0.3",
    "date-fns": "^2.29.1",
    "date-fns-tz": "^1.3.6",
    "deprecated-react-native-prop-types": "^2.3.0",
    "fbjs": "^3.0.4",
    "hermes-engine-cli": "~0.11.0",
    "html-entities": "^2.3.3",
    "jwt-decode": "^3.1.2",
    "libphonenumber-js": "^1.10.11",
    "react": "18.2.0",
    "react-instantsearch-native": "^6.31.1",
    "react-native": "^0.69.4",
    "react-native-add-calendar-event": "^4.0.0",
    "react-native-autolink": "^4.0.0",
    "react-native-blob-util": "^0.16.2",
    "react-native-bootsplash": "^4.3.0",
    "react-native-calendar-events": "^2.2.0",
    "react-native-calendars": "1.1286.0",
    "react-native-config": "^1.4.6",
    "react-native-device-info": "^10.0.2",
    "react-native-dialog": "^9.2.2",
    "react-native-document-picker": "^8.1.1",
    "react-native-encrypted-storage": "^4.0.2",
    "react-native-fast-image": "^8.5.11",
    "react-native-fs": "^2.20.0",
    "react-native-gesture-handler": "^2.5.0",
    "react-native-global-props": "^1.1.5",
    "react-native-haptic-feedback": "^1.14.0",
    "react-native-image-crop-picker": "^0.38.0",
    "react-native-image-resizer": "^1.4.5",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-logs": "^5.0.1",
    "react-native-maps": "^1.2.0",
    "react-native-pdf": "^6.6.2",
    "react-native-ratings": "^8.1.0",
    "react-native-reanimated": "2",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "^4.3.1",
    "react-native-screens": "^3.15.0",
    "react-native-share": "^7.8.0",
    "react-native-smooch": "git+https://github.com/billnbell/react-native-sunshine-conversations.git#1.0.39",
    "react-native-svg": "^12.4.3",
    "react-native-touch-id": "^4.4.1",
    "react-native-vector-icons": "^9.2.0",
    "react-native-video": "6.0.0-alpha.1",
    "react-native-webview": "^11.23.0",
    "react-native-wifi-reborn": "^4.7.0",
    "stream-chat": "^6.7.3",
    "stream-chat-react-native": "^4.13.0",
    "use-async-effect": "^2.2.6",
    "validator": "^13.7.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.18.10",
    "@babel/core": "^7.18.10",
    "@babel/eslint-parser": "^7.18.9",
    "@babel/preset-typescript": "^7.18.6",
    "@babel/runtime": "^7.18.9",
    "@jest/create-cache-key-function": "^28.1.3",
    "@jest/globals": "^28.1.3",
    "@react-native-community/cli-platform-ios": "8",
    "@testing-library/jest-native": "^4.0.8",
    "@testing-library/react-native": "^11.0.0",
    "@types/jest": "^28.1.6",
    "@types/react": "^18.0.15",
    "@types/react-native": "0.69",
    "@types/react-native-dialog": "^8.0.0",
    "@types/react-native-dotenv": "^0.2.0",
    "@types/react-native-vector-icons": "^6.4.11",
    "@types/react-test-renderer": "18.0",
    "@types/validator": "^13.7.5",
    "@typescript-eslint/eslint-plugin": "^5.33.0",
    "@typescript-eslint/parser": "^5.33.0",
    "babel-jest": "^28.1.3",
    "babel-plugin-module-resolver": "^4.1.0",
    "cheerio": "1.0.0-rc.12",
    "eslint": "^8.21.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^8.5.0",
    "eslint-import-resolver-typescript": "^3.4.0",
    "eslint-plugin-eslint-plugin": "^5.0.2",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jest": "^26.8.2",
    "eslint-plugin-jsx-a11y": "^6.6.1",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.30.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-native": "^4.0.0",
    "eslint-plugin-simple-import-sort": "^7.0.0",
    "eslint-watch": "^8.0.0",
    "flow-bin": "^0.183.1",
    "jest": "^28.1.3",
    "jest-environment-jsdom": "^28.1.3",
    "metro-react-native-babel-preset": "^0.72.0",
    "patch-package": "^6.4.7",
    "pod-install": "^0.1.38",
    "postinstall-postinstall": "^2.1.0",
    "prettier": "^2.7.1",
    "react-dom": "^18.2.0",
    "react-native-bundle-visualizer": "^3.1.1",
    "react-native-clean-project": "^4.0.1",
    "react-native-typescript-transformer": "^1.2.13",
    "react-test-renderer": "^18.2.0",
    "ts-jest": "^28.0.7",
    "typescript": "^4.7.4"
  }
}
billnbell commented 2 years ago

Do I need "hermes-engine-cli": "~0.11.0", anymore?

brianlenz commented 2 years ago

We ran into this issue, too. react-native-firebase 15.x requires use_frameworks!, per:

https://rnfirebase.io/#altering-cocoapods-to-use-frameworks

For us, the solution was to downgrade react-native-firebase to 14.x (and disable use_frameworks!) until there is better support for Hermes + use_frameworks!. Apparently 0.69.1 was supposed to have some support (and there was a patch-package for it at some point), but even with RN 0.69.4, it's still clearly not fully supported.

It's trivial to reproduce this issue. Just bootstrap a new, vanilla react-native app, edit the Podfile, enable use_frameworks! and set :hermes_enabled => true. Then, just run a Release build, and it'll crash with the above error.

billnbell commented 2 years ago

Thank you! SO they can fix it. It locks up on real device in Release mode, not on simulator.

We ran into this issue, too. react-native-firebase 15.x requires use_frameworks!, per:

https://rnfirebase.io/#altering-cocoapods-to-use-frameworks

For us, the solution was to downgrade react-native-firebase to 14.x (and disable use_frameworks!) until there is better support for Hermes + use_frameworks!. Apparently 0.69.1 was supposed to have some support (and there was a patch-package for it at some point), but even with RN 0.69.4, it's still clearly not fully supported.

It's trivial to reproduce this issue. Just bootstrap a new, vanilla react-native app, edit the Podfile, enable use_frameworks! and set :hermes_enabled => true. Then, just run a Release build, and it'll crash with the above error.

brianlenz commented 2 years ago

FWIW, it crashes if you run a Release build on the Simulator, too.

billnbell commented 2 years ago

Can we cherry pick - this one?

https://github.com/facebook/react-native/commit/70daa6e72822e3eeda4a1c4ebe9a7daa4fc2ac1f

alexco2 commented 2 years ago

We ran into this issue, too. react-native-firebase 15.x requires use_frameworks!, per:

https://rnfirebase.io/#altering-cocoapods-to-use-frameworks

For us, the solution was to downgrade react-native-firebase to 14.x (and disable use_frameworks!) until there is better support for Hermes + use_frameworks!. Apparently 0.69.1 was supposed to have some support (and there was a patch-package for it at some point), but even with RN 0.69.4, it's still clearly not fully supported.

It's trivial to reproduce this issue. Just bootstrap a new, vanilla react-native app, edit the Podfile, enable use_frameworks! and set :hermes_enabled => true. Then, just run a Release build, and it'll crash with the above error.

I have the same issue with my project as well as a Vanilla rn app.

billnbell commented 2 years ago

same with 0.69.5 too,

evelant commented 2 years ago

Yeah, can confirm 0.69.5 crashes on Release iOS build with use_frameworks! and hermes.

What's almost worse is that development builds work. They apparently silently fall back to JSC.

react-native-firebase is forced to use use_frameworks! due to upstream firebase libraries. They can't fix the problem going forward no matter what. That means that currently nobody can make release builds on iOS if they use what is probably one of the most popular libraries in the RN ecosystem. Downgrading to rn-firebase v14.11.1 is only a temporary fix.

The fix for this seem to clearly lie with react-native or hermes. How can we get this issue some attention? It's likely impacting a lot of people.

billnbell commented 2 years ago

Anyone - thoughts?

I am happy to help figure it out - but no idea why it is crashing.

nanthawat commented 2 years ago

react-native-reanimated/pull/3491 this solution it work for me

glesperance commented 2 years ago

@nanthawat can you go into more details about how you applied the fix[1]? The PR you linked modifies a podspec -- are you applying the same kind of modification but to the podfile?

[1] https://github.com/software-mansion/react-native-reanimated/pull/3491

billnbell commented 2 years ago

OK this appears to work on react-native-reanimated. We need t get that pushed out ....

   "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
tr3v3r commented 1 year ago

Try to use add :linkage => :static to use_framework. Hope it helps.

use_frameworks! :linkage => :static
Simoon-F commented 1 year ago

same.

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 8 months ago

This issue was closed because it has been stalled for 7 days with no activity.