npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-v8-fix-fresco

v0.63.4-patch.0

Published

Opt-in V8 runtime for React Native Android

Downloads

3

Readme

npm version CircleCI

React Native with V8 Runtime

The aim of this project is to support V8 runtime for React Native. Designed as opt-in package, it should easy to integrate with existing React Native projects.

Integration with React Native

To make RN integration easier, we publish prebuilt AAR into npm.

The versioning is aligned with React Native but suffixed with a -patch.N in version E.g. If your React Native version is 0.60.0, you should use react-native-v8 >=0.60.0-patch.0 <0.60.1.

Following steps will take 0.60.0 as example.

  1. Install react-native-v8
yarn add 'react-native-v8@>=0.60.0-patch.0 <0.60.1'

# [OPTIONAL] If to use different V8 version
# yarn add '[email protected]'
  1. Modify your React Native build.gradle
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -161,11 +161,18 @@ android {
             }
         }
     }
+
+    packagingOptions {
+        // Make sure libjsc.so does not packed in APK
+        exclude "**/libjsc.so"
+    }
 }

 dependencies {
     implementation fileTree(dir: "libs", include: ["*.jar"])
     implementation "com.facebook.react:react-native:+"  // From node_modules
+    // Add v8-android - prebuilt libv8android.so into APK
+    implementation 'org.chromium:v8-android:+'

     // JSC from node_modules
     if (useIntlJsc) {
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -24,8 +24,12 @@ allprojects {
     repositories {
         mavenLocal()
         maven {
-            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
-            url("$rootDir/../node_modules/react-native/android")
+            // Replace AAR from original RN with AAR from react-native-v8
+            url("$rootDir/../node_modules/react-native-v8/dist")
+        }
+        maven {
+            // prebuilt libv8android.so
+            url("$rootDir/../node_modules/v8-android/dist")
         }
         maven {
             // Android JSC is installed from npm
  1. Gradle rebuild or react-native run-android

  2. Start application and could verify by JS global._v8runtime().version which expected to return V8 version.

Builtin JavaScript object

global._v8runtime() has some builtin information such as v8 version.

console.log(`V8 version is ${global._v8runtime().version}`);

Please note that global._v8runtime() existed only for V8 enabled environment but not React Native remote debugging mode. For remote debugging mode, the JavaScript actually runs on Chrome from your host and there is no V8Runtime.

V8 Features Flags

V8 provides many feature flags and the most important one should be JIT. Currently JIT is disabled for V8 lite mode

react-native-v8 use the V8 shared libray from v8-android-buildscripts. For detailed V8 features, please check there.

You can do the following to use one of these features in place of V8 lite mode which is packaged as the default for this repository:

  1. Add v8-android-jit via yarn or npm
$ npm i v8-android-jit
$ yarn add v8-android-jit
  1. Modify the gradle dependency to use v8-android-jit or other variants
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -29,7 +29,7 @@ allprojects {
         }
         maven {
             // prebuilt libv8android.so
-            url("$rootDir/../node_modules/v8-android/dist")
+            url("$rootDir/../node_modules/v8-android-jit/dist")
         }
         maven {
             // Android JSC is installed from npm

This method can also be used to swap to other variants of V8. All possible variants include:

  • v8-android
  • v8-android-nointl
  • v8-android-jit
  • v8-android-jit-nointl

Simply switch out v8-android-jit in the steps provided with the variant that you would like to use.

FAQ

How to reduce APK size ?

The V8 currently bundled by default supports Intl and the ICU data costs about 7MiB per ABI. If you are not going to use Intl, you could use no-Intl version to reduce APK size. (jsc-android and Hermes have no Intl by default)

TODO

  • [x] Performance comparison with JavaScriptCore in React Native

    Please check https://github.com/Kudo/react-native-js-benchmark for the benchmark and result

  • [ ] V8 inspector integration

  • [ ] V8 snapshot integration

  • [ ] V8 code cache experiment