Skip to content

Commit 1edec6f

Browse files
author
Jonah Williams
authored
Revert "[flutter_tools] refactor drive launch into separate service, split by mobile+desktop and web (flutter#68451)" (flutter#68845)
This reverts commit 2e75f52.
1 parent b25ce5b commit 1edec6f

File tree

23 files changed

+1612
-1268
lines changed

23 files changed

+1612
-1268
lines changed

packages/flutter_tools/lib/executable.dart

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

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

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

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

595597
if (debuggingOptions.debuggingEnabled) {
596598
observatoryDiscovery = ProtocolDiscovery.observatory(
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-
),
599+
await getLogReader(),
604600
portForwarder: portForwarder,
605601
hostPort: debuggingOptions.hostVmServicePort,
606602
devicePort: debuggingOptions.deviceVmServicePort,
@@ -673,6 +669,8 @@ class AndroidDevice extends Device {
673669
// Wait for the service protocol port here. This will complete once the
674670
// device has printed "Observatory is listening on...".
675671
_logger.printTrace('Waiting for observatory port to be available...');
672+
673+
// TODO(danrubel): Waiting for observatory services can be made common across all devices.
676674
try {
677675
Uri observatoryUri;
678676
if (debuggingOptions.buildInfo.isDebug || debuggingOptions.buildInfo.isProfile) {

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ 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+
2528
/// Whether the application has web plugins.
2629
const String kHasWebPlugins = 'HasWebPlugins';
2730

@@ -86,6 +89,7 @@ class WebEntrypointTarget extends Target {
8689
@override
8790
Future<void> build(Environment environment) async {
8891
final String targetFile = environment.defines[kTargetFile];
92+
final bool shouldInitializePlatform = environment.defines[kInitializePlatform] == 'true';
8993
final bool hasPlugins = environment.defines[kHasWebPlugins] == 'true';
9094
final Uri importUri = environment.fileSystem.file(targetFile).absolute.uri;
9195
// TODO(jonahwilliams): support configuration of this file.
@@ -133,7 +137,9 @@ import '$mainImport' as entrypoint;
133137
134138
Future<void> main() async {
135139
registerPlugins(webPluginRegistry);
136-
await ui.webOnlyInitializePlatform();
140+
if ($shouldInitializePlatform) {
141+
await ui.webOnlyInitializePlatform();
142+
}
137143
entrypoint.main();
138144
}
139145
''';
@@ -146,7 +152,9 @@ import 'dart:ui' as ui;
146152
import '$mainImport' as entrypoint;
147153
148154
Future<void> main() async {
149-
await ui.webOnlyInitializePlatform();
155+
if ($shouldInitializePlatform) {
156+
await ui.webOnlyInitializePlatform();
157+
}
150158
entrypoint.main();
151159
}
152160
''';

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ 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,
387388
fileSystemRoots: stringsArg('filesystem-root'),
388389
fileSystemScheme: stringArg('filesystem-scheme'),
389390
target: stringArg('target'),

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ 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+
);
2834
argParser.addFlag('csp',
2935
defaultsTo: false,
3036
negatable: false,
@@ -86,6 +92,7 @@ class BuildWebCommand extends BuildSubCommand {
8692
flutterProject,
8793
target,
8894
buildInfo,
95+
boolArg('web-initialize-platform'),
8996
boolArg('csp'),
9097
stringArg('pwa-strategy'),
9198
boolArg('source-maps')

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

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

467467
final FlutterDevice flutterDevice = await FlutterDevice.create(
468468
device,
469+
flutterProject: flutterProject,
469470
target: target,
470471
buildInfo: options.buildInfo,
471472
platform: globals.platform,

0 commit comments

Comments
 (0)