Skip to content

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

@garvsgit

Description

@garvsgit

Description

This is an issue with React Native 0.72.
According to the design of DevSupportManager

/**
* A simple factory that creates instances of {@link DevSupportManager} implementations. Uses
* reflection to create BridgeDevSupportManager if it exists. This allows ProGuard to strip that
* class and its dependencies in release builds. If the class isn't found, {@link
* DisabledDevSupportManager} is returned instead.
*/

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
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
    def enableProguardInReleaseBuilds = false
  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

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