Skip to content

Commit

Permalink
Remove remote JS debugging (iOS)
Browse files Browse the repository at this point in the history
Summary:
## Context

**Remote JS Debugging removal**

In React Native 0.73, we have deprecated Remote JS Debugging (execution of JavaScript in a separate V8 process) and also removed the Dev Menu launcher (facebook#36754).

This was motivated primarily by the broken state of this feature — in particular: incompatibility with the New Architecture. Secondly, as the React Native team continues to invest in improving debugging, we want to reduce the surface area of debugging modes that we support.

During this year, we reached out to our partners about the impact of removing this feature, and if there was interest in having separate community support for debugging JSC on Android (a limited use case affected by this change). Without strong interest, we concluded that dropping Remote JS Debugging support in core for React Native 0.74 makes sense. We are focusing future debugging efforts into providing a first-class experience for Hermes.

Existing alternatives:

- [Direct debugging for JSC (Safari, iOS only)](https://reactnative.dev/docs/0.71/debugging#safari-developer-tools).
- Direct debugging with Hermes: Flipper, [Chrome (old method)](https://reactnative.dev/docs/0.71/hermes#debugging-js-on-hermes-using-google-chromes-devtools), or via `react-native start --experimental-debugger` (intended future default).

## This diff

This removes remaininng Remote JS Debugging code and `RCTWebSocketExecutor` on iOS.

Changelog: [iOS][Breaking] Remove remote JS debugging capability (JSC projects)

Differential Revision: D50326296
  • Loading branch information
huntie authored and facebook-github-bot committed Oct 19, 2023
1 parent 0a8639c commit 1cdb074
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 450 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Class RCTRedBoxCls(void) __attribute__((used));
Class RCTSourceCodeCls(void) __attribute__((used));
Class RCTStatusBarManagerCls(void) __attribute__((used));
Class RCTTimingCls(void) __attribute__((used));
Class RCTWebSocketExecutorCls(void) __attribute__((used));
Class RCTWebSocketModuleCls(void) __attribute__((used));
Class RCTBlobManagerCls(void) __attribute__((used));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Class RCTCoreModulesClassProvider(const char *name) {
{"SourceCode", RCTSourceCodeCls},
{"StatusBarManager", RCTStatusBarManagerCls},
{"Timing", RCTTimingCls},
{"WebSocketExecutor", RCTWebSocketExecutorCls},
{"WebSocketModule", RCTWebSocketModuleCls},
{"BlobModule", RCTBlobManagerCls},
};
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/React/CoreModules/RCTDevSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
- (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource;

@property (nonatomic, readonly) BOOL isHotLoadingAvailable;
@property (nonatomic, readonly) BOOL isRemoteDebuggingAvailable;
@property (nonatomic, readonly) BOOL isDeviceDebuggingAvailable;
@property (nonatomic, readonly) BOOL isJSCSamplingProfilerAvailable;

Expand Down
75 changes: 1 addition & 74 deletions packages/react-native/React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -176,37 +176,6 @@ - (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource

- (void)initialize
{
#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION
if (self.bridge) {
RCTBridge *__weak weakBridge = self.bridge;
_bridgeExecutorOverrideToken = [[RCTPackagerConnection sharedPackagerConnection]
addNotificationHandler:^(id params) {
if (params != (id)kCFNull && [params[@"debug"] boolValue]) {
weakBridge.executorClass = objc_lookUpClass("RCTWebSocketExecutor");
}
}
queue:dispatch_get_main_queue()
forMethod:@"reload"];
}

if (numInitializedModules++ == 0) {
reloadToken = [[RCTPackagerConnection sharedPackagerConnection]
addNotificationHandler:^(id params) {
RCTTriggerReloadCommandListeners(@"Global hotkey");
}
queue:dispatch_get_main_queue()
forMethod:@"reload"];
#if RCT_DEV_MENU
devMenuToken = [[RCTPackagerConnection sharedPackagerConnection]
addNotificationHandler:^(id params) {
[self.bridge.devMenu show];
}
queue:dispatch_get_main_queue()
forMethod:@"devMenu"];
#endif
}
#endif

#if RCT_ENABLE_INSPECTOR
if (self.bridge) {
// We need this dispatch to the main thread because the bridge is not yet
Expand Down Expand Up @@ -290,15 +259,6 @@ - (BOOL)isDeviceDebuggingAvailable
#endif // RCT_ENABLE_INSPECTOR
}

- (BOOL)isRemoteDebuggingAvailable
{
if (RCTTurboModuleEnabled()) {
return NO;
}
Class jsDebuggingExecutorClass = objc_lookUpClass("RCTWebSocketExecutor");
return (jsDebuggingExecutorClass != nil);
}

- (BOOL)isHotLoadingAvailable
{
if (self.bundleManager.bundleURL) {
Expand Down Expand Up @@ -332,30 +292,6 @@ - (BOOL)isShakeToShowDevMenuEnabled
return [[self settingForKey:kRCTDevSettingShakeToShowDevMenu] boolValue];
}

RCT_EXPORT_METHOD(setIsDebuggingRemotely : (BOOL)enabled)
{
[self _updateSettingWithValue:@(enabled) forKey:kRCTDevSettingIsDebuggingRemotely];
[self _remoteDebugSettingDidChange];
}

- (BOOL)isDebuggingRemotely
{
return [[self settingForKey:kRCTDevSettingIsDebuggingRemotely] boolValue];
}

- (void)_remoteDebugSettingDidChange
{
// This value is passed as a command-line argument, so fall back to reading from NSUserDefaults directly
NSString *executorOverride = [[NSUserDefaults standardUserDefaults] stringForKey:kRCTDevSettingExecutorOverrideClass];
Class executorOverrideClass = executorOverride ? NSClassFromString(executorOverride) : nil;
if (executorOverrideClass) {
self.executorClass = executorOverrideClass;
} else {
BOOL enabled = self.isRemoteDebuggingAvailable && self.isDebuggingRemotely;
self.executorClass = enabled ? objc_getClass("RCTWebSocketExecutor") : nil;
}
}

RCT_EXPORT_METHOD(setProfilingEnabled : (BOOL)enabled)
{
[self _updateSettingWithValue:@(enabled) forKey:kRCTDevSettingProfilingEnabled];
Expand Down Expand Up @@ -450,11 +386,7 @@ - (void)setExecutorClass:(Class)executorClass
{
_executorClass = executorClass;
if (self.bridge.executorClass != executorClass) {
// TODO (6929129): we can remove this special case test once we have better
// support for custom executors in the dev menu. But right now this is
// needed to prevent overriding a custom executor with the default if a
// custom executor has been set directly on the bridge
if (executorClass == Nil && self.bridge.executorClass != objc_lookUpClass("RCTWebSocketExecutor")) {
if (executorClass == Nil) {
return;
}

Expand Down Expand Up @@ -503,7 +435,6 @@ - (void)setupHMRClientWithAdditionalBundleURL:(NSURL *)bundleURL
*/
- (void)_synchronizeAllSettings
{
[self _remoteDebugSettingDidChange];
[self _profilingSettingDidChange];
}

Expand Down Expand Up @@ -563,10 +494,6 @@ - (BOOL)isHotLoadingAvailable
{
return NO;
}
- (BOOL)isRemoteDebuggingAvailable
{
return NO;
}
+ (BOOL)requiresMainQueueSetup
{
return NO;
Expand Down
19 changes: 0 additions & 19 deletions packages/react-native/React/CoreModules/RCTWebSocketExecutor.h

This file was deleted.

Loading

0 comments on commit 1cdb074

Please sign in to comment.