Skip to content

DevSupport classes included in release apks (~40KB size impact) due to DevLoadingModule  #44682

Description

@garvsgit

Description

This is an issue with React Native 0.72.
According to the design of DevSupportManager
https://github.com/facebook/react-native/blob/d724007364c4315e2cabace0fc6eae6e6212431d/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevSupportManagerFactory.java#L21-L26
BridgeDevSupportManager class and its dependencies should be stripped by Proguard in release builds, however on inspecting the release APKs with proguard enabled, I found that many DevSupport classes were included. On digging deeper, I found the issue here https://github.com/facebook/react-native/blob/d724007364c4315e2cabace0fc6eae6e6212431d/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/devloading/DevLoadingModule.java#L16
On deleting the usages of DevLoading Module, I found that the unnecessary DevSupport classes were no longer included in the release APKs.

Please look into refactoring DevLoading Module so that it doesn't cause unnecessary bloat in the release APK

Steps to reproduce

  1. npx react-native@0.72.14 init test072App --version 0.72.14
  2. Enable proguard in app/build.gradle https://github.com/facebook/react-native/blob/d724007364c4315e2cabace0fc6eae6e6212431d/packages/react-native/template/android/app/build.gradle#L56
  3. Build and check the classes.dex in APK Analyzer, find unnecessary classes like BridgeDevSupportManager. Total devsupport package size (~52KB), which should be ~14KB (checked when I deleted DevLoadingModule from react-native)

React Native Version

0.72.14

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: Windows 11 10.0.22621
  CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-11300H @ 3.10GHz
  Memory: 3.15 GB / 15.79 GB
Binaries:
  Node:
    version: 18.16.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 9.5.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowAllTrustedApps: Disabled
    Versions:
      - 10.0.19041.0
IDEs:
  Android Studio: AI-221.6008.13.2211.9619390
  Visual Studio:
    - 17.0.32014.148 (Visual Studio Community 2022)
Languages:
  Java: 17.0.1
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.14
    wanted: 0.72.14
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

Check screenshots

Reproducer

https://github.com/garvsgit/test072App

Screenshots and Videos

image

Activity

  1. added
    Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.
    and removed
    Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.
    on May 26, 2024
  2. garvsgit commented on May 26, 2024

    @garvsgit
    Author

    Updated with template reproducer with proguard enabled

  3. cortinico commented on Jun 4, 2024

    @cortinico
    Contributor

    Is this happening on 0.74 also?

  4. github-actions commented on Jun 29, 2024

    @github-actions

    This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

  5. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Jun 29, 2024
  6. garvsgit commented on Jul 4, 2024

    @garvsgit
    Author

    This issue is not present in 0.73 and above. Have re-opened #44698 as a pick-request to 0.72 for the solve

  7. cortinico commented on Jul 4, 2024

    @cortinico
    Contributor

    This issue is not present in 0.73 and above. Have re-opened #44698 as a pick-request to 0.72 for the solve

    Thanks for the investigation @garvsgit
    As this issue is already fixed, what is preventing you from updating to 0.73 or 0.74?
    0.72 is end of life and we limit the pick requests to only extremely necessary picks

  8. garvsgit commented on Jul 4, 2024

    @garvsgit
    Author

    I depend on a few out-of-support packages which do not work well with 0.73 so holding off on an upgrade for now.
    I understand that 0.72 is end of life and this is only a nice to have pick, not a necessary one so I'll be closing this issue and the associated PR.

    Thanks!

  9. added
    Resolution: AnsweredWhen the issue is resolved with a simple answer
    and removed
    Needs: AttentionIssues where the author has responded to feedback.
    on Jul 4, 2024
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

    Resolution: AnsweredWhen the issue is resolved with a simple answerStaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions