Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,11 @@ jobs:
uses: ./.github/actions/build-android
with:
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
run-e2e-tests: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
run-e2e-tests: true #${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}

test_e2e_android_rntester:
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
#if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
runs-on: 4-core-ubuntu
needs: [build_android]
strategy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ internal object NdkConfiguratorUtils {
): Pair<List<String>, List<String>> {
val excludes = mutableListOf<String>()
val includes = mutableListOf<String>()

// note: libjsctooling.so is kept here for backward compatibility.
when {
hermesEnabled -> {
excludes.add("**/libjsc.so")
Expand Down
21 changes: 21 additions & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,19 @@ public abstract interface class com/facebook/react/interfaces/fabric/ReactSurfac
public abstract fun stop ()Lcom/facebook/react/interfaces/TaskInterface;
}

public final class com/facebook/react/jscexecutor/JSCExecutor : com/facebook/react/bridge/JavaScriptExecutor {
public fun getName ()Ljava/lang/String;
public static final fun loadLibrary ()V
}

public final class com/facebook/react/jscexecutor/JSCExecutorFactory : com/facebook/react/bridge/JavaScriptExecutorFactory {
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public fun create ()Lcom/facebook/react/bridge/JavaScriptExecutor;
public fun startSamplingProfiler ()V
public fun stopSamplingProfiler (Ljava/lang/String;)V
public fun toString ()Ljava/lang/String;
}

public final class com/facebook/react/jstasks/HeadlessJsTaskConfig {
public fun <init> (Lcom/facebook/react/jstasks/HeadlessJsTaskConfig;)V
public fun <init> (Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;)V
Expand Down Expand Up @@ -3122,6 +3135,10 @@ public class com/facebook/react/runtime/CoreReactPackage$$ReactModuleInfoProvide
public fun getReactModuleInfos ()Ljava/util/Map;
}

public final class com/facebook/react/runtime/JSCInstance : com/facebook/react/runtime/JSRuntimeFactory {
public fun <init> ()V
}

public abstract class com/facebook/react/runtime/JSRuntimeFactory {
public fun <init> (Lcom/facebook/jni/HybridData;)V
}
Expand Down Expand Up @@ -3236,6 +3253,10 @@ public final class com/facebook/react/soloader/OpenSourceMergedSoMapping : com/f
public final fun libhermes_executor_so ()I
public final fun libhermesinstancejni_so ()I
public final fun libhermestooling_so ()I
public final fun libjscexecutor_so ()I
public final fun libjscinstance_so ()I
public final fun libjscruntime_so ()I
public final fun libjsctooling_so ()I
public final fun libjsijniprofiler_so ()I
public final fun libjsinspector_so ()I
public final fun libmapbufferjni_so ()I
Expand Down
16 changes: 13 additions & 3 deletions packages/react-native/ReactAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ val preparePrefab by
// hermes_executor
// This prefab targets is used by Expo & Reanimated
Pair("../ReactCommon/hermes/inspector-modern/", "hermes/inspector-modern/"),
// jscexecutor
Pair("../ReactCommon/jsc/", "jsc/"),
// fabricjni
Pair("src/main/jni/react/fabric", "react/fabric/"),
// glog
Expand Down Expand Up @@ -234,6 +236,10 @@ val preparePrefab by
"hermestooling",
// hermes_executor
Pair("../ReactCommon/hermes/inspector-modern/", "hermes/inspector-modern/")),
PrefabPreprocessingEntry(
"jsctooling",
// jsc
Pair("../ReactCommon/jsc/", "jsc/")),
))
outputDir.set(prefabHeadersDir)
}
Expand Down Expand Up @@ -528,6 +534,7 @@ android {
"reactnative",
"jsi",
"hermestooling",
"jsctooling",
)
}
}
Expand Down Expand Up @@ -576,9 +583,10 @@ android {
resources.excludes.add("META-INF/LICENSE")
// We intentionally don't want to bundle any JS Runtime inside the Android AAR
// we produce. The reason behind this is that we want to allow users to pick the
// JS engine by specifying a dependency on either `hermes-engine` or other engines
// JS engine by specifying a dependency on either `hermes-engine` or `android-jsc`
// that will include the necessary .so files to load.
jniLibs.excludes.add("**/libhermes.so")
jniLibs.excludes.add("**/libjsc.so")
}

buildFeatures {
Expand All @@ -591,6 +599,7 @@ android {
create("jsi") { headers = File(prefabHeadersDir, "jsi").absolutePath }
create("reactnative") { headers = File(prefabHeadersDir, "reactnative").absolutePath }
create("hermestooling") { headers = File(prefabHeadersDir, "hermestooling").absolutePath }
create("jsctooling") { headers = File(prefabHeadersDir, "jsctooling").absolutePath }
}

publishing {
Expand Down Expand Up @@ -635,9 +644,10 @@ dependencies {
compileOnly(libs.javax.annotation.api)
api(libs.javax.inject)

// It's up to the consumer to decide if hermes or other engines should be included or not.
// Therefore hermes-engine is a compileOnly dependencies.
// It's up to the consumer to decide if hermes/jsc should be included or not.
// Therefore hermes-engine and jsc are compileOnly dependencies.
compileOnly(project(":packages:react-native:ReactAndroid:hermes-engine"))
compileOnly(libs.jsc.android)

testImplementation(libs.junit)
testImplementation(libs.assertj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.common.build.ReactBuildConfig
import com.facebook.react.fabric.ComponentFactory
import com.facebook.react.runtime.BindingsInstaller
import com.facebook.react.runtime.JSCInstance
import com.facebook.react.runtime.JSRuntimeFactory
import com.facebook.react.runtime.ReactHostImpl
import com.facebook.react.runtime.cxxreactpackage.CxxReactPackage
Expand Down Expand Up @@ -207,7 +208,7 @@ public object DefaultReactHost {
jsMainModulePath,
jsBundleAssetPath,
jsBundleFilePath,
HermesInstance(),
if (isHermesEnabled) HermesInstance() else JSCInstance(),
useDevSupport,
cxxReactPackageProviders,
exceptionHandler,
Expand Down Expand Up @@ -263,7 +264,7 @@ public object DefaultReactHost {
jsMainModulePath,
jsBundleAssetPath,
jsBundleFilePath,
HermesInstance(),
if (isHermesEnabled) HermesInstance() else JSCInstance(),
useDevSupport,
cxxReactPackageProviders,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.facebook.react.bridge.UIManagerProvider
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.fabric.ComponentFactory
import com.facebook.react.fabric.FabricUIManagerProviderImpl
import com.facebook.react.runtime.JSCInstance
import com.facebook.react.runtime.JSRuntimeFactory
import com.facebook.react.runtime.hermes.HermesInstance
import com.facebook.react.uimanager.ViewManagerRegistry
Expand Down Expand Up @@ -92,9 +93,6 @@ protected constructor(
* If true, the app will load the Hermes engine, and fail if not found. If false, the app will
* load the JSC engine, and fail if not found.
*/
@Deprecated(
"Setting isHermesEnabled inside `ReactNativeHost` is deprecated and this field will be ignored. If this field is set to true, you can safely remove it. If this field is set to false, please follow the setup on https://github.com/react-native-community/javascriptcore to continue using JSC",
ReplaceWith(""))
protected open val isHermesEnabled: Boolean
get() = true

Expand All @@ -108,7 +106,8 @@ protected constructor(
context: Context,
jsRuntimeFactory: JSRuntimeFactory? = null
): ReactHost {
val concreteJSRuntimeFactory = jsRuntimeFactory ?: HermesInstance()
val concreteJSRuntimeFactory =
jsRuntimeFactory ?: if (isHermesEnabled) HermesInstance() else JSCInstance()
return DefaultReactHost.getDefaultReactHost(
context,
packages,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.jscexecutor

import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStrip
import com.facebook.react.bridge.JavaScriptExecutor
import com.facebook.react.bridge.ReadableNativeMap
import com.facebook.react.common.annotations.internal.LegacyArchitecture
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
import com.facebook.soloader.SoLoader

@DoNotStrip
@LegacyArchitecture
public class JSCExecutor internal constructor(jscConfig: ReadableNativeMap) :
JavaScriptExecutor(initHybrid(jscConfig)) {

override fun getName(): String {
return "JSCExecutor"
}

internal companion object {
init {
loadLibrary()
LegacyArchitectureLogger.assertLegacyArchitecture("JSCExecutor")
}

@JvmStatic
@Throws(UnsatisfiedLinkError::class)
fun loadLibrary() {
SoLoader.loadLibrary("jscexecutor")
}

@JvmStatic private external fun initHybrid(jscConfig: ReadableNativeMap): HybridData
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.jscexecutor

import com.facebook.react.bridge.JavaScriptExecutor
import com.facebook.react.bridge.JavaScriptExecutorFactory
import com.facebook.react.bridge.WritableNativeMap
import com.facebook.react.common.annotations.internal.LegacyArchitecture
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger

@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
public class JSCExecutorFactory(private val appName: String, private val deviceName: String) :
JavaScriptExecutorFactory {

init {
LegacyArchitectureLogger.assertLegacyArchitecture(
"JSCExecutorFactory", LegacyArchitectureLogLevel.ERROR)
}

@Throws(Exception::class)
override fun create(): JavaScriptExecutor {
val jscConfig =
WritableNativeMap().apply {
putString("OwnerIdentity", "ReactNative")
putString("AppIdentity", appName)
putString("DeviceIdentity", deviceName)
}
return JSCExecutor(jscConfig)
}

override fun startSamplingProfiler() {
throw UnsupportedOperationException("Starting sampling profiler not supported on ${toString()}")
}

override fun stopSamplingProfiler(filename: String) {
throw UnsupportedOperationException("Stopping sampling profiler not supported on ${toString()}")
}

override fun toString(): String = "JSIExecutor+JSCRuntime"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.runtime

import com.facebook.jni.HybridData
import com.facebook.jni.annotations.DoNotStrip
import com.facebook.jni.annotations.DoNotStripAny
import com.facebook.soloader.SoLoader

@DoNotStripAny
public class JSCInstance : JSRuntimeFactory(initHybrid()) {
private companion object {
init {
SoLoader.loadLibrary("jscinstance")
}

@DoNotStrip @JvmStatic private external fun initHybrid(): HybridData
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public object OpenSourceMergedSoMapping : ExternalSoMapping {
"jsijniprofiler" -> {
"hermestooling"
}
"jscexecutor",
"jscruntime",
"jscinstance" -> {
"jsctooling"
}
else -> input
}

Expand All @@ -51,6 +56,10 @@ public object OpenSourceMergedSoMapping : ExternalSoMapping {
"hermes_executor" -> libhermes_executor_so()
"hermesinstancejni" -> libhermesinstancejni_so()
"hermestooling" -> libhermestooling_so()
"jscexecutor" -> libjscexecutor_so()
"jscinstance" -> libjscinstance_so()
"jscruntime" -> libjscruntime_so()
"jsctooling" -> libjsctooling_so()
"jsijniprofiler" -> libjsijniprofiler_so()
"jsinspector" -> libjsinspector_so()
"mapbufferjni" -> libmapbufferjni_so()
Expand All @@ -76,6 +85,14 @@ public object OpenSourceMergedSoMapping : ExternalSoMapping {

public external fun libhermestooling_so(): Int

public external fun libjscexecutor_so(): Int

public external fun libjscinstance_so(): Int

public external fun libjscruntime_so(): Int

public external fun libjsctooling_so(): Int

public external fun libjsijniprofiler_so(): Int

public external fun libjsinspector_so(): Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ endfunction()
# Third-party prefabs
find_package(hermes-engine REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)
find_package(jsc-android REQUIRED CONFIG)
add_library(fbjni ALIAS fbjni::fbjni)
add_library(jsc ALIAS jsc-android::jsc)

# Third-party downloaded targets
add_react_third_party_ndk_subdir(glog)
Expand All @@ -69,6 +71,7 @@ add_react_common_subdir(logger)
add_react_common_subdir(jsiexecutor)
add_react_common_subdir(jsitooling)
add_react_common_subdir(cxxreact)
add_react_common_subdir(jsc)
add_react_common_subdir(jsi)
add_react_common_subdir(callinvoker)
add_react_common_subdir(oscompat)
Expand Down Expand Up @@ -137,6 +140,8 @@ add_react_android_subdir(src/main/jni/first-party/yogajni)
add_react_android_subdir(src/main/jni/first-party/jni-lib-merge)
add_react_android_subdir(src/main/jni/react/jni)
add_react_android_subdir(src/main/jni/react/reactperflogger)
add_react_android_subdir(src/main/jni/react/jscexecutor)
add_react_android_subdir(src/main/jni/react/jsctooling)
add_react_android_subdir(src/main/jni/react/turbomodule)
add_react_android_subdir(src/main/jni/react/uimanager)
add_react_android_subdir(src/main/jni/react/mapbuffer)
Expand All @@ -150,6 +155,7 @@ add_react_android_subdir(src/main/jni/react/hermes/instrumentation/)
add_react_android_subdir(src/main/jni/react/runtime/cxxreactpackage)
add_react_android_subdir(src/main/jni/react/runtime/jni)
add_react_android_subdir(src/main/jni/react/runtime/hermes/jni)
add_react_android_subdir(src/main/jni/react/runtime/jsc/jni)
add_react_android_subdir(src/main/jni/react/devsupport)

# SoMerging Utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
# hermestooling is a shared library where we merge all the hermes* related libraries.
#
# It acts as an 'umbrella' library and gets removed by RNGP (see `configureJsEnginePackagingOptions`)
# Please note that this library gets removed for users that opt to use JSC as their JS engine.

add_library(hermestooling
SHARED
Expand Down
Loading
Loading