From 2a9805f9b154e4262cb81c04e2ab77f1b0d6401b Mon Sep 17 00:00:00 2001 From: Titus-Andrei Moldovan Date: Mon, 28 Sep 2020 16:27:56 +0300 Subject: [PATCH] feat(android) revert to JSC as our JS engine JSC wasn't the cause for the crash we were hunting after all. RN doesn't set HErmes as the default, neither does Expo, so the jury is still out on Hermes, and it looks like JSC is still the safest bet. In addition, the way Hermes is packaged (as a standalone AARs, instead of a local "Maven repo") complicates the SDK build and can make the resulting build bloated. --- android/app/proguard-rules.pro | 6 +--- android/build.gradle | 2 ++ android/scripts/release-sdk.sh | 32 ++++++++----------- android/sdk/build.gradle | 21 ++---------- .../meet/sdk/ReactInstanceManagerHolder.java | 8 +++-- 5 files changed, 24 insertions(+), 45 deletions(-) diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index 73775479c..261aca42a 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -85,8 +85,4 @@ # ^^^ We added the above when we switched minifyEnabled on. # Rule to avoid build errors related to SVGs. --keep public class com.horcrux.svg.** {*;} - -# Hermes --keep class com.facebook.hermes.unicode.** { *; } - +-keep public class com.horcrux.svg.** {*;} \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 72890deb5..c31ae6d3b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,6 +21,8 @@ allprojects { jcenter() // React Native (JS, Obj-C sources, Android binaries) is installed from npm. maven { url "$rootDir/../node_modules/react-native/android" } + // Android JSC is installed from npm. + maven { url("$rootDir/../node_modules/jsc-android/dist") } } // Make sure we use the react-native version in node_modules and not the one diff --git a/android/scripts/release-sdk.sh b/android/scripts/release-sdk.sh index a9b43a213..a1a76166b 100755 --- a/android/scripts/release-sdk.sh +++ b/android/scripts/release-sdk.sh @@ -10,7 +10,7 @@ MVN_HTTP=0 DEFAULT_SDK_VERSION=$(grep sdkVersion ${THIS_DIR}/../gradle.properties | cut -d"=" -f2) SDK_VERSION=${OVERRIDE_SDK_VERSION:-${DEFAULT_SDK_VERSION}} RN_VERSION=$(jq -r '.version' ${THIS_DIR}/../../node_modules/react-native/package.json) -HERMES_VERSION=$(jq -r '.dependencies."hermes-engine"' ${THIS_DIR}/../../node_modules/react-native/package.json | cut -c 2-) +JSC_VERSION="r"$(jq -r '.dependencies."jsc-android"' ${THIS_DIR}/../../node_modules/react-native/package.json | cut -d . -f 1 | cut -c 2-) DO_GIT_TAG=${GIT_TAG:-0} if [[ $THE_MVN_REPO == http* ]]; then @@ -38,19 +38,17 @@ if [[ $MVN_HTTP == 1 ]]; then -DgeneratePom=false \ -DpomFile=react-native-${RN_VERSION}.pom || true popd - # Push Hermes - echo "Pushing Hermes ${HERMES_VERSION} to the Maven repo" - pushd ${THIS_DIR}/../../node_modules/hermes-engine/android/ + # Push JSC + echo "Pushing JSC ${JSC_VERSION} to the Maven repo" + pushd ${THIS_DIR}/../../node_modules/jsc-android/dist/org/webkit/android-jsc/${JSC_VERSION} mvn \ deploy:deploy-file \ -Durl=${MVN_REPO} \ -DrepositoryId=${MVN_REPO_ID} \ - -Dfile=hermes-release.aar \ + -Dfile=android-jsc-${JSC_VERSION}.aar \ -Dpackaging=aar \ - -DgroupId=com.facebook \ - -DartifactId=hermes \ - -Dversion=${HERMES_VERSION} \ - -DgeneratePom=true || true + -DgeneratePom=false \ + -DpomFile=android-jsc-${JSC_VERSION}.pom || true popd else # Push React Native, if necessary @@ -67,19 +65,17 @@ else popd fi - # Push Hermes, if necessary - if [[ ! -d ${MVN_REPO}/com/facebook/hermes/${HERMES_VERSION} ]]; then - echo "Pushing Hermes ${HERMES_VERSION} to the Maven repo" - pushd ${THIS_DIR}/../../node_modules/hermes-engine/android/ + # Push JSC, if necessary + if [[ ! -d ${MVN_REPO}/org/webkit/android-jsc/${JSC_VERSION} ]]; then + echo "Pushing JSC ${JSC_VERSION} to the Maven repo" + pushd ${THIS_DIR}/../../node_modules/jsc-android/dist/org/webkit/android-jsc/${JSC_VERSION} mvn \ deploy:deploy-file \ -Durl=${MVN_REPO} \ - -Dfile=hermes-release.aar \ + -Dfile=android-jsc-${JSC_VERSION}.aar \ -Dpackaging=aar \ - -DgroupId=com.facebook \ - -DartifactId=hermes \ - -Dversion=${HERMES_VERSION} \ - -DgeneratePom=true + -DgeneratePom=false \ + -DpomFile=android-jsc-${JSC_VERSION}.pom popd fi diff --git a/android/sdk/build.gradle b/android/sdk/build.gradle index be83b4ab9..902f7a616 100644 --- a/android/sdk/build.gradle +++ b/android/sdk/build.gradle @@ -1,5 +1,3 @@ -import groovy.json.JsonSlurper - apply plugin: 'com.android.library' apply plugin: 'maven-publish' @@ -35,10 +33,6 @@ android { } } } - - packagingOptions { - pickFirst '**/libc++_shared.so' - } } dependencies { @@ -50,11 +44,8 @@ dependencies { //noinspection GradleDynamicVersion api 'com.facebook.react:react-native:+' - - // Hermes JS engine - def hermesPath = "../../node_modules/hermes-engine/android/" - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") + //noinspection GradleDynamicVersion + implementation 'org.webkit:android-jsc:+' implementation 'com.dropbox.core:dropbox-core-sdk:3.0.8' implementation 'com.jakewharton.timber:timber:4.7.1' @@ -227,14 +218,6 @@ publishing { dependency.appendNode('artifactId', artifactId) dependency.appendNode('version', it.moduleVersion) } - - // Add Hermes dependency. - def hermesPkg = new File("$rootDir/../node_modules/hermes-engine/package.json") - def hermesVersion = new JsonSlurper().parseText(hermesPkg.text).version - def hermesDependency = dependencies.appendNode('dependency') - hermesDependency.appendNode('groupId', "com.facebook") - hermesDependency.appendNode('artifactId', "hermes") - hermesDependency.appendNode('version', hermesVersion) } } diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java index 3a8e6c245..d399acf26 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java @@ -20,7 +20,6 @@ import android.app.Activity; import androidx.annotation.Nullable; -import com.facebook.hermes.reactexecutor.HermesExecutorFactory; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactPackage; import com.facebook.react.bridge.NativeModule; @@ -28,6 +27,7 @@ import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.common.LifecycleState; import com.facebook.react.devsupport.DevInternalSettings; +import com.facebook.react.jscexecutor.JSCExecutorFactory; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.soloader.SoLoader; @@ -35,6 +35,7 @@ import com.facebook.soloader.SoLoader; import com.oney.WebRTCModule.RTCVideoViewManager; import com.oney.WebRTCModule.WebRTCModule; +import org.jitsi.meet.sdk.log.JitsiMeetLogger; import org.webrtc.SoftwareVideoDecoderFactory; import org.webrtc.SoftwareVideoEncoderFactory; import org.webrtc.audio.AudioDeviceModule; @@ -216,8 +217,9 @@ class ReactInstanceManagerHolder { // Ignore any error, the module is not compiled when LIBRE_BUILD is enabled. } - // Use the Hermes JavaScript engine. - HermesExecutorFactory jsFactory = new HermesExecutorFactory(); + // Keep on using JSC, the jury is out on Hermes. + JSCExecutorFactory jsFactory + = new JSCExecutorFactory("", ""); reactInstanceManager = ReactInstanceManager.builder()