Skip to content
Permalink
Browse files
Remove "Debug with Nuclide" option
Summary: This is no longer needed.

Reviewed By: cpojer

Differential Revision: D20722274

fbshipit-source-id: 5bc3104e90811d724f42aadbf137ab8eff718ca0
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Mar 30, 2020
1 parent 7007df6 commit 011eb4cea5d482cef54d7659e7436a04e539ff19
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 126 deletions.
@@ -249,28 +249,12 @@ - (void)setDefaultJSBundle
} else {
[items addObject:[RCTDevMenuItem
buttonItemWithTitleBlock:^NSString * {
if (devSettings.isNuclideDebuggingAvailable) {
return devSettings.isDebuggingRemotely ? @"Stop Chrome Debugger" : @"Debug with Chrome";
} else {
return devSettings.isDebuggingRemotely ? @"Stop Debugging" : @"Debug";
}
return devSettings.isDebuggingRemotely ? @"Stop Debugging" : @"Debug";
}
handler:^{
devSettings.isDebuggingRemotely = !devSettings.isDebuggingRemotely;
}]];
}

if (devSettings.isNuclideDebuggingAvailable && !devSettings.isDebuggingRemotely) {
[items addObject:[RCTDevMenuItem buttonItemWithTitle:@"Debug with Nuclide"
handler:^{
#if RCT_ENABLE_INSPECTOR
[RCTInspectorDevServerHelper
attachDebugger:@"ReactNative"
withBundleURL:bridge.bundleURL
withView:RCTPresentedViewController()];
#endif
}]];
}
}

[items addObject:[RCTDevMenuItem
@@ -17,7 +17,6 @@

+ (RCTInspectorPackagerConnection *)connectWithBundleURL:(NSURL *)bundleURL;
+ (void)disableDebugger;
+ (void)attachDebugger:(NSString *)owner withBundleURL:(NSURL *)bundleURL withView:(UIViewController *)view;
@end

#endif
@@ -49,24 +49,6 @@
escapedAppName]];
}

static NSURL *getAttachDeviceUrl(NSURL *bundleURL, NSString *title)
{
NSNumber *metroBundlerPort = @8081;
NSString *metroBundlerPortStr = [[[NSProcessInfo processInfo] environment] objectForKey:@"RCT_METRO_PORT"];
if (metroBundlerPortStr && [metroBundlerPortStr length] > 0) {
metroBundlerPort = [NSNumber numberWithInt:[metroBundlerPortStr intValue]];
}
NSString *escapedDeviceName = [[[UIDevice currentDevice] name]
stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier]
stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/attach-debugger-nuclide?title=%@&device=%@&app=%@",
getServerHost(bundleURL, metroBundlerPort),
title,
escapedDeviceName,
escapedAppName]];
}

@implementation RCTInspectorDevServerHelper

RCT_NOT_IMPLEMENTED(-(instancetype)init)
@@ -80,36 +62,6 @@ static void sendEventToAllConnections(NSString *event)
}
}

static void displayErrorAlert(UIViewController *view, NSString *message)
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
message:message
preferredStyle:UIAlertControllerStyleAlert];
[view presentViewController:alert animated:YES completion:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * 2.5), dispatch_get_main_queue(), ^{
[alert dismissViewControllerAnimated:YES completion:nil];
});
}

+ (void)attachDebugger:(NSString *)owner withBundleURL:(NSURL *)bundleURL withView:(UIViewController *)view
{
NSURL *url = getAttachDeviceUrl(bundleURL, owner);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];

__weak UIViewController *viewCapture = view;
[[[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(
__unused NSData *_Nullable data, __unused NSURLResponse *_Nullable response, NSError *_Nullable error) {
UIViewController *viewCaptureStrong = viewCapture;
if (error != nullptr && viewCaptureStrong != nullptr) {
displayErrorAlert(viewCaptureStrong, @"The request to attach Nuclide couldn't reach Metro!");
}
}] resume];
}

+ (void)disableDebugger
{
sendEventToAllConnections(kDebuggerMsgDisable);
@@ -7,13 +7,10 @@

package com.facebook.react.devsupport;

import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.R;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
import com.facebook.react.devsupport.interfaces.PackagerStatusCallback;
@@ -250,36 +247,6 @@ protected Void doInBackground(Void... params) {
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

public void attachDebugger(final Context context, final String title) {
new AsyncTask<Void, String, Boolean>() {
@Override
protected Boolean doInBackground(Void... ignore) {
return doSync();
}

public boolean doSync() {
try {
String attachToNuclideUrl = getInspectorAttachUrl(context, title);
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(attachToNuclideUrl).build();
client.newCall(request).execute();
return true;
} catch (IOException e) {
FLog.e(ReactConstants.TAG, "Failed to send attach request to Inspector", e);
return false;
}
}

@Override
protected void onPostExecute(Boolean result) {
if (!result) {
String message = context.getString(R.string.catalyst_debug_nuclide_error);
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

public void symbolicateStackTrace(
Iterable<StackFrame> stackFrames, final SymbolicationListener listener) {
try {
@@ -370,16 +337,6 @@ private String getInspectorDeviceUrl() {
mPackageName);
}

private String getInspectorAttachUrl(Context context, String title) {
return String.format(
Locale.US,
"http://%s/nuclide/attach-debugger-nuclide?title=%s&app=%s&device=%s",
AndroidInfoHelpers.getServerHost(context),
title,
mPackageName,
AndroidInfoHelpers.getFriendlyDeviceName());
}

public void downloadBundleFromURL(
DevBundleDownloadListener callback,
File outputFile,
@@ -433,30 +433,16 @@ public void onOptionSelected() {
}
});
options.put(
mDevSettings.isNuclideJSDebugEnabled()
? mDevSettings.isRemoteJSDebugEnabled()
? mApplicationContext.getString(R.string.catalyst_debug_chrome_stop)
: mApplicationContext.getString(R.string.catalyst_debug_chrome)
: mDevSettings.isRemoteJSDebugEnabled()
? mApplicationContext.getString(R.string.catalyst_debug_stop)
: mApplicationContext.getString(R.string.catalyst_debug),
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();
}
});
if (mDevSettings.isNuclideJSDebugEnabled()) {
options.put(
mApplicationContext.getString(R.string.catalyst_debug_nuclide),
new DevOptionHandler() {
@Override
public void onOptionSelected() {
mDevServerHelper.attachDebugger(mApplicationContext, "ReactNative");
}
});
}
options.put(
mApplicationContext.getString(R.string.catalyst_change_bundle_location),
new DevOptionHandler() {

0 comments on commit 011eb4c

Please sign in to comment.