From 3e625a500b21e9fd7e8810467e9fae671a4a0db5 Mon Sep 17 00:00:00 2001 From: richardo2016x Date: Thu, 26 Dec 2024 16:15:06 +0800 Subject: [PATCH] Revert "Revert "feat: use jsc/v8-jit on Android."" This reverts commit dd69e05baabb3f606b93086dcc69c62db93c742d. --- apps/mobile/android/app/build.gradle | 18 +-- .../com/debank/rabbymobile/MainActivity.java | 4 +- .../debank/rabbymobile/MainApplication.java | 14 +++ apps/mobile/android/gradle.properties | 2 +- apps/mobile/package.json | 5 + apps/mobile/src/hooks/useLock.ts | 3 +- apps/mobile/src/setup-app.ts | 5 + yarn.lock | 117 ++++++++++++++++++ 8 files changed, 156 insertions(+), 12 deletions(-) diff --git a/apps/mobile/android/app/build.gradle b/apps/mobile/android/app/build.gradle index b0780cbc2..84bdf7a03 100644 --- a/apps/mobile/android/app/build.gradle +++ b/apps/mobile/android/app/build.gradle @@ -167,14 +167,16 @@ android { } } } - // packagingOptions { - // jniLibs { - // pickFirsts += [ - // 'lib/**/libssl.so', - // 'lib/**/libcrypto.so' - // ] - // } - // } + packagingOptions { + // Make sure libjsc.so does not packed in APK + exclude "**/libjsc.so" + // jniLibs { + // pickFirsts += [ + // 'lib/**/libssl.so', + // 'lib/**/libcrypto.so' + // ] + // } + } } androidComponents { diff --git a/apps/mobile/android/app/src/main/java/com/debank/rabbymobile/MainActivity.java b/apps/mobile/android/app/src/main/java/com/debank/rabbymobile/MainActivity.java index d7462e3bd..28c202d57 100644 --- a/apps/mobile/android/app/src/main/java/com/debank/rabbymobile/MainActivity.java +++ b/apps/mobile/android/app/src/main/java/com/debank/rabbymobile/MainActivity.java @@ -5,8 +5,8 @@ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.defaults.DefaultReactActivityDelegate; -import android.os.Bundle; // react-native-splash-screen -import org.devio.rn.splashscreen.SplashScreen; +import android.os.Bundle; +import org.devio.rn.splashscreen.SplashScreen; // react-native-splash-screen public class MainActivity extends ReactActivity { @Override diff --git a/apps/mobile/android/app/src/main/java/com/debank/rabbymobile/MainApplication.java b/apps/mobile/android/app/src/main/java/com/debank/rabbymobile/MainApplication.java index 98d6e8f72..cfa703351 100644 --- a/apps/mobile/android/app/src/main/java/com/debank/rabbymobile/MainApplication.java +++ b/apps/mobile/android/app/src/main/java/com/debank/rabbymobile/MainApplication.java @@ -5,11 +5,15 @@ import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.defaults.DefaultReactNativeHost; +import com.facebook.react.modules.systeminfo.AndroidInfoHelpers; import com.facebook.soloader.SoLoader; import java.util.List; +import io.csie.kudo.reactnative.v8.executor.V8ExecutorFactory; + import com.facebook.react.views.text.ReactFontManager; import com.facebook.react.modules.network.OkHttpClientProvider; // import androidx.appcompat.app.AppCompatDelegate; @@ -47,6 +51,16 @@ protected boolean isNewArchEnabled() { protected Boolean isHermesEnabled() { return BuildConfig.IS_HERMES_ENABLED; } + + + @Override + protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() { + return new V8ExecutorFactory( + getApplicationContext(), + getPackageName(), + AndroidInfoHelpers.getFriendlyDeviceName(), + getUseDeveloperSupport()); + } }; @Override diff --git a/apps/mobile/android/gradle.properties b/apps/mobile/android/gradle.properties index f4e706629..fb5fa16a2 100644 --- a/apps/mobile/android/gradle.properties +++ b/apps/mobile/android/gradle.properties @@ -41,7 +41,7 @@ newArchEnabled=false # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. -hermesEnabled=true +hermesEnabled=false # Use this property to speed up build time by running multiple Gradle tasks in parallel. org.gradle.parallel=true diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 23bd4c30a..b4bcfa373 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -12,6 +12,8 @@ "build:deps": "yarn ../../ build", "devtools": "react-devtools", "doctor": "react-native doctor", + "vbundle:android": "react-native-bundle-visualizer --platform=android --entry-file=./index.js", + "vbundle:ios": "react-native-bundle-visualizer --platform=ios --entry-file=./index.js", "ensure-git-hooks": "yarn ../../ install-husky", "postinstall": "yarn build:deps && yarn build-inpage", "ios": "react-native run-ios", @@ -163,6 +165,7 @@ "react-native-splash-screen": "^3.3.0", "react-native-svg": "^14.0.0", "react-native-switch": "^1.5.1", + "react-native-v8": "^2.5.1", "react-native-vector-icons": "^10.0.2", "react-native-version-check": "^3.4.7", "react-native-video": "^5.2.1", @@ -176,6 +179,7 @@ "semver": "^7.5.4", "styled-components": "^6.1.1", "use-count-up": "^3.0.1", + "v8-android-jit": "^11.1000.4", "viem": "^2.17.4", "web3": "^4.3.0", "web3-eth-abi": "1.7.0", @@ -215,6 +219,7 @@ "qrcode": "^1.5.3", "react-devtools": "^4.28.5", "react-native-asset": "^2.1.1", + "react-native-bundle-visualizer": "3.1.0", "react-native-svg-transformer": "^1.1.0", "react-native-version": "^4.0.0", "react-test-renderer": "18.2.0", diff --git a/apps/mobile/src/hooks/useLock.ts b/apps/mobile/src/hooks/useLock.ts index 9d6aae21b..528a3465f 100644 --- a/apps/mobile/src/hooks/useLock.ts +++ b/apps/mobile/src/hooks/useLock.ts @@ -60,7 +60,8 @@ export function usePasswordStatus() { } const tryAutoUnlockPromiseRef = { - current: apisLock.tryAutoUnlockRabbyMobileWithUpdateUnlockTime(), + current: (async () => + apisLock.tryAutoUnlockRabbyMobileWithUpdateUnlockTime())(), }; /** diff --git a/apps/mobile/src/setup-app.ts b/apps/mobile/src/setup-app.ts index cf5a27c34..319f363f3 100644 --- a/apps/mobile/src/setup-app.ts +++ b/apps/mobile/src/setup-app.ts @@ -4,6 +4,11 @@ import { setNativeExceptionHandler, } from 'react-native-exception-handler'; import { initSentry } from './core/sentry'; + +if (__DEV__) { + console.debug(`V8 version is ${global._v8runtime().version}`); +} + setJSExceptionHandler((error, isFatal) => { console.debug('setJSExceptionHandler:: error'); console.log(error); diff --git a/yarn.lock b/yarn.lock index 04650edfb..49b3d61de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15592,6 +15592,17 @@ __metadata: languageName: node linkType: hard +"ejs@npm:^3.1.5": + version: 3.1.10 + resolution: "ejs@npm:3.1.10" + dependencies: + jake: ^10.8.5 + bin: + ejs: bin/cli.js + checksum: ce90637e9c7538663ae023b8a7a380b2ef7cc4096de70be85abf5a3b9641912dde65353211d05e24d56b1f242d71185c6d00e02cb8860701d571786d92c71f05 + languageName: node + linkType: hard + "ejs@npm:^3.1.6": version: 3.1.9 resolution: "ejs@npm:3.1.9::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fejs%2F-%2Fejs-3.1.9.tgz" @@ -16040,6 +16051,13 @@ __metadata: languageName: node linkType: hard +"escape-html@npm:^1.0.3": + version: 1.0.3 + resolution: "escape-html@npm:1.0.3" + checksum: 6213ca9ae00d0ab8bccb6d8d4e0a98e76237b2410302cf7df70aaa6591d509a2a37ce8998008cbecae8fc8ffaadf3fb0229535e6a145f3ce0b211d060decbb24 + languageName: node + linkType: hard + "escape-html@npm:~1.0.3": version: 1.0.3 resolution: "escape-html@npm:1.0.3::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fescape-html%2F-%2Fescape-html-1.0.3.tgz" @@ -20472,6 +20490,15 @@ __metadata: languageName: node linkType: hard +"is-wsl@npm:^2.1.1": + version: 2.2.0 + resolution: "is-wsl@npm:2.2.0" + dependencies: + is-docker: ^2.0.0 + checksum: 20849846ae414997d290b75e16868e5261e86ff5047f104027026fd61d8b5a9b0b3ade16239f35e1a067b3c7cc02f70183cb661010ed16f4b6c7c93dad1b19d8 + languageName: node + linkType: hard + "is-wsl@npm:^2.2.0": version: 2.2.0 resolution: "is-wsl@npm:2.2.0::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fis-wsl%2F-%2Fis-wsl-2.2.0.tgz" @@ -25394,6 +25421,16 @@ __metadata: languageName: node linkType: hard +"open@npm:^7.3.1": + version: 7.4.2 + resolution: "open@npm:7.4.2" + dependencies: + is-docker: ^2.0.0 + is-wsl: ^2.1.1 + checksum: 3333900ec0e420d64c23b831bc3467e57031461d843c801f569b2204a1acc3cd7b3ec3c7897afc9dde86491dfa289708eb92bba164093d8bd88fb2c231843c91 + languageName: node + linkType: hard + "open@npm:^8.0.9, open@npm:^8.4.0": version: 8.4.2 resolution: "open@npm:8.4.2::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fopen%2F-%2Fopen-8.4.2.tgz" @@ -27646,6 +27683,7 @@ __metadata: react-native-asset: ^2.1.1 react-native-ble-manager: 8 react-native-ble-plx: 3.1.2 + react-native-bundle-visualizer: 3.1.0 react-native-cloud-storage: ^1.4.1 react-native-collapsible-tab-view: ^6.2.1 react-native-crypto-js: ^1.0.0 @@ -27680,6 +27718,7 @@ __metadata: react-native-svg: ^14.0.0 react-native-svg-transformer: ^1.1.0 react-native-switch: ^1.5.1 + react-native-v8: ^2.5.1 react-native-vector-icons: ^10.0.2 react-native-version: ^4.0.0 react-native-version-check: ^3.4.7 @@ -27702,6 +27741,7 @@ __metadata: ts-toolbelt: ^9.6.0 typescript: 4.8.4 use-count-up: ^3.0.1 + v8-android-jit: ^11.1000.4 viem: ^2.17.4 web3: ^4.3.0 web3-eth-abi: 1.7.0 @@ -28119,6 +28159,22 @@ __metadata: languageName: node linkType: hard +"react-native-bundle-visualizer@npm:3.1.0": + version: 3.1.0 + resolution: "react-native-bundle-visualizer@npm:3.1.0" + dependencies: + chalk: ^4.1.2 + execa: ^5.1.1 + fs-extra: ^10.0.0 + minimist: ^1.2.5 + open: ^8.4.0 + source-map-explorer: ^2.5.2 + bin: + react-native-bundle-visualizer: src/react-native-bundle-visualizer.js + checksum: efddc8218835fdc6c5e9df87a0933ad9e8285e6e104548b619c92ef9daf4617f942ca5801fcda546b9f03f8c8001f164adbef4b1d447aae8a75767f7b2851cf1 + languageName: node + linkType: hard + "react-native-cloud-storage@npm:^1.4.1": version: 1.4.1 resolution: "react-native-cloud-storage@npm:1.4.1" @@ -28668,6 +28724,20 @@ __metadata: languageName: node linkType: hard +"react-native-v8@npm:^2.5.1": + version: 2.5.1 + resolution: "react-native-v8@npm:2.5.1" + dependencies: + semver: ^7.6.2 + peerDependencies: + expo: "*" + peerDependenciesMeta: + expo: + optional: true + checksum: a54759bc783c6fe4672495006b62c0907d95d4e0e9a7455369d380004583ad41c7e82f383c4a476c639823c0f6c40dc16ee0ac8d1cbaf12efb4ae1155b08d871 + languageName: node + linkType: hard + "react-native-vector-icons@npm:^10.0.2": version: 10.0.3 resolution: "react-native-vector-icons@npm:10.0.3::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Freact-native-vector-icons%2F-%2Freact-native-vector-icons-10.0.3.tgz" @@ -30866,6 +30936,29 @@ __metadata: languageName: node linkType: hard +"source-map-explorer@npm:^2.5.2": + version: 2.5.3 + resolution: "source-map-explorer@npm:2.5.3" + dependencies: + btoa: ^1.2.1 + chalk: ^4.1.0 + convert-source-map: ^1.7.0 + ejs: ^3.1.5 + escape-html: ^1.0.3 + glob: ^7.1.6 + gzip-size: ^6.0.0 + lodash: ^4.17.20 + open: ^7.3.1 + source-map: ^0.7.4 + temp: ^0.9.4 + yargs: ^16.2.0 + bin: + sme: bin/cli.js + source-map-explorer: bin/cli.js + checksum: 1d4e619d7eb224f38a3dadfb20eb34a56cfc29bd237b4815b60257e7fe5ee9f791fda3e0bba91318e0f2beffec5cca573abb8b5030a95f305ce4abee93296065 + languageName: node + linkType: hard + "source-map-js@npm:^1.0.1, source-map-js@npm:^1.0.2": version: 1.0.2 resolution: "source-map-js@npm:1.0.2::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fsource-map-js%2F-%2Fsource-map-js-1.0.2.tgz" @@ -30954,6 +31047,13 @@ __metadata: languageName: node linkType: hard +"source-map@npm:^0.7.4": + version: 0.7.4 + resolution: "source-map@npm:0.7.4" + checksum: 01cc5a74b1f0e1d626a58d36ad6898ea820567e87f18dfc9d24a9843a351aaa2ec09b87422589906d6ff1deed29693e176194dc88bcae7c9a852dc74b311dbf5 + languageName: node + linkType: hard + "source-map@npm:^0.8.0-beta.0": version: 0.8.0-beta.0 resolution: "source-map@npm:0.8.0-beta.0::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fsource-map%2F-%2Fsource-map-0.8.0-beta.0.tgz" @@ -32125,6 +32225,16 @@ __metadata: languageName: node linkType: hard +"temp@npm:^0.9.4": + version: 0.9.4 + resolution: "temp@npm:0.9.4" + dependencies: + mkdirp: ^0.5.1 + rimraf: ~2.6.2 + checksum: 8709d4d63278bd309ca0e49e80a268308dea543a949e71acd427b3314cd9417da9a2cc73425dd9c21c6780334dbffd67e05e7be5aaa73e9affe8479afc6f20e3 + languageName: node + linkType: hard + "tempy@npm:^0.6.0": version: 0.6.0 resolution: "tempy@npm:0.6.0::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Ftempy%2F-%2Ftempy-0.6.0.tgz" @@ -33594,6 +33704,13 @@ __metadata: languageName: node linkType: hard +"v8-android-jit@npm:^11.1000.4": + version: 11.1000.4 + resolution: "v8-android-jit@npm:11.1000.4" + checksum: bf3242b5b845bee781fb868dbf4024c0acf597453b2c437edb9c2a9577c1f7febd9dcbf4071a30b77a4c3c8eeff6142b5d37e92f18805003a6315a6c6fb38b69 + languageName: node + linkType: hard + "v8-compile-cache-lib@npm:^3.0.1": version: 3.0.1 resolution: "v8-compile-cache-lib@npm:3.0.1::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fv8-compile-cache-lib%2F-%2Fv8-compile-cache-lib-3.0.1.tgz"