Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrease startup time on React Native Android applications

I'm currently down the path of trying to figure out how to decrease Android startup time. It hasn't been an issue with iOS but for Android, I'm seeing anywhere from 6-10 seconds. The goal is to be around 3-4 seconds.

Here's a summary of the research I've come across

  • createReactContext: where the react bridge gets initialized and starts loading all the native modules
  • getMethodDescriptors: using reflection it compiles (run-time) a list of all exposed methods using ReactMethod

Solutions exist but not perfect:

  1. LazyReactPackage (Experimental) https://github.com/facebook/react-native/commit/797ca6c219b2a44f88f10c61d91e8cc21e2f306e
  2. Removing reflection for all exposed ReactMethods https://github.com/facebook/react-native/pull/10084

My problem with these solutions is around using annotation processing to generate classes (compile time). I'm trying to figure out how to get these solutions running with no luck.

Also, other suggestions around decreasing startup time for Android would be helpful.

Thanks!

like image 513
howdy_miguel Avatar asked Dec 06 '17 17:12

howdy_miguel


1 Answers

For this Facebook has released their new build mechanism Hermes which will increase the speed of your startup time. But you need react native 0.60> to use this engine. https://facebook.github.io/react-native/blog/2019/07/17/hermes

like image 191
Asela Wijesinghe Avatar answered Oct 06 '22 00:10

Asela Wijesinghe