Unverified Commit d01de941 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Revert "Support --fast-start for Android applications (as an opt-in) (#45431)" (#46138)

This reverts commit 2a113165.
parent 2a113165
...@@ -273,13 +273,6 @@ Future<void> _runToolTests() async { ...@@ -273,13 +273,6 @@ Future<void> _runToolTests() async {
await selectSubshard(subshards); await selectSubshard(subshards);
} }
// Example apps that should not be built by _runBuildTests`
const List<String> _excludedExampleApplications = <String>[
// This application contains no platform code and cannot be built, except for
// as a part of a '--fast-start' Android application.
'splash',
];
/// Verifies that AOT, APK, and IPA (if on macOS) builds the examples apps /// Verifies that AOT, APK, and IPA (if on macOS) builds the examples apps
/// without crashing. It does not actually launch the apps. That happens later /// without crashing. It does not actually launch the apps. That happens later
/// in the devicelab. This is just a smoke-test. In particular, this will verify /// in the devicelab. This is just a smoke-test. In particular, this will verify
...@@ -291,9 +284,6 @@ Future<void> _runBuildTests() async { ...@@ -291,9 +284,6 @@ Future<void> _runBuildTests() async {
if (fileEntity is! Directory) { if (fileEntity is! Directory) {
continue; continue;
} }
if (_excludedExampleApplications.any(fileEntity.path.endsWith)) {
continue;
}
final String examplePath = fileEntity.path; final String examplePath = fileEntity.path;
await _flutterBuildAot(examplePath); await _flutterBuildAot(examplePath);
await _flutterBuildApk(examplePath); await _flutterBuildApk(examplePath);
...@@ -766,7 +756,6 @@ Future<void> _runHostOnlyDeviceLabTests() async { ...@@ -766,7 +756,6 @@ Future<void> _runHostOnlyDeviceLabTests() async {
if (Platform.isMacOS) () => _runDevicelabTest('flutter_create_offline_test_mac'), if (Platform.isMacOS) () => _runDevicelabTest('flutter_create_offline_test_mac'),
if (Platform.isLinux) () => _runDevicelabTest('flutter_create_offline_test_linux'), if (Platform.isLinux) () => _runDevicelabTest('flutter_create_offline_test_linux'),
if (Platform.isWindows) () => _runDevicelabTest('flutter_create_offline_test_windows'), if (Platform.isWindows) () => _runDevicelabTest('flutter_create_offline_test_windows'),
() => _runDevicelabTest('gradle_fast_start_test', environment: gradleEnvironment),
// TODO(ianh): Fails on macOS looking for "dexdump", https://github.com/flutter/flutter/issues/42494 // TODO(ianh): Fails on macOS looking for "dexdump", https://github.com/flutter/flutter/issues/42494
if (!Platform.isMacOS) () => _runDevicelabTest('gradle_jetifier_test', environment: gradleEnvironment), if (!Platform.isMacOS) () => _runDevicelabTest('gradle_jetifier_test', environment: gradleEnvironment),
() => _runDevicelabTest('gradle_non_android_plugin_test', environment: gradleEnvironment), () => _runDevicelabTest('gradle_non_android_plugin_test', environment: gradleEnvironment),
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/framework/apk_utils.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
Future<void> main() async {
await task(() async {
try {
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleDebug with --fast-start');
await pluginProject.runGradleTask('assembleDebug',
options: <String>['-Pfast-start=true']);
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath);
checkCollectionContains<String>(<String>[
...debugAssets,
...baseApkFiles,
'lib/x86/libflutter.so',
'lib/x86_64/libflutter.so',
'lib/armeabi-v7a/libflutter.so',
'lib/arm64-v8a/libflutter.so',
], apkFiles);
checkCollectionDoesNotContain<String>(<String>[
...flutterAssets,
], apkFiles);
});
return TaskResult.success(null);
} on TaskResult catch (taskResult) {
return taskResult;
} catch (e) {
return TaskResult.failure(e.toString());
}
});
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
void main() {
runApp(
const DecoratedBox(
decoration: BoxDecoration(color: Colors.white),
child: Center(
child: FlutterLogo(size: 48),
),
),
);
}
name: splash
environment:
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
meta: 1.1.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies:
flutter_test:
sdk: flutter
archive: 2.0.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
args: 1.5.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
async: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 2.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
image: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
matcher: 0.12.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
path: 1.6.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pedantic: 1.8.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
petitparser: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
quiver: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
string_scanner: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
test_api: 0.2.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
xml: 3.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: f789
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:splash/main.dart' as entrypoint;
void main() {
testWidgets('Displays flutter logo', (WidgetTester tester) async {
entrypoint.main();
expect(find.byType(FlutterLogo), findsOneWidget);
});
}
...@@ -472,15 +472,6 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -472,15 +472,6 @@ class FlutterPlugin implements Plugin<Project> {
return false return false
} }
/// Whether to build the debug app in "fast-start" mode.
private Boolean isFastStart() {
if (project.hasProperty("fast-start")) {
return project.property("fast-start").toBoolean()
}
return false
}
private static Boolean shouldShrinkResources(Project project) { private static Boolean shouldShrinkResources(Project project) {
if (project.hasProperty("shrink")) { if (project.hasProperty("shrink")) {
return project.property("shrink").toBoolean() return project.property("shrink").toBoolean()
...@@ -619,7 +610,6 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -619,7 +610,6 @@ class FlutterPlugin implements Plugin<Project> {
localEngineSrcPath this.localEngineSrcPath localEngineSrcPath this.localEngineSrcPath
targetPath target targetPath target
verbose isVerbose() verbose isVerbose()
fastStart isFastStart()
fileSystemRoots fileSystemRootsValue fileSystemRoots fileSystemRootsValue
fileSystemScheme fileSystemSchemeValue fileSystemScheme fileSystemSchemeValue
trackWidgetCreation trackWidgetCreationValue trackWidgetCreation trackWidgetCreationValue
...@@ -739,8 +729,6 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -739,8 +729,6 @@ abstract class BaseFlutterTask extends DefaultTask {
String localEngine String localEngine
String localEngineSrcPath String localEngineSrcPath
@Input @Input
Boolean fastStart
@Input
String targetPath String targetPath
@Optional @Optional
Boolean verbose Boolean verbose
...@@ -781,13 +769,9 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -781,13 +769,9 @@ abstract class BaseFlutterTask extends DefaultTask {
// cache. // cache.
String[] ruleNames; String[] ruleNames;
if (buildMode == "debug") { if (buildMode == "debug") {
if (fastStart) { ruleNames = ["debug_android_application"]
ruleNames = ["faststart_android_application"]
} else {
ruleNames = ["debug_android_application"]
}
} else { } else {
ruleNames = targetPlatformValues.collect { "android_aot_bundle_${buildMode}_$it" } ruleNames = targetPlatformValues.collect { "android_aot_bundle_${buildMode}_$it" }
} }
project.exec { project.exec {
executable flutterExecutable.absolutePath executable flutterExecutable.absolutePath
...@@ -804,11 +788,7 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -804,11 +788,7 @@ abstract class BaseFlutterTask extends DefaultTask {
args "assemble" args "assemble"
args "--depfile", "${intermediateDir}/flutter_build.d" args "--depfile", "${intermediateDir}/flutter_build.d"
args "--output", "${intermediateDir}" args "--output", "${intermediateDir}"
if (!fastStart || buildMode != "debug") { args "-dTargetFile=${targetPath}"
args "-dTargetFile=${targetPath}"
} else {
args "-dTargetFile=${Paths.get(flutterRoot.absolutePath, "examples", "splash", "lib", "main.dart")}"
}
args "-dTargetPlatform=android" args "-dTargetPlatform=android"
args "-dBuildMode=${buildMode}" args "-dBuildMode=${buildMode}"
if (extraFrontEndOptions != null) { if (extraFrontEndOptions != null) {
......
...@@ -527,7 +527,6 @@ class AndroidDevice extends Device { ...@@ -527,7 +527,6 @@ class AndroidDevice extends Device {
androidBuildInfo: AndroidBuildInfo( androidBuildInfo: AndroidBuildInfo(
debuggingOptions.buildInfo, debuggingOptions.buildInfo,
targetArchs: <AndroidArch>[androidArch], targetArchs: <AndroidArch>[androidArch],
fastStart: debuggingOptions.fastStart
), ),
); );
// Package has been built, so we can get the updated application ID and // Package has been built, so we can get the updated application ID and
...@@ -644,9 +643,6 @@ class AndroidDevice extends Device { ...@@ -644,9 +643,6 @@ class AndroidDevice extends Device {
@override @override
bool get supportsHotRestart => true; bool get supportsHotRestart => true;
@override
bool get supportsFastStart => true;
@override @override
Future<bool> stopApp(AndroidApk app) { Future<bool> stopApp(AndroidApk app) {
final List<String> command = adbCommandForDevice(<String>['shell', 'am', 'force-stop', app.id]); final List<String> command = adbCommandForDevice(<String>['shell', 'am', 'force-stop', app.id]);
......
...@@ -331,9 +331,6 @@ Future<void> buildGradleApp({ ...@@ -331,9 +331,6 @@ Future<void> buildGradleApp({
// Don't use settings.gradle from the current project since it includes the plugins as subprojects. // Don't use settings.gradle from the current project since it includes the plugins as subprojects.
command.add('--settings-file=settings_aar.gradle'); command.add('--settings-file=settings_aar.gradle');
} }
if (androidBuildInfo.fastStart) {
command.add('-Pfast-start=true');
}
command.add(assembleTask); command.add(assembleTask);
GradleHandledError detectedGradleError; GradleHandledError detectedGradleError;
......
...@@ -103,7 +103,6 @@ class AndroidBuildInfo { ...@@ -103,7 +103,6 @@ class AndroidBuildInfo {
], ],
this.splitPerAbi = false, this.splitPerAbi = false,
this.shrink = false, this.shrink = false,
this.fastStart = false,
}); });
// The build info containing the mode and flavor. // The build info containing the mode and flavor.
...@@ -121,9 +120,6 @@ class AndroidBuildInfo { ...@@ -121,9 +120,6 @@ class AndroidBuildInfo {
/// The target platforms for the build. /// The target platforms for the build.
final Iterable<AndroidArch> targetArchs; final Iterable<AndroidArch> targetArchs;
/// Whether to bootstrap an empty application.
final bool fastStart;
} }
/// A summary of the compilation strategy used for Dart. /// A summary of the compilation strategy used for Dart.
......
...@@ -423,7 +423,7 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner { ...@@ -423,7 +423,7 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner {
@override @override
Future<OperationResult> restart({ Future<OperationResult> restart({
bool fullRestart = false, bool fullRestart = false,
bool pause = false, bool pauseAfterRestart = false,
String reason, String reason,
bool benchmarkMode = false, bool benchmarkMode = false,
}) async { }) async {
...@@ -692,7 +692,7 @@ class _DwdsResidentWebRunner extends ResidentWebRunner { ...@@ -692,7 +692,7 @@ class _DwdsResidentWebRunner extends ResidentWebRunner {
@override @override
Future<OperationResult> restart({ Future<OperationResult> restart({
bool fullRestart = false, bool fullRestart = false,
bool pause = false, bool pauseAfterRestart = false,
String reason, String reason,
bool benchmarkMode = false, bool benchmarkMode = false,
}) async { }) async {
......
...@@ -31,13 +31,10 @@ abstract class AndroidAssetBundle extends Target { ...@@ -31,13 +31,10 @@ abstract class AndroidAssetBundle extends Target {
List<Source> get outputs => const <Source>[]; List<Source> get outputs => const <Source>[];
@override @override
List<String> get depfiles => <String>[ List<String> get depfiles => const <String>[
if (_copyAssets) 'flutter_assets.d',
'flutter_assets.d',
]; ];
bool get _copyAssets => true;
@override @override
Future<void> build(Environment environment) async { Future<void> build(Environment environment) async {
if (environment.defines[kBuildMode] == null) { if (environment.defines[kBuildMode] == null) {
...@@ -59,10 +56,8 @@ abstract class AndroidAssetBundle extends Target { ...@@ -59,10 +56,8 @@ abstract class AndroidAssetBundle extends Target {
fs.file(isolateSnapshotData) fs.file(isolateSnapshotData)
.copySync(outputDirectory.childFile('isolate_snapshot_data').path); .copySync(outputDirectory.childFile('isolate_snapshot_data').path);
} }
if (_copyAssets) { final Depfile assetDepfile = await copyAssets(environment, outputDirectory);
final Depfile assetDepfile = await copyAssets(environment, outputDirectory); assetDepfile.writeToFile(environment.buildDir.childFile('flutter_assets.d'));
assetDepfile.writeToFile(environment.buildDir.childFile('flutter_assets.d'));
}
} }
@override @override
...@@ -95,17 +90,6 @@ class DebugAndroidApplication extends AndroidAssetBundle { ...@@ -95,17 +90,6 @@ class DebugAndroidApplication extends AndroidAssetBundle {
]; ];
} }
/// A minimal android application that does not include assets.
class FastStartAndroidApplication extends DebugAndroidApplication {
const FastStartAndroidApplication();
@override
String get name => 'faststart_android_application';
@override
bool get _copyAssets => false;
}
/// An implementation of [AndroidAssetBundle] that only includes assets. /// An implementation of [AndroidAssetBundle] that only includes assets.
class AotAndroidAssetBundle extends AndroidAssetBundle { class AotAndroidAssetBundle extends AndroidAssetBundle {
const AotAndroidAssetBundle(); const AotAndroidAssetBundle();
......
...@@ -37,7 +37,6 @@ const List<Target> _kDefaultTargets = <Target>[ ...@@ -37,7 +37,6 @@ const List<Target> _kDefaultTargets = <Target>[
DebugBundleLinuxAssets(), DebugBundleLinuxAssets(),
WebReleaseBundle(), WebReleaseBundle(),
DebugAndroidApplication(), DebugAndroidApplication(),
FastStartAndroidApplication(),
ProfileAndroidApplication(), ProfileAndroidApplication(),
ReleaseAndroidApplication(), ReleaseAndroidApplication(),
// These are one-off rules for bundle and aot compat // These are one-off rules for bundle and aot compat
......
...@@ -577,7 +577,7 @@ class AppDomain extends Domain { ...@@ -577,7 +577,7 @@ class AppDomain extends Domain {
} }
_inProgressHotReload = app._runInZone<OperationResult>(this, () { _inProgressHotReload = app._runInZone<OperationResult>(this, () {
return app.restart(fullRestart: fullRestart, pause: pauseAfterRestart, reason: restartReason); return app.restart(fullRestart: fullRestart, pauseAfterRestart: pauseAfterRestart, reason: restartReason);
}); });
return _inProgressHotReload.whenComplete(() { return _inProgressHotReload.whenComplete(() {
_inProgressHotReload = null; _inProgressHotReload = null;
...@@ -922,8 +922,8 @@ class AppInstance { ...@@ -922,8 +922,8 @@ class AppInstance {
_AppRunLogger _logger; _AppRunLogger _logger;
Future<OperationResult> restart({ bool fullRestart = false, bool pause = false, String reason }) { Future<OperationResult> restart({ bool fullRestart = false, bool pauseAfterRestart = false, String reason }) {
return runner.restart(fullRestart: fullRestart, pause: pause, reason: reason); return runner.restart(fullRestart: fullRestart, pauseAfterRestart: pauseAfterRestart, reason: reason);
} }
Future<void> stop() => runner.exit(); Future<void> stop() => runner.exit();
......
...@@ -187,14 +187,6 @@ class RunCommand extends RunCommandBase { ...@@ -187,14 +187,6 @@ class RunCommand extends RunCommandBase {
hide: true, hide: true,
help: 'Whether to automatically invoke webOnlyInitializePlatform.', help: 'Whether to automatically invoke webOnlyInitializePlatform.',
) )
..addFlag('fast-start',
negatable: true,
defaultsTo: false,
hide: true,
help: 'Whether to quickly bootstrap applications with a minimal app. '
'Currently this is only supported on Android devices. This option '
'cannot be paired with --use-application-binary.'
)
..addOption(FlutterOptions.kExtraFrontEndOptions, hide: true) ..addOption(FlutterOptions.kExtraFrontEndOptions, hide: true)
..addOption(FlutterOptions.kExtraGenSnapshotOptions, hide: true) ..addOption(FlutterOptions.kExtraGenSnapshotOptions, hide: true)
..addMultiOption(FlutterOptions.kEnableExperiment, ..addMultiOption(FlutterOptions.kEnableExperiment,
...@@ -292,9 +284,6 @@ class RunCommand extends RunCommandBase { ...@@ -292,9 +284,6 @@ class RunCommand extends RunCommandBase {
if (!runningWithPrebuiltApplication) { if (!runningWithPrebuiltApplication) {
await super.validateCommand(); await super.validateCommand();
} }
if (boolArg('fast-start') && runningWithPrebuiltApplication) {
throwToolExit('--fast-start is not supported with --use-application-binary');
}
if (deviceManager.hasSpecifiedAllDevices && runningWithPrebuiltApplication) { if (deviceManager.hasSpecifiedAllDevices && runningWithPrebuiltApplication) {
throwToolExit('Using -d all with --use-application-binary is not supported'); throwToolExit('Using -d all with --use-application-binary is not supported');
} }
...@@ -329,9 +318,6 @@ class RunCommand extends RunCommandBase { ...@@ -329,9 +318,6 @@ class RunCommand extends RunCommandBase {
hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '', hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '',
port: featureFlags.isWebEnabled ? stringArg('web-port') : '', port: featureFlags.isWebEnabled ? stringArg('web-port') : '',
vmserviceOutFile: stringArg('vmservice-out-file'), vmserviceOutFile: stringArg('vmservice-out-file'),
// Allow forcing fast-start to off to prevent doing more work on devices that
// don't support it.
fastStart: boolArg('fast-start') && devices.every((Device device) => device.supportsFastStart),
); );
} }
} }
...@@ -399,12 +385,6 @@ class RunCommand extends RunCommandBase { ...@@ -399,12 +385,6 @@ class RunCommand extends RunCommandBase {
} }
for (Device device in devices) { for (Device device in devices) {
if (!device.supportsFastStart && boolArg('fast-start')) {
printStatus(
'Using --fast-start option with device ${device.name}, but this device '
'does not support it. Overriding the setting to false.'
);
}
if (await device.isLocalEmulator) { if (await device.isLocalEmulator) {
if (await device.supportsHardwareRendering) { if (await device.supportsHardwareRendering) {
final bool enableSoftwareRendering = boolArg('enable-software-rendering') == true; final bool enableSoftwareRendering = boolArg('enable-software-rendering') == true;
......
...@@ -420,9 +420,6 @@ abstract class Device { ...@@ -420,9 +420,6 @@ abstract class Device {
/// application. /// application.
bool get supportsScreenshot => false; bool get supportsScreenshot => false;
/// Whether the device supports the '--fast-start' development mode.
bool get supportsFastStart => false;
/// Stop an app package on the current device. /// Stop an app package on the current device.
Future<bool> stopApp(covariant ApplicationPackage app); Future<bool> stopApp(covariant ApplicationPackage app);
...@@ -537,7 +534,6 @@ class DebuggingOptions { ...@@ -537,7 +534,6 @@ class DebuggingOptions {
this.hostname, this.hostname,
this.port, this.port,
this.vmserviceOutFile, this.vmserviceOutFile,
this.fastStart = false,
}) : debuggingEnabled = true; }) : debuggingEnabled = true;
DebuggingOptions.disabled(this.buildInfo, { this.initializePlatform = true, this.port, this.hostname, this.cacheSkSL = false, }) DebuggingOptions.disabled(this.buildInfo, { this.initializePlatform = true, this.port, this.hostname, this.cacheSkSL = false, })
...@@ -554,8 +550,7 @@ class DebuggingOptions { ...@@ -554,8 +550,7 @@ class DebuggingOptions {
verboseSystemLogs = false, verboseSystemLogs = false,
hostVmServicePort = null, hostVmServicePort = null,
deviceVmServicePort = null, deviceVmServicePort = null,
vmserviceOutFile = null, vmserviceOutFile = null;
fastStart = false;
final bool debuggingEnabled; final bool debuggingEnabled;
...@@ -579,7 +574,6 @@ class DebuggingOptions { ...@@ -579,7 +574,6 @@ class DebuggingOptions {
final String hostname; final String hostname;
/// A file where the vmservice URL should be written after the application is started. /// A file where the vmservice URL should be written after the application is started.
final String vmserviceOutFile; final String vmserviceOutFile;
final bool fastStart;
bool get hasObservatoryPort => hostVmServicePort != null; bool get hasObservatoryPort => hostVmServicePort != null;
} }
......
...@@ -712,7 +712,7 @@ abstract class ResidentRunner { ...@@ -712,7 +712,7 @@ abstract class ResidentRunner {
bool get supportsRestart => false; bool get supportsRestart => false;
Future<OperationResult> restart({ bool fullRestart = false, bool pause = false, String reason }) { Future<OperationResult> restart({ bool fullRestart = false, bool pauseAfterRestart = false, String reason }) {
final String mode = isRunningProfile ? 'profile' : final String mode = isRunningProfile ? 'profile' :
isRunningRelease ? 'release' : 'this'; isRunningRelease ? 'release' : 'this';
throw '${fullRestart ? 'Restart' : 'Reload'} is not supported in $mode mode'; throw '${fullRestart ? 'Restart' : 'Reload'} is not supported in $mode mode';
......
...@@ -103,7 +103,7 @@ class HotRunner extends ResidentRunner { ...@@ -103,7 +103,7 @@ class HotRunner extends ResidentRunner {
bool pause = false, bool pause = false,
}) async { }) async {
// TODO(cbernaschina): check that isolateId is the id of the UI isolate. // TODO(cbernaschina): check that isolateId is the id of the UI isolate.
final OperationResult result = await restart(pause: pause); final OperationResult result = await restart(pauseAfterRestart: pause);
if (!result.isOk) { if (!result.isOk) {
throw rpc.RpcException( throw rpc.RpcException(
rpc_error_code.INTERNAL_ERROR, rpc_error_code.INTERNAL_ERROR,
...@@ -114,7 +114,7 @@ class HotRunner extends ResidentRunner { ...@@ -114,7 +114,7 @@ class HotRunner extends ResidentRunner {
Future<void> _restartService({ bool pause = false }) async { Future<void> _restartService({ bool pause = false }) async {
final OperationResult result = final OperationResult result =
await restart(fullRestart: true, pause: pause); await restart(fullRestart: true, pauseAfterRestart: pause);
if (!result.isOk) { if (!result.isOk) {
throw rpc.RpcException( throw rpc.RpcException(
rpc_error_code.INTERNAL_ERROR, rpc_error_code.INTERNAL_ERROR,
...@@ -211,15 +211,6 @@ class HotRunner extends ResidentRunner { ...@@ -211,15 +211,6 @@ class HotRunner extends ResidentRunner {
} }
} }
if (debuggingOptions.fastStart) {
await restart(
fullRestart: true,
benchmarkMode: !debuggingOptions.startPaused,
reason: 'restart',
silent: true,
);
}
appStartedCompleter?.complete(); appStartedCompleter?.complete();
if (benchmarkMode) { if (benchmarkMode) {
...@@ -365,10 +356,12 @@ class HotRunner extends ResidentRunner { ...@@ -365,10 +356,12 @@ class HotRunner extends ResidentRunner {
Uri packagesUri, Uri packagesUri,
Uri assetsDirectoryUri, Uri assetsDirectoryUri,
) { ) {
return Future.wait(<Future<void>>[ final List<Future<void>> futures = <Future<void>>[
for (FlutterView view in device.views) for (FlutterView view in device.views) view.runFromSource(entryUri, packagesUri, assetsDirectoryUri),
view.runFromSource(entryUri, packagesUri, assetsDirectoryUri), ];
]); final Completer<void> completer = Completer<void>();
Future.wait(futures).whenComplete(() { completer.complete(null); });
return completer.future;
} }
Future<void> _launchFromDevFS(String mainScript) async { Future<void> _launchFromDevFS(String mainScript) async {
...@@ -465,11 +458,9 @@ class HotRunner extends ResidentRunner { ...@@ -465,11 +458,9 @@ class HotRunner extends ResidentRunner {
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) { for (FlutterView view in device.views) {
isolateNotifications.add( isolateNotifications.add(
view.owner.vm.vmService.onIsolateEvent view.owner.vm.vmService.onIsolateEvent.then((Stream<ServiceEvent> serviceEvents) async {
.then((Stream<ServiceEvent> serviceEvents) async {
await for (ServiceEvent serviceEvent in serviceEvents) { await for (ServiceEvent serviceEvent in serviceEvents) {
if (serviceEvent.owner.name.contains('_spawn') if (serviceEvent.owner.name.contains('_spawn') && serviceEvent.kind == ServiceEvent.kIsolateExit) {
&& serviceEvent.kind == ServiceEvent.kIsolateExit) {
return; return;
} }
} }
...@@ -530,10 +521,9 @@ class HotRunner extends ResidentRunner { ...@@ -530,10 +521,9 @@ class HotRunner extends ResidentRunner {
@override @override
Future<OperationResult> restart({ Future<OperationResult> restart({
bool fullRestart = false, bool fullRestart = false,
bool pauseAfterRestart = false,
String reason, String reason,
bool benchmarkMode = false, bool benchmarkMode = false,
bool silent = false,
bool pause = false,
}) async { }) async {
String targetPlatform; String targetPlatform;
String sdkName; String sdkName;
...@@ -560,11 +550,8 @@ class HotRunner extends ResidentRunner { ...@@ -560,11 +550,8 @@ class HotRunner extends ResidentRunner {
emulator: emulator, emulator: emulator,
reason: reason, reason: reason,
benchmarkMode: benchmarkMode, benchmarkMode: benchmarkMode,
silent: silent,
); );
if (!silent) { printStatus('Restarted application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
printStatus('Restarted application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
}
return result; return result;
} }
final OperationResult result = await _hotReloadHelper( final OperationResult result = await _hotReloadHelper(
...@@ -572,13 +559,11 @@ class HotRunner extends ResidentRunner { ...@@ -572,13 +559,11 @@ class HotRunner extends ResidentRunner {
sdkName: sdkName, sdkName: sdkName,
emulator: emulator, emulator: emulator,
reason: reason, reason: reason,
pause: pause, pauseAfterRestart: pauseAfterRestart,
); );
if (result.isOk) { if (result.isOk) {
final String elapsed = getElapsedAsMilliseconds(timer.elapsed); final String elapsed = getElapsedAsMilliseconds(timer.elapsed);
if (!silent) { printStatus('${result.message} in $elapsed.');
printStatus('${result.message} in $elapsed.');
}
} }
return result; return result;
} }
...@@ -589,19 +574,15 @@ class HotRunner extends ResidentRunner { ...@@ -589,19 +574,15 @@ class HotRunner extends ResidentRunner {
bool emulator, bool emulator,
String reason, String reason,
bool benchmarkMode, bool benchmarkMode,
bool silent,
}) async { }) async {
if (!canHotRestart) { if (!canHotRestart) {
return OperationResult(1, 'hotRestart not supported'); return OperationResult(1, 'hotRestart not supported');
} }
Status status; final Status status = logger.startProgress(
if (!silent) { 'Performing hot restart...',
status = logger.startProgress( timeout: timeoutConfiguration.fastOperation,
'Performing hot restart...', progressId: 'hot.restart',
timeout: timeoutConfiguration.fastOperation, );
progressId: 'hot.restart',
);
}
OperationResult result; OperationResult result;
String restartEvent = 'restart'; String restartEvent = 'restart';
try { try {
...@@ -629,7 +610,7 @@ class HotRunner extends ResidentRunner { ...@@ -629,7 +610,7 @@ class HotRunner extends ResidentRunner {
emulator: emulator, emulator: emulator,
fullRestart: true, fullRestart: true,
reason: reason).send(); reason: reason).send();
status?.cancel(); status.cancel();
} }
return result; return result;
} }
...@@ -639,7 +620,7 @@ class HotRunner extends ResidentRunner { ...@@ -639,7 +620,7 @@ class HotRunner extends ResidentRunner {
String sdkName, String sdkName,
bool emulator, bool emulator,
String reason, String reason,
bool pause, bool pauseAfterRestart = false,
}) async { }) async {
final bool reloadOnTopOfSnapshot = _runningFromSnapshot; final bool reloadOnTopOfSnapshot = _runningFromSnapshot;
final String progressPrefix = reloadOnTopOfSnapshot ? 'Initializing' : 'Performing'; final String progressPrefix = reloadOnTopOfSnapshot ? 'Initializing' : 'Performing';
...@@ -654,8 +635,8 @@ class HotRunner extends ResidentRunner { ...@@ -654,8 +635,8 @@ class HotRunner extends ResidentRunner {
targetPlatform: targetPlatform, targetPlatform: targetPlatform,
sdkName: sdkName, sdkName: sdkName,
emulator: emulator, emulator: emulator,
pause: pauseAfterRestart,
reason: reason, reason: reason,
pause: pause,
onSlow: (String message) { onSlow: (String message) {
status?.cancel(); status?.cancel();
status = logger.startProgress( status = logger.startProgress(
......
...@@ -10,14 +10,11 @@ import 'package:args/command_runner.dart'; ...@@ -10,14 +10,11 @@ import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/run.dart'; import 'package:flutter_tools/src/commands/run.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/resident_runner.dart'; import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart';
...@@ -56,71 +53,6 @@ void main() { ...@@ -56,71 +53,6 @@ void main() {
} }
}); });
testUsingContext('does not support "--use-application-binary" and "--fast-start"', () async {
fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
fs.file('pubspec.yaml').createSync();
fs.file('.packages').createSync();
final RunCommand command = RunCommand();
applyMocksToCommand(command);
try {
await createTestCommandRunner(command).run(<String>[
'run',
'--use-application-binary=app/bar/faz',
'--fast-start',
'--no-pub',
'--show-test-device',
]);
fail('Expect exception');
} catch (e) {
expect(e.toString(), contains('--fast-start is not supported with --use-application-binary'));
}
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('Forces fast start off for devices that do not support it', () async {
final MockDevice mockDevice = MockDevice(TargetPlatform.android_arm);
when(mockDevice.name).thenReturn('mockdevice');
when(mockDevice.supportsFastStart).thenReturn(false);
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.isLocalEmulator).thenAnswer((Invocation invocation) async => false);
when(deviceManager.hasSpecifiedAllDevices).thenReturn(false);
when(deviceManager.findTargetDevices(any)).thenAnswer((Invocation invocation) {
return Future<List<Device>>.value(<Device>[mockDevice]);
});
when(deviceManager.getDevices()).thenAnswer((Invocation invocation) {
return Stream<Device>.value(mockDevice);
});
fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
fs.file('pubspec.yaml').createSync();
fs.file('.packages').createSync();
final RunCommand command = RunCommand();
applyMocksToCommand(command);
try {
await createTestCommandRunner(command).run(<String>[
'run',
'--fast-start',
'--no-pub',
]);
fail('Expect exception');
} catch (e) {
expect(e, isInstanceOf<ToolExit>());
}
final BufferLogger bufferLogger = logger as BufferLogger;
expect(bufferLogger.statusText, contains(
'Using --fast-start option with device mockdevice, but this device '
'does not support it. Overriding the setting to false.'
));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
DeviceManager: () => MockDeviceManager(),
});
group('cache', () { group('cache', () {
MemoryFileSystem fs; MemoryFileSystem fs;
MockCache mockCache; MockCache mockCache;
......
...@@ -154,41 +154,6 @@ void main() { ...@@ -154,41 +154,6 @@ void main() {
expect(onAppStart.isCompleted, true); expect(onAppStart.isCompleted, true);
})); }));
test('ResidentRunner can attach to device successfully with --fast-start', () => testbed.run(() async {
when(mockDevice.supportsHotRestart).thenReturn(true);
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async {
return 'Example';
});
when(mockDevice.targetPlatform).thenAnswer((Invocation invocation) async {
return TargetPlatform.android_arm;
});
when(mockDevice.isLocalEmulator).thenAnswer((Invocation invocation) async {
return false;
});
residentRunner = HotRunner(
<FlutterDevice>[
mockFlutterDevice,
],
stayResident: false,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, fastStart: true, startPaused: true),
);
final Completer<DebugConnectionInfo> onConnectionInfo = Completer<DebugConnectionInfo>.sync();
final Completer<void> onAppStart = Completer<void>.sync();
final Future<int> result = residentRunner.attach(
appStartedCompleter: onAppStart,
connectionInfoCompleter: onConnectionInfo,
);
final Future<DebugConnectionInfo> connectionInfo = onConnectionInfo.future;
expect(await result, 0);
verify(mockFlutterDevice.initLogReader()).called(1);
expect(onConnectionInfo.isCompleted, true);
expect((await connectionInfo).baseUri, 'foo://bar');
expect(onAppStart.isCompleted, true);
}));
test('ResidentRunner can handle an RPC exception from hot reload', () => testbed.run(() async { test('ResidentRunner can handle an RPC exception from hot reload', () => testbed.run(() async {
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async { when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async {
return 'Example'; return 'Example';
......
...@@ -497,7 +497,7 @@ class FlutterRunTestDriver extends FlutterTestDriver { ...@@ -497,7 +497,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
// fast. // fast.
unawaited(_process.exitCode.then((_) { unawaited(_process.exitCode.then((_) {
if (!prematureExitGuard.isCompleted) { if (!prematureExitGuard.isCompleted) {
prematureExitGuard.completeError('Process existed prematurely: ${args.join(' ')}: $_errorBuffer'); prematureExitGuard.completeError('Process existed prematurely: ${args.join(' ')}');
} }
})); }));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment