Skip to content

Commit

Permalink
Fix crashing Systrace when debugging JS remotely
Browse files Browse the repository at this point in the history
Reviewed By: fromcelticpark

Differential Revision: D6522026

fbshipit-source-id: 11920ecc0133f47314607a0b3431f27027cc9e22
  • Loading branch information
alexeylang authored and facebook-github-bot committed Dec 14, 2017
1 parent f871d25 commit e8eec24
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion React/DevSupport/RCTDevMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ - (void)addItem:(RCTDevMenuItem *)item
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 {
Expand All @@ -241,7 +246,20 @@ - (void)addItem:(RCTDevMenuItem *)item
[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;
}
}]];
}

Expand Down

0 comments on commit e8eec24

Please sign in to comment.