Skip to content

Fix for app restart on Android in case of remote debugging#45775

Closed
Sushant-Sardeshpande wants to merge 1 commit into
facebook:mainfrom
Sushant-Sardeshpande:main
Closed

Fix for app restart on Android in case of remote debugging#45775
Sushant-Sardeshpande wants to merge 1 commit into
facebook:mainfrom
Sushant-Sardeshpande:main

Conversation

@Sushant-Sardeshpande
Copy link
Copy Markdown
Contributor

@Sushant-Sardeshpande Sushant-Sardeshpande commented Jul 29, 2024

Added a check in setRemoteJSDebugEnabled in DevSupportManagerBase.java to check for PREFS_REMOTE_JS_DEBUG_KEY to see if the value has changed.

Summary:

Fix for #45399 - App restarting when NativeDevSettings.setIsDebuggingRemotely is used in a landing component. If this was invoked from a component load or action that would fire on app start, it was creating an infinite loop where the app would keep on restart before eventually leading to a crash.

Changelog:

[ANDROID] [FIXED] - Fix issue with NativeDevSettings.setIsDebuggingRemotely where the app would keep on restarting if remote debugging was invoked from an action / component that was called on app start.

Test Plan:

Create a new project using RN CLI.
Set newArchEnabled=false.

Install modules using yarn install.

Build from source for Android by setting the following in settings.gradle-


includeBuild('../node_modules/react-native') {
     dependencySubstitution {
         substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))
         substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))
         substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
         substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
     }
 }

Set the ANDROID_HOME and ANDROID_NDK_HOME environment variables required for react native.
Call NativeDevSettings.setIsDebuggingRemotely from App.tsx which is the landing component.

Test with both hermesEnabled=true and hermesEnabled=false and ensure that app does not keep on restarting after fix.

Added a check in setRemoteJSDebugEnabled in DevSupportManagerBase.java to check for PREFS_REMOTE_JS_DEBUG_KEY to see if the value has changed.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 29, 2024
@react-native-bot
Copy link
Copy Markdown
Collaborator

Fails
🚫

📋 Verify Changelog Format - See Changelog format

Generated by 🚫 dangerJS against e9606af

@Sushant-Sardeshpande Sushant-Sardeshpande marked this pull request as ready for review July 29, 2024 08:47
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 29, 2024
@huntie
Copy link
Copy Markdown
Member

huntie commented Jul 29, 2024

Thanks for this fix!

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@huntie has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Aug 8, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@huntie merged this pull request in beebf4a.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @Sushant-Sardeshpande in beebf4a

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants