Skip to content

Commit e8eec24

Browse files
alexeylangfacebook-github-bot
authored andcommitted
Fix crashing Systrace when debugging JS remotely
Reviewed By: fromcelticpark Differential Revision: D6522026 fbshipit-source-id: 11920ecc0133f47314607a0b3431f27027cc9e22
1 parent f871d25 commit e8eec24

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

React/DevSupport/RCTDevMenu.m

+19-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ - (void)addItem:(RCTDevMenuItem *)item
217217
alertControllerWithTitle:@"Remote JS Debugger Unavailable"
218218
message:@"You need to include the RCTWebSocket library to enable remote JS debugging"
219219
preferredStyle:UIAlertControllerStyleAlert];
220+
__weak typeof(alertController) weakAlertController = alertController;
221+
[alertController addAction:
222+
[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
223+
[weakAlertController dismissViewControllerAnimated:YES completion:nil];
224+
}]];
220225
[RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL];
221226
}]];
222227
} else {
@@ -241,7 +246,20 @@ - (void)addItem:(RCTDevMenuItem *)item
241246
[items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{
242247
return devSettings.isProfilingEnabled ? @"Stop Systrace" : @"Start Systrace";
243248
} handler:^{
244-
devSettings.isProfilingEnabled = !devSettings.isProfilingEnabled;
249+
if (devSettings.isDebuggingRemotely) {
250+
UIAlertController *alertController = [UIAlertController
251+
alertControllerWithTitle:@"Systrace Unavailable"
252+
message:@"You need to stop remote JS debugging to enable Systrace"
253+
preferredStyle:UIAlertControllerStyleAlert];
254+
__weak typeof(alertController) weakAlertController = alertController;
255+
[alertController addAction:
256+
[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
257+
[weakAlertController dismissViewControllerAnimated:YES completion:nil];
258+
}]];
259+
[RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL];
260+
} else {
261+
devSettings.isProfilingEnabled = !devSettings.isProfilingEnabled;
262+
}
245263
}]];
246264
}
247265

0 commit comments

Comments
 (0)