Skip to content

Commit

Permalink
Move Chrome debugging menu item to BridgeDevSupportManager
Browse files Browse the repository at this point in the history
Summary:
Google Chrome debugging is only supported by the bridge. So, it makes sense to move it to BridgeDevSupportManager.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29031514

fbshipit-source-id: 4d6b6bb3bc298be5fe4d9f96c0d019676fe256db
  • Loading branch information
RSNara authored and facebook-github-bot committed Jun 15, 2021
1 parent 2f943d9 commit 5f2fae0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Expand Up @@ -107,6 +107,22 @@ public void onOptionSelected() {
toggleJSSamplingProfiler();
}
});

if (!getDevSettings().isDeviceDebugEnabled()) {
// For remote debugging, we open up Chrome running the app in a web worker.
// Note that this requires async communication, which will not work for Turbo Modules.
addCustomDevOption(
getDevSettings().isRemoteJSDebugEnabled()
? applicationContext.getString(com.facebook.react.R.string.catalyst_debug_stop)
: applicationContext.getString(com.facebook.react.R.string.catalyst_debug),
new DevOptionHandler() {
@Override
public void onOptionSelected() {
getDevSettings().setRemoteJSDebugEnabled(!getDevSettings().isRemoteJSDebugEnabled());
handleReloadJS();
}
});
}
}

@Override
Expand Down
Expand Up @@ -396,6 +396,7 @@ public void onOptionSelected() {
handleReloadJS();
}
});

if (mDevSettings.isDeviceDebugEnabled()) {
// For on-device debugging we link out to Flipper.
// Since we're assuming Flipper is available, also include the DevTools.
Expand Down Expand Up @@ -428,21 +429,8 @@ public void onOptionSelected() {
mApplicationContext.getString(R.string.catalyst_open_flipper_error));
}
});
} else {
// For remote debugging, we open up Chrome running the app in a web worker.
// Note that this requires async communication, which will not work for Turbo Modules.
options.put(
mDevSettings.isRemoteJSDebugEnabled()
? mApplicationContext.getString(R.string.catalyst_debug_stop)
: mApplicationContext.getString(R.string.catalyst_debug),
new DevOptionHandler() {
@Override
public void onOptionSelected() {
mDevSettings.setRemoteJSDebugEnabled(!mDevSettings.isRemoteJSDebugEnabled());
handleReloadJS();
}
});
}

options.put(
mApplicationContext.getString(R.string.catalyst_change_bundle_location),
new DevOptionHandler() {
Expand Down Expand Up @@ -478,6 +466,7 @@ public void onClick(DialogInterface dialog, int which) {
bundleLocationDialog.show();
}
});

options.put(
// NOTE: `isElementInspectorEnabled` is not guaranteed to be accurate.
mApplicationContext.getString(R.string.catalyst_inspector),
Expand Down

1 comment on commit 5f2fae0

@4332weizi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the user toggles debugging mode, The Custom Dev Option Debug will not change to Stop Debugging until the ReactNativeHost is recreated.

Please sign in to comment.