DevSupport classes included in release apks (~40KB size impact) due to DevLoadingModule
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
- npx [email protected] init test072App --version 0.72.14
- Enable proguard in app/build.gradle https://github.com/facebook/react-native/blob/d724007364c4315e2cabace0fc6eae6e6212431d/packages/react-native/template/android/app/build.gradle#L56
- 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
Updated with template reproducer with proguard enabled
Is this happening on 0.74 also?
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
This issue is not present in 0.73 and above. Have re-opened #44698 as a pick-request to 0.72 for the solve
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
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!