From 5f57d87aa3ab5db85c6f8593882908686e018cbd Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Tue, 1 Nov 2016 15:50:47 +0100 Subject: [PATCH] Disable features of `flutter run` that depend on the service protocol when running in release mode (#6571) --- packages/flutter_tools/lib/src/resident_runner.dart | 11 +++++++++++ packages/flutter_tools/lib/src/run.dart | 12 +++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index f8d9fb6010..1932b67e0f 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -28,6 +28,11 @@ abstract class ResidentRunner { final bool usesTerminalUI; final Completer _finished = new Completer(); + bool get isRunningDebug => debuggingOptions.buildMode == BuildMode.debug; + bool get isRunningProfile => debuggingOptions.buildMode == BuildMode.profile; + bool get isRunningRelease => debuggingOptions.buildMode == BuildMode.release; + bool get supportsServiceProtocol => isRunningDebug || isRunningProfile; + VMService vmService; FlutterView currentView; StreamSubscription _loggingSubscription; @@ -72,6 +77,8 @@ abstract class ResidentRunner { await cleanupAfterSignal(); exit(0); }); + if (!supportsServiceProtocol) + return; ProcessSignal.SIGUSR1.watch().listen((ProcessSignal signal) async { printStatus('Caught SIGUSR1'); await restart(fullRestart: false); @@ -130,9 +137,13 @@ abstract class ResidentRunner { printHelp(details: true); return true; } else if (lower == 'w') { + if (!supportsServiceProtocol) + return true; await _debugDumpApp(); return true; } else if (lower == 't') { + if (!supportsServiceProtocol) + return true; await _debugDumpRenderTree(); return true; } else if (lower == 'q' || character == AnsiTerminal.KEY_F10) { diff --git a/packages/flutter_tools/lib/src/run.dart b/packages/flutter_tools/lib/src/run.dart index 216253f331..36374268cd 100644 --- a/packages/flutter_tools/lib/src/run.dart +++ b/packages/flutter_tools/lib/src/run.dart @@ -243,6 +243,8 @@ class RunAndStayResident extends ResidentRunner { Future handleTerminalCommand(String code) async { String lower = code.toLowerCase(); if (lower == 'r' || code == AnsiTerminal.KEY_F5) { + if (!supportsServiceProtocol) + return; if (device.supportsRestart) { // F5, restart await restart(); @@ -263,13 +265,17 @@ class RunAndStayResident extends ResidentRunner { @override void printHelp({ @required bool details }) { - if (!prebuiltMode && device.supportsRestart) + final bool showRestartText = !prebuiltMode && device.supportsRestart && + supportsServiceProtocol; + if (showRestartText) printStatus('To restart the app, press "r" or F5.'); if (_result.hasObservatory) printStatus('The Observatory debugger and profiler is available at: http://127.0.0.1:${_result.observatoryPort}/'); if (details) { - printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".'); - printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "r".'); + if (supportsServiceProtocol) { + printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".'); + printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "r".'); + } printStatus('To repeat this help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.'); } else { printStatus('For a more detailed help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.');