Enable Hermes in Android. Fixes #8952

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Pedro Pombeiro 2019-08-22 18:36:59 +02:00
parent e4eabd2810
commit cc79cf3b3a
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
3 changed files with 37 additions and 4 deletions

View File

@ -264,6 +264,11 @@ geth-connect: ##@other Connect to Geth on the device
adb forward tcp:8545 tcp:8545 && \
build/bin/geth attach http://localhost:8545
android-clean: export TARGET_OS ?= android
android-clean: ##@prepare Clean Gradle state
git clean -dxf -f ./android/app/build
[ -d android/.gradle ] && cd android && ./gradlew clean
android-ports: export _NIX_ATTR := targets.mobile.android.adb.shell
android-ports: export TARGET_OS ?= android
android-ports: ##@other Add proxies to Android Device/Simulator

View File

@ -79,7 +79,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.Copy
project.ext.react = [
nodeExecutableAndArgs: ["node", "--max-old-space-size=16384"],
entryFile: "index.android.js",
enableHermes: false, // clean and rebuild if changing
enableHermes: true, // clean and rebuild if changing. NOTE: Hermes engine is required for Android 64-bit builds running on 64 devices, to guard against a hang in the UI thread after invoking status-go
bundleInPr: true,
inputExcludes: ["android/**", "ios/**", "react-native/**", "src/**", "test/**"]
]
@ -304,9 +304,11 @@ dependencies {
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
prImplementation files(hermesPath + "hermes-release.aar")
// Force using the release Hermes VM until the perf issues in debug VM are fixed in npm package > 0.1.1 (https://github.com/facebook/hermes/issues/73)
implementation files(hermesPath + "hermes-release.aar")
// debugImplementation files(hermesPath + "hermes-debug.aar")
// releaseImplementation files(hermesPath + "hermes-release.aar")
// prImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}

View File

@ -73,6 +73,9 @@ let
mkdir -p ${projectBuildDir}/node_modules
cp -a ${projectNodePackage}/node_modules/. ${projectBuildDir}/node_modules/
# Ensure that module was correctly installed
[ -d ${projectBuildDir}/node_modules/jsc-android/dist ] || exit 1
# Adjust permissions
chmod -R u+w ${projectBuildDir}
@ -145,6 +148,29 @@ let
'nodeExecutableAndArgs: ["node"' \
'nodeExecutableAndArgs: ["${nodejs}/bin/node"'
# Fix bugs in Hermes usage (https://github.com/facebook/react-native/issues/25601#issuecomment-510856047)
# - Make script always include release Hermes VM, as the debug version is currently way too slow in npm package <= 0.1.1 (https://github.com/facebook/hermes/issues/73)
# - Make PR builds also count as release builds
# - Fix issue where hermes command is being called with same input/output file
substituteInPlace ${projectBuildDir}/node_modules/react-native/react.gradle \
--replace \
'def isRelease = targetName.toLowerCase().contains("release")' \
'def isRelease = true' \
--replace \
'targetName.toLowerCase().contains("release")' \
'!targetName.toLowerCase().contains("debug")' \
--replace \
'commandLine(getHermesCommand(), "-emit-binary", "-out", jsBundleFile, jsBundleFile, *hermesFlags)' \
'def jsBundleFileIn = File.createTempFile("index.android",".tmp")
jsBundleFileIn.deleteOnExit()
ant.move(
file: jsBundleFile,
tofile: jsBundleFileIn
);
commandLine(getHermesCommand(), "-emit-binary", "-out", jsBundleFile, jsBundleFileIn, *hermesFlags)
' \
|| exit
# Patch dependencies which are not yet ported to AndroidX
npx jetify