From 06fb04ce9f87d5eb8ebb855d972fcbec9150029d Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Tue, 30 Jan 2024 17:49:30 +0530 Subject: [PATCH] chore: disable hermes via gradle project env var fixes #18493 ## Summary We enabled `hermes` for android in the `react-native` upgrade to `0.72.5` Although things seemed fine but developers were seeing frequent crashes in their local environment. After some investigation the crashes were traced to max native call stack depth in `hermes` engine. Disabling `hermes` for local debug builds helps fix that issue. This commit disables `hermes` by default with the help of a exporting an environment variable in the `make run-android` command. It is annoying that this also modifies `android/gradle.properties` so we keep `hermesEnabled` as `false` there as well. We also enable `hermes` when generating release builds so that we can take advantage of `hermes` engine in release builds. --- Makefile | 3 +++ android/gradle.properties | 2 +- nix/mobile/android/release.nix | 2 ++ src/status_im/core.cljs | 6 ++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4704a81e24fa..6456dfdb9c26 100644 --- a/Makefile +++ b/Makefile @@ -273,6 +273,9 @@ run-re-frisk: ##@run Start re-frisk server # TODO: Migrate this to a Nix recipe, much the same way as nix/mobile/android/targets/release-android.nix run-android: export TARGET := android +# INFO: We disable hermes for local builds by default to prevent crashes with exceeding native callstack errors +# https://github.com/status-im/status-mobile/issues/18493 +run-android: export ORG_GRADLE_PROJECT_hermesEnabled := false # INFO: If it's empty (no devices attached, parsing issues, script error) - for Nix it's the same as not set. run-android: export ANDROID_ABI_INCLUDE ?= $(shell ./scripts/adb_devices_abis.sh) run-android: ##@run Build Android APK and start it on the device diff --git a/android/gradle.properties b/android/gradle.properties index 80c9b4dff0c2..3eb91f05da69 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -57,4 +57,4 @@ newArchEnabled=false # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. -hermesEnabled=true +hermesEnabled=false diff --git a/nix/mobile/android/release.nix b/nix/mobile/android/release.nix index c1843b929762..790c9f0378d8 100644 --- a/nix/mobile/android/release.nix +++ b/nix/mobile/android/release.nix @@ -79,6 +79,8 @@ in stdenv.mkDerivation rec { STATUS_GO_SRC_OVERRIDE = statusGoSrcOverride; ANDROID_ABI_SPLIT = androidAbiSplit; ANDROID_ABI_INCLUDE = androidAbiInclude; + # hermes is Disabled by default, we enable it for release https://github.com/status-im/status-mobile/issues/18493 + ORG_GRADLE_PROJECT_hermesEnabled = true; # Fix for ERR_OSSL_EVP_UNSUPPORTED error. NODE_OPTIONS = "--openssl-legacy-provider"; diff --git a/src/status_im/core.cljs b/src/status_im/core.cljs index 4d35819cee65..3cea96d2cc91 100644 --- a/src/status_im/core.cljs +++ b/src/status_im/core.cljs @@ -34,8 +34,13 @@ (def adjust-resize 16) +(defn is-hermes + [] + (boolean (.-HermesInternal js/global))) + (defn init [] + (native-module/init #(re-frame/dispatch [:signals/signal-received %])) (when platform/android? (native-module/set-soft-input-mode adjust-resize)) @@ -54,5 +59,6 @@ (async-storage/get-item :screen-height #(reset! shell.state/screen-height %)) (dev/setup) + (prn "is-hermes ->" (is-hermes)) (re-frame/dispatch-sync [:app-started]))