Skip to content

Support lazy/turbo packages #356

Description

@lithin

Describe the Feature

As described by Ram in his article, Android can greatly benefit from using LazyReactPackage or TurboReactPackage to decrease startup time.

It requires adding annotations to native modules themselves but is also backwards compatible in the sense that if annotation is missing, the module still gets loaded, only not lazily.

From performance perspective, it's also better not to wrap every module in its own package - instead of nesting them, we can only have one package to wrap all native modules.

Possible Implementations

As part of the work on react-native config, we could update the MainApplication.java changes to include only one TurboReactPackage with all native modules in it.

Activity

  1. janicduplessis commented on Aug 3, 2019

    @janicduplessis
    Contributor

    Here's what the generated code should look like: https://gist.github.com/janicduplessis/6256d4bda0a59dd345654dacae106ea2.

    Also this confirms that the approach of using a single TurboReactPackage is right https://twitter.com/nparashuram/status/1157483387864489984.

    Instead of adding a package per module we should add all native modules and view managers from each linked library to a single TurboReactPackage. We might need a way for libs to declare view manager and native modules classes. For native modules it could be possible to find them by checking for the @ReactModule annotation. For view managers this might be more complex since there is no annotation and we'd have to follow the inheritance chain to find if a class is a subclass of ViewManager.

  2. sbearben commented on Dec 29, 2019

    @sbearben

    @janicduplessis thank you for sharing that gist! From the twitter thread regarding using ReactModuleSpecProcessor:

    Actually it looks super easy to do, just need to tell the java compiler where the annotation processor is

    Can you explain how you did this with gradle?

  3. github-actions commented on Dec 1, 2022

    @github-actions

    There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

  4. added
    no-stale-botThis issue cannot be marked as stale by stale bot
    and removed on Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions