From 011eb4cea5d482cef54d7659e7436a04e539ff19 Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Mon, 30 Mar 2020 10:05:59 -0700 Subject: [PATCH] Remove "Debug with Nuclide" option Summary: This is no longer needed. Reviewed By: cpojer Differential Revision: D20722274 fbshipit-source-id: 5bc3104e90811d724f42aadbf137ab8eff718ca0 --- React/CoreModules/RCTDevMenu.mm | 18 +------ .../DevSupport/RCTInspectorDevServerHelper.h | 1 - .../DevSupport/RCTInspectorDevServerHelper.mm | 48 ------------------- .../react/devsupport/DevServerHelper.java | 43 ----------------- .../devsupport/DevSupportManagerBase.java | 20 ++------ 5 files changed, 4 insertions(+), 126 deletions(-) diff --git a/React/CoreModules/RCTDevMenu.mm b/React/CoreModules/RCTDevMenu.mm index f66232cd0c61aa..46a8c55388e392 100644 --- a/React/CoreModules/RCTDevMenu.mm +++ b/React/CoreModules/RCTDevMenu.mm @@ -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 diff --git a/React/DevSupport/RCTInspectorDevServerHelper.h b/React/DevSupport/RCTInspectorDevServerHelper.h index 9cf04a5bdf5acc..c50051bb0f69dc 100644 --- a/React/DevSupport/RCTInspectorDevServerHelper.h +++ b/React/DevSupport/RCTInspectorDevServerHelper.h @@ -17,7 +17,6 @@ + (RCTInspectorPackagerConnection *)connectWithBundleURL:(NSURL *)bundleURL; + (void)disableDebugger; -+ (void)attachDebugger:(NSString *)owner withBundleURL:(NSURL *)bundleURL withView:(UIViewController *)view; @end #endif diff --git a/React/DevSupport/RCTInspectorDevServerHelper.mm b/React/DevSupport/RCTInspectorDevServerHelper.mm index b6c2ac621f9000..7d7212ffbcf30f 100644 --- a/React/DevSupport/RCTInspectorDevServerHelper.mm +++ b/React/DevSupport/RCTInspectorDevServerHelper.mm @@ -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); diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java index c40242077cf4e9..f80ae648404005 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java @@ -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() { - @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 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, diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java index c29483bae32470..249a359230dcc6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java @@ -433,13 +433,9 @@ 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() { @@ -447,16 +443,6 @@ public void onOptionSelected() { 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() {