Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevSupport classes included in release build with proguard enabled. Resolves unnecessary usage of BridgeDevSupportManager in DevLoadingModule. #44698

Closed
wants to merge 2 commits into from

Conversation

garvsgit
Copy link

Summary:

Resolves #44682
Intended for React Native 0.72

BridgeDevSupportManager class and its dependencies should be stripped by Proguard in release builds. However, due to the usage of BridgeDevSupportManager in DevLoadingModule this wasn't happening.

Refactored the code to use only the DevSupportManager interface to mitigate the above problem. This is in line with the design pattern here

/**
* 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.
*/

DevSupportManagerBase always creates an instance of DevLoadingViewManager, which is why it need not be initialized again in DevLoadingModule.

This change brings down devsupport package size from ~52KB to ~12KB in release builds with proguard enabled

Also added a missing null check in mDevLoadingViewManager.showMessage() which could cause app crashes in certain cases.
Most of this PR is inspired by #40999 which is already in 0.73-stable

Changelog:

[INTERNAL] [FIXED] - Remove unnecessary usage of BridgeDevSupportManager in DevLoadingModule.

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

Test Plan:

Most of these changes are already live in 0.73. Checked template app release variant dex files in APK analyzer for before and after size comparison. Tested fast refresh capability in debug variant

DevLoadingModule was using BridgeDevSupportManager to initialize DevLoadingViewManager. This meant a lot of devsupport classes were included in the relase APK.
This commit refactors DevLoadingModule to use only the DevSupportManager interface to mitigate the above problem.
DevSupportManagerBase always creates an instance of DevLoadingViewManager, which is why it need not be initialized again in DevLoadingModule.
Removing old related unused methods from BridgeDevSupportManager
Adding a null check on show() in DevLoadingModule which seems to have been missed.
@facebook-github-bot
Copy link
Contributor

Hi @garvsgit!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,463,997 -11,095,050
android hermes armeabi-v7a 7782085 n/a
android hermes x86 8934486 n/a
android hermes x86_64 8795481 n/a
android jsc arm64-v8a 9,123,008 -13,789,752
android jsc armeabi-v7a 8312621 n/a
android jsc x86 9176282 n/a
android jsc x86_64 9434960 n/a

Base commit: a93a15a
Branch: main

@garvsgit garvsgit marked this pull request as draft May 28, 2024 21:51
@garvsgit garvsgit marked this pull request as ready for review May 29, 2024 06:13
@garvsgit garvsgit marked this pull request as draft May 29, 2024 06:14
@garvsgit garvsgit closed this May 29, 2024
@garvsgit garvsgit reopened this Jul 4, 2024
@cortinico
Copy link
Contributor

I don't think we'll accept this one for 0.72 as 72 is end of life. You should update to 0.73 or 0.74 to benefit from the same fix which is already included and battle tested

@cortinico cortinico closed this Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants