Kudo / react-native-v8

Opt-in V8 runtime for React Native Android
MIT License
900 stars 69 forks source link

Slowness on the UI after using react-native-v8 #169

Closed kelvinsantos closed 1 year ago

kelvinsantos commented 1 year ago

Hello,

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

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.

https://user-images.githubusercontent.com/2209204/221777865-ac34dcc4-0825-41de-8d7a-29216e1b878d.mp4

Kudo commented 1 year ago

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.

kelvinsantos commented 1 year ago

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.

affansk commented 1 year ago

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

sunnylqm commented 1 year ago

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

Kudo commented 1 year ago

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

sunnylqm commented 1 year ago

@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: https://github.com/OneKeyHQ/app-monorepo/compare/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 1 year ago

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

sunnylqm commented 1 year ago

@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 1 year ago

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(
kylecesmat commented 1 year ago

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

sunnylqm commented 1 year ago

@Kudo I can confirm v8-android-jit@11.1000.3 is working again 🎉

Kudo commented 1 year ago

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

Kudo commented 11 months ago

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.

agatharejina commented 3 months ago

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.