Bytecode client for Android (#30595)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/30595

Changelog: [Internal]

Add support for loading HBC bundles from Metro in Twilight.
* adds `runtimeBytecodeVersion` to the bundleURL
* adds logic to check chunk hermes bytecode bundles
* adds support for running the bytecode bundles

Reviewed By: cpojer

Differential Revision: D24966992

fbshipit-source-id: acdd03a2e9e2b3e4c29c99c35a7c9136a3a7ef01
This commit is contained in:
Keion Anvaripour
2020-12-16 16:03:57 -08:00
committed by Facebook GitHub Bot
parent 98f1825f56
commit 4537131878
10 changed files with 55 additions and 3 deletions
@@ -40,6 +40,7 @@ rn_android_build_config(
package = "com.facebook.react",
values = [
"boolean IS_INTERNAL_BUILD = true",
"int HERMES_BYTECODE_VERSION = 0",
],
visibility = [
"PUBLIC",
@@ -20,4 +20,5 @@ public class ReactBuildConfig {
public static final boolean DEBUG = BuildConfig.DEBUG;
public static final boolean IS_INTERNAL_BUILD = BuildConfig.IS_INTERNAL_BUILD;
public static final int EXOPACKAGE_FLAGS = BuildConfig.EXOPACKAGE_FLAGS;
public static final int HERMES_BYTECODE_VERSION = BuildConfig.HERMES_BYTECODE_VERSION;
}
@@ -14,6 +14,7 @@ import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
import com.facebook.react.devsupport.interfaces.PackagerStatusCallback;
import com.facebook.react.devsupport.interfaces.StackFrame;
@@ -428,9 +429,13 @@ public class DevServerHelper {
private String createBundleURL(
String mainModuleID, BundleType type, String host, boolean modulesOnly, boolean runModule) {
String runtimeBytecodeVersion =
ReactBuildConfig.HERMES_BYTECODE_VERSION != 0
? "&runtimeBytecodeVersion=" + ReactBuildConfig.HERMES_BYTECODE_VERSION
: "";
return String.format(
Locale.US,
"http://%s/%s.%s?platform=android&dev=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s",
"http://%s/%s.%s?platform=android&dev=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s%s",
host,
mainModuleID,
type.typeID(),
@@ -438,7 +443,8 @@ public class DevServerHelper {
getJSMinifyMode(),
mPackageName,
modulesOnly ? "true" : "false",
runModule ? "true" : "false");
runModule ? "true" : "false",
runtimeBytecodeVersion);
}
private String createBundleURL(String mainModuleID, BundleType type) {