Kudo/react-native-v8

Slowness on the UI after using react-native-v8

kelvinsantos opened this issue ยท 14 comments

Hello,

I tried to integrate react-native-v8 into our react native expo application, details as follows:

  • react:18.2.0
  • react-native:0.71.3
  • react-native-v8:2.0.0
  • v8-android-jit:11.110.1
  • expo:48.0.4

But after the build and confirmed that our app is running v8. The UI/UX got so laggy.
But the performance of the app has been significantly better. Please let me know if there is anything that we can do.

Screen_Recording_20230228_153949_CRDZ.mp4
Kudo commented

hi there! could you create a repro for me to further investigate? i was thinking whether this comes from react-native upgrade, or v8 upgrade.

hi @Kudo, I found out the issue already! With my project I have the "react-native-reanimated": "~2.14.4", which caused the slowness to the application.

Hi @Kudo its very slow i have the latest version of reanimated "^3.0.2" and react native 0.71.5

same issue. working fine if switch back to "jsc-android": "^294992.0.0"

Kudo commented

is that reanimated 3 + v8 only? would be good if someone could share a repro project.

@Kudo

v8 + reanimated2:
https://github.com/OneKeyHQ/app-monorepo/tree/feat/rn71-expo48-v8

hermes + reanimated2:
https://github.com/OneKeyHQ/app-monorepo/tree/feat/rn71-expo48

the diff:
OneKeyHQ/app-monorepo@feat/rn71-expo48...feat/rn71-expo48-v8

it's a complicated monorepo and there are some issues with the new metro, so please run yarn native first in workspace root folder and open a new terminal to run yarn android. And you may need to uninstall the app before switching to another engine (guess maybe related to realm database?)

Kudo commented

great repro, thanks @sunnylqm!
it turns out the performance regression is coming from v8 upgrade and i've tried to address on Kudo/v8-android-buildscripts#36. could you try to upgrade v8-android-jit@^11.110.3 and check whether it improves the performance for you?

@Kudo Thanks for looking into this. I just tried v8-android-jit@^11.110.3 but unfortunately it seems even worse (took minutes to boot and got lots of unresponsive warnings)

Kudo commented

having no idea in the meantime but only to downgrade v8 for original version 10.0.139.9.
published v8-android-jit@11.1000.3 and that requires a patch to react-native-v8.
not get a chance to test on @sunnylqm's repo but updates here. hopes someone could help to verify this.

--- a/node_modules/react-native-v8/src/v8runtime/V8Inspector.cpp
+++ b/node_modules/react-native-v8/src/v8runtime/V8Inspector.cpp
@@ -150,8 +150,7 @@ InspectorClient::InspectorClient(
   session_ = inspector_->connect(
       contextGroupId,
       channel_.get(),
-      inspectorNameStringView,
-      v8_inspector::V8Inspector::kFullyTrusted);
+      inspectorNameStringView);
   context_.Reset(isolate_, context);

   inspector_->contextCreated(v8_inspector::V8ContextInfo(

@Kudo this change works great! No more performance issues noted after applyingv8-android-jit@11.1000.3

@Kudo I can confirm v8-android-jit@11.1000.3 is working again ๐ŸŽ‰

Kudo commented

setting v8-android-jit@11.1000.3 as latest and published react-native-v8@2.2.0 with the support without patch-package.

i'm sorry that previous version was still built by NDK r21. please upgrade v8-android-jit@11.1000.4 to have the correct NDK r23 build.

hi @Kudo, I found out the issue already! With my project I have the "react-native-reanimated": "~2.14.4", which caused the slowness to the application.

hi @kelvinsantos ! May I know which version of the react-native-reanimated that you upgraded? i'm also having the same issue.