From e8eec24706e792314ee574bbf7f7c0066c4f3a7a Mon Sep 17 00:00:00 2001 From: Alexey Lang Date: Thu, 14 Dec 2017 10:11:40 -0800 Subject: [PATCH] Fix crashing Systrace when debugging JS remotely Reviewed By: fromcelticpark Differential Revision: D6522026 fbshipit-source-id: 11920ecc0133f47314607a0b3431f27027cc9e22 --- React/DevSupport/RCTDevMenu.m | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/React/DevSupport/RCTDevMenu.m b/React/DevSupport/RCTDevMenu.m index 69abab6d5..6e998c78d 100644 --- a/React/DevSupport/RCTDevMenu.m +++ b/React/DevSupport/RCTDevMenu.m @@ -217,6 +217,11 @@ RCT_EXPORT_MODULE() alertControllerWithTitle:@"Remote JS Debugger Unavailable" message:@"You need to include the RCTWebSocket library to enable remote JS debugging" preferredStyle:UIAlertControllerStyleAlert]; + __weak typeof(alertController) weakAlertController = alertController; + [alertController addAction: + [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ + [weakAlertController dismissViewControllerAnimated:YES completion:nil]; + }]]; [RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL]; }]]; } else { @@ -241,7 +246,20 @@ RCT_EXPORT_MODULE() [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ return devSettings.isProfilingEnabled ? @"Stop Systrace" : @"Start Systrace"; } handler:^{ - devSettings.isProfilingEnabled = !devSettings.isProfilingEnabled; + if (devSettings.isDebuggingRemotely) { + UIAlertController *alertController = [UIAlertController + alertControllerWithTitle:@"Systrace Unavailable" + message:@"You need to stop remote JS debugging to enable Systrace" + preferredStyle:UIAlertControllerStyleAlert]; + __weak typeof(alertController) weakAlertController = alertController; + [alertController addAction: + [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ + [weakAlertController dismissViewControllerAnimated:YES completion:nil]; + }]]; + [RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL]; + } else { + devSettings.isProfilingEnabled = !devSettings.isProfilingEnabled; + } }]]; }