Skip to content

Commit 2e75f52

Browse files
author
Jonah Williams
authored
[flutter_tools] refactor drive launch into separate service, split by mobile+desktop and web (flutter#68451)
Overhaul of flutter drive in order to deliver a better experience, namely: flutter run and flutter drive now share more flags, so code paths that were previously only testable on run are now testable on drive. Removes web-initialize-platform as this is no longer used flutter drive correctly sets up a logger that shows native exceptions, by connecting to the vm service. VM service connection now provides access to memory info without launching devtools (only for debug/profile mode) Web changes Passes on the one test in the repo, otherwise the webdriver code has been isolated as much as possible Additional NNBD related bug fixes: No longer passes --enable-experiment to the test script. (FYI @blasten ). earlier we might have assumed that the flutter gallery benchmarks would be migrated along side the app and flutter driver, but only the app under test needs to be migrated. The test scripts should never be run with the experiment.
1 parent 1bd661f commit 2e75f52

File tree

23 files changed

+1268
-1612
lines changed

23 files changed

+1268
-1612
lines changed

packages/flutter_tools/lib/executable.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ Future<void> main(List<String> args) async {
9595
DevicesCommand(),
9696
DoctorCommand(verbose: verbose),
9797
DowngradeCommand(),
98-
DriveCommand(verboseHelp: verboseHelp),
98+
DriveCommand(verboseHelp: verboseHelp,
99+
fileSystem: globals.fs,
100+
logger: globals.logger,
101+
),
99102
EmulatorsCommand(),
100103
FormatCommand(),
101104
GenerateCommand(),

packages/flutter_tools/lib/src/android/android_device.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,17 @@ class AndroidDevice extends Device {
590590
}
591591

592592
final bool traceStartup = platformArgs['trace-startup'] as bool ?? false;
593-
_logger.printTrace('$this startApp');
594-
595593
ProtocolDiscovery observatoryDiscovery;
596594

597595
if (debuggingOptions.debuggingEnabled) {
598596
observatoryDiscovery = ProtocolDiscovery.observatory(
599-
await getLogReader(),
597+
// Avoid using getLogReader, which returns a singleton instance, because the
598+
// observatory discovery will dipose at the end. creating a new logger here allows
599+
// logs to be surfaced normally during `flutter drive`.
600+
await AdbLogReader.createLogReader(
601+
this,
602+
_processManager,
603+
),
600604
portForwarder: portForwarder,
601605
hostPort: debuggingOptions.hostVmServicePort,
602606
devicePort: debuggingOptions.deviceVmServicePort,
@@ -669,8 +673,6 @@ class AndroidDevice extends Device {
669673
// Wait for the service protocol port here. This will complete once the
670674
// device has printed "Observatory is listening on...".
671675
_logger.printTrace('Waiting for observatory port to be available...');
672-
673-
// TODO(danrubel): Waiting for observatory services can be made common across all devices.
674676
try {
675677
Uri observatoryUri;
676678
if (debuggingOptions.buildInfo.isDebug || debuggingOptions.buildInfo.isProfile) {

packages/flutter_tools/lib/src/build_system/targets/web.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import 'assets.dart';
2222
import 'common.dart';
2323
import 'localizations.dart';
2424

25-
/// Whether web builds should call the platform initialization logic.
26-
const String kInitializePlatform = 'InitializePlatform';
27-
2825
/// Whether the application has web plugins.
2926
const String kHasWebPlugins = 'HasWebPlugins';
3027

@@ -89,7 +86,6 @@ class WebEntrypointTarget extends Target {
8986
@override
9087
Future<void> build(Environment environment) async {
9188
final String targetFile = environment.defines[kTargetFile];
92-
final bool shouldInitializePlatform = environment.defines[kInitializePlatform] == 'true';
9389
final bool hasPlugins = environment.defines[kHasWebPlugins] == 'true';
9490
final Uri importUri = environment.fileSystem.file(targetFile).absolute.uri;
9591
// TODO(jonahwilliams): support configuration of this file.
@@ -137,9 +133,7 @@ import '$mainImport' as entrypoint;
137133
138134
Future<void> main() async {
139135
registerPlugins(webPluginRegistry);
140-
if ($shouldInitializePlatform) {
141-
await ui.webOnlyInitializePlatform();
142-
}
136+
await ui.webOnlyInitializePlatform();
143137
entrypoint.main();
144138
}
145139
''';
@@ -152,9 +146,7 @@ import 'dart:ui' as ui;
152146
import '$mainImport' as entrypoint;
153147
154148
Future<void> main() async {
155-
if ($shouldInitializePlatform) {
156-
await ui.webOnlyInitializePlatform();
157-
}
149+
await ui.webOnlyInitializePlatform();
158150
entrypoint.main();
159151
}
160152
''';

packages/flutter_tools/lib/src/commands/attach.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
384384

385385
final FlutterDevice flutterDevice = await FlutterDevice.create(
386386
device,
387-
flutterProject: flutterProject,
388387
fileSystemRoots: stringsArg('filesystem-root'),
389388
fileSystemScheme: stringArg('filesystem-scheme'),
390389
target: stringArg('target'),

packages/flutter_tools/lib/src/commands/build_web.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ class BuildWebCommand extends BuildSubCommand {
2525
usesDartDefineOption();
2626
addEnableExperimentation(hide: !verboseHelp);
2727
addNullSafetyModeOptions(hide: !verboseHelp);
28-
argParser.addFlag('web-initialize-platform',
29-
defaultsTo: true,
30-
negatable: true,
31-
hide: true,
32-
help: 'Whether to automatically invoke webOnlyInitializePlatform.',
33-
);
3428
argParser.addFlag('csp',
3529
defaultsTo: false,
3630
negatable: false,
@@ -92,7 +86,6 @@ class BuildWebCommand extends BuildSubCommand {
9286
flutterProject,
9387
target,
9488
buildInfo,
95-
boolArg('web-initialize-platform'),
9689
boolArg('csp'),
9790
stringArg('pwa-strategy'),
9891
boolArg('source-maps')

packages/flutter_tools/lib/src/commands/daemon.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ class AppDomain extends Domain {
466466

467467
final FlutterDevice flutterDevice = await FlutterDevice.create(
468468
device,
469-
flutterProject: flutterProject,
470469
target: target,
471470
buildInfo: options.buildInfo,
472471
platform: globals.platform,

0 commit comments

Comments
 (0)