React native for android run very slow when not enable “Debug JS”

后端 未结 5 1531
南旧
南旧 2021-02-05 03:33

I am developing an app using react native, I use some code base for ios and android, the ios version run smoothly.

But the android version run very slowly. the weird thi

相关标签:
5条回答
  • 2021-02-05 03:56

    The reason for different execution speeds of javascript code when running in debug mode and without is that when you are in debug mode, in order to enable the debugging experience React Native executes the code in the Chrome browser on your computer, and the results of the execution are bridged onto the device.

    Outside of the debug mode, the code is executed in the JavaScriptCore engine on the device itself.

    That said, I cannot explain why the execution is so slow on the device. Are you perhaps running on an low-powered device, or an emulator with limited allocated memory?

    0 讨论(0)
  • 2021-02-05 04:00

    React Native app does run slower on Android. But the performance is not real during your development. You can build a release version to check the real performance, release version is much faster than dev version.

    There are also some bad codes which can make your app slow. Like console.log(), it does slow the app during development. Avoid unnecessary re-render the view, don't use arrow function and .bind in render, etc.

    0 讨论(0)
  • 2021-02-05 04:03

    I have the same issue on IOS device (ipad4, ios10). I don't use redux-logger and removed all console.log, still don't know what makes the app so slow. It takes 2s to swich between tabs.

    "react-native": "0.41.2",
    "react": "15.4.2",
    "native-base": "^2.0.10",

    0 讨论(0)
  • 2021-02-05 04:11

    I know it is an old topic but suffered the same problem. I applied the above solutions but the problem still presisted. Later I found out that problem caused by a emulated USB storage device rather than mounted as a USB disk. Because when you upload signed Apk file and install the appllication from this file it causes problems and gives write error e.g. hiddenly but don't gives error messages much. I hope changing from emulated storage device to mounted as a trivial disk helps who suffer the same problem like me.

    0 讨论(0)
  • 2021-02-05 04:19

    Sometimes, one or more than one active console.log() lines cause this issue. console.log lines should be searched and deleted if they exist.

    Also in production, babel-plugin-transform-remove-console can be used to clear all console.* methods automatically.

    0 讨论(0)
提交回复
热议问题