Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(RN 0.72.5) How do we disable hermes for debug variant of Android App and keep hermes enabled for release variants? #42766

Closed
siddarthkay opened this issue Jan 31, 2024 · 6 comments
Labels
Platform: Android Android applications. Resolution: Answered When the issue is resolved with a simple answer Type: Upgrade Issue Issues reported from upgrade issue form

Comments

@siddarthkay
Copy link
Contributor

Old Version

0.69.10

New Version

0.72.5

Description

This is more of a question and an attempt to figure out if something needs to be added to react-native to make this easier.
Prior to upgrading to react native 0.70.x we were able to disable hermes for our debug builds like this -> status-im/status-mobile#14041
After we upgraded to react native 0.72.5 I kept hermes enabled and then later realised that we need to disable it for debug variants.

However when I tried to do so I could not find a straightforward way to do so.
If I keep hermesEnabled as false in gradle.properties hermes is now disabled for all build variants.
We want to disable it for debug but keep it enabled for release variants so that we can reap the benefits of the Hermes Engine.

I tried a very hacky way to achieve this here -> status-im/status-mobile#18675
but I am not sure if this is the best way to do so.

Steps to reproduce

Just try to get hermes to be disabled when you do npx react-native run-android and keep it enabled when you prepare it for release on react-native 0.72.x and above.

Affected Platforms

Runtime - Android, Build - MacOS, Build - Linux

Output of npx react-native info

[nix-shell:~/code/status-im/PR/status-mobile]$ npx react-native info
warn Package react-native-blob-util contains invalid configuration: "dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Fetching system and libraries information...
System:
  OS: macOS 14.3
  CPU: (8) x64 Apple M2
  Memory: 20.21 MB / 24.00 GB
  Shell:
    version: 5.2.21
    path: /nix/store/5cvi09jkz66vlp62zbqxvjybc6yn1cqh-bash-interactive-5.2-p21/bin/bash
Binaries:
  Node:
    version: 18.16.0
    path: /nix/store/4d4sar5gv82d7wn96lq1ddxq3vxfh7h1-nodejs-18.16.0/bin/node
  Yarn:
    version: 1.22.19
    path: /nix/store/y4yns1i4j0p15v3yjhdvwsfilg7s78qm-yarn-1.22.19/bin/yarn
  npm:
    version: 9.5.1
    path: /nix/store/4d4sar5gv82d7wn96lq1ddxq3vxfh7h1-nodejs-18.16.0/bin/npm
  Watchman:
    version: 4.9.0
    path: /nix/store/ak2bihxc4by13kpw8fdln3pdbmpqhdm6-watchman-4.9.0/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "33"
    Build Tools:
      - 33.0.0
    Android NDK: 25.2.9519653
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.11
    path: /nix/store/cpp2dbw1189xj7xd4073iy13saczcr3i-zulu11.48.21-ca-jdk-11.0.11/bin/javac
  Ruby:
    version: 3.1.2
    path: /Users/siddarthkumar/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.5
    wanted: 0.72.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: Not found

Stacktrace or Logs

There is no failure stacktrace, only the failure of my ability to disable hermes on debug builds :)

Reproducer

https://github.com/status-im/status-mobile

Screenshots and Videos

No response

@siddarthkay siddarthkay added Needs: Triage 🔍 Type: Upgrade Issue Issues reported from upgrade issue form labels Jan 31, 2024
@github-actions github-actions bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jan 31, 2024
Copy link

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@github-actions github-actions bot added the Platform: Android Android applications. label Jan 31, 2024
@siddarthkay siddarthkay changed the title How do we disable hermes for debug variant of Android App and keep hermes enabled for release variants? (RN 0.72.5) How do we disable hermes for debug variant of Android App and keep hermes enabled for release variants? Jan 31, 2024
@cortinico
Copy link
Contributor

After we upgraded to react native 0.72.5 I kept hermes enabled and then later realised that we need to disable it for debug variants.

Why do you need to disable Hermes only for debug?
Ultimately, this is not a supported configuration. You should be using Hermes for both Debug and Release.

@JB712
Copy link

JB712 commented Jan 31, 2024

@cortinico To be able to debug via react-native-debugger which use a Chrome debug console, we need to disable Hermes.

@cortinico
Copy link
Contributor

@cortinico To be able to debug via react-native-debugger which use a Chrome debug console, we need to disable Hermes.

Have you tried using our experimental debugger?
https://reactnative.dev/blog/2023/12/06/0.73-debugging-improvements-stable-symlinks#debugging-improvements

Ultimately this is a problem of react-native-debugger so they should provide you support here

@siddarthkay
Copy link
Contributor Author

Why do you need to disable Hermes only for debug

Hi @cortinico : we found here status-im/status-mobile#18493 (comment)
that our debug app crashes very often during development time when hermes is enabled, we tried a few things listed in this issue to fix this crash but what worked best was to disable hermes

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Feb 1, 2024
@siddarthkay
Copy link
Contributor Author

siddarthkay commented Feb 1, 2024

Anyone that came here trying to figure this out, I was able to turn hermes off by setting this environment variable locally :
export ORG_GRADLE_PROJECT_hermesEnabled = false
ref -> example 3 from here : https://docs.gradle.org/current/userguide/project_properties.html
in my CI we set this env var to true

So this problem is solved for me.

@cortinico cortinico added Resolution: Answered When the issue is resolved with a simple answer and removed Needs: Triage 🔍 Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Attention Issues where the author has responded to feedback. labels Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android Android applications. Resolution: Answered When the issue is resolved with a simple answer Type: Upgrade Issue Issues reported from upgrade issue form
Projects
None yet
Development

No branches or pull requests

3 participants