[flutter] ensure vmservice binding is registered in profile mode (#83913)
This commit is contained in:
parent
f41fa9dd48
commit
85df73d0e3
15
dev/devicelab/bin/tasks/devtools_profile_start_test.dart
Normal file
15
dev/devicelab/bin/tasks/devtools_profile_start_test.dart
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// 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_devicelab/framework/adb.dart';
|
||||||
|
import 'package:flutter_devicelab/framework/framework.dart';
|
||||||
|
import 'package:flutter_devicelab/framework/utils.dart';
|
||||||
|
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||||
|
|
||||||
|
Future<void> main() async {
|
||||||
|
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||||
|
await task(DevtoolsStartupTest(
|
||||||
|
'${flutterDirectory.path}/examples/hello_world',
|
||||||
|
).run);
|
||||||
|
}
|
@ -15,6 +15,8 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
|||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
|
import '../common.dart';
|
||||||
|
|
||||||
/// Must match flutter_driver/lib/src/common.dart.
|
/// Must match flutter_driver/lib/src/common.dart.
|
||||||
///
|
///
|
||||||
/// Redefined here to avoid taking a dependency on flutter_driver.
|
/// Redefined here to avoid taking a dependency on flutter_driver.
|
||||||
@ -615,6 +617,106 @@ class StartupTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A one-off test to verify that devtools starts in profile mode.
|
||||||
|
class DevtoolsStartupTest {
|
||||||
|
const DevtoolsStartupTest(this.testDirectory);
|
||||||
|
|
||||||
|
final String testDirectory;
|
||||||
|
|
||||||
|
Future<TaskResult> run() async {
|
||||||
|
return inDirectory<TaskResult>(testDirectory, () async {
|
||||||
|
final Device device = await devices.workingDevice;
|
||||||
|
|
||||||
|
section('Building application');
|
||||||
|
String applicationBinaryPath;
|
||||||
|
switch (deviceOperatingSystem) {
|
||||||
|
case DeviceOperatingSystem.android:
|
||||||
|
await flutter('build', options: <String>[
|
||||||
|
'apk',
|
||||||
|
'-v',
|
||||||
|
'--profile',
|
||||||
|
'--target-platform=android-arm,android-arm64',
|
||||||
|
]);
|
||||||
|
applicationBinaryPath = '$testDirectory/build/app/outputs/flutter-apk/app-profile.apk';
|
||||||
|
break;
|
||||||
|
case DeviceOperatingSystem.androidArm:
|
||||||
|
await flutter('build', options: <String>[
|
||||||
|
'apk',
|
||||||
|
'-v',
|
||||||
|
'--profile',
|
||||||
|
'--target-platform=android-arm',
|
||||||
|
]);
|
||||||
|
applicationBinaryPath = '$testDirectory/build/app/outputs/flutter-apk/app-profile.apk';
|
||||||
|
break;
|
||||||
|
case DeviceOperatingSystem.androidArm64:
|
||||||
|
await flutter('build', options: <String>[
|
||||||
|
'apk',
|
||||||
|
'-v',
|
||||||
|
'--profile',
|
||||||
|
'--target-platform=android-arm64',
|
||||||
|
]);
|
||||||
|
applicationBinaryPath = '$testDirectory/build/app/outputs/flutter-apk/app-profile.apk';
|
||||||
|
break;
|
||||||
|
case DeviceOperatingSystem.ios:
|
||||||
|
await flutter('build', options: <String>[
|
||||||
|
'ios',
|
||||||
|
'-v',
|
||||||
|
'--profile',
|
||||||
|
]);
|
||||||
|
applicationBinaryPath = _findIosAppInBuildDirectory('$testDirectory/build/ios/iphoneos');
|
||||||
|
break;
|
||||||
|
case DeviceOperatingSystem.fuchsia:
|
||||||
|
case DeviceOperatingSystem.fake:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Process process = await startProcess(path.join(flutterDirectory.path, 'bin', 'flutter'), <String>[
|
||||||
|
'run',
|
||||||
|
'--no-android-gradle-daemon',
|
||||||
|
'--no-publish-port',
|
||||||
|
'--verbose',
|
||||||
|
'--profile',
|
||||||
|
'-d',
|
||||||
|
device.deviceId,
|
||||||
|
if (applicationBinaryPath != null)
|
||||||
|
'--use-application-binary=$applicationBinaryPath',
|
||||||
|
]);
|
||||||
|
final Completer<void> completer = Completer<void>();
|
||||||
|
bool sawLine = false;
|
||||||
|
process.stdout
|
||||||
|
.transform(utf8.decoder)
|
||||||
|
.transform(const LineSplitter())
|
||||||
|
.listen((String line) {
|
||||||
|
print('[STDOUT]: $line');
|
||||||
|
// Wait for devtools output.
|
||||||
|
if (line.contains('The Flutter DevTools debugger and profiler')) {
|
||||||
|
sawLine = true;
|
||||||
|
completer.complete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bool didExit = false;
|
||||||
|
unawaited(process.exitCode.whenComplete(() {
|
||||||
|
didExit = true;
|
||||||
|
}));
|
||||||
|
await Future.any(<Future<void>>[completer.future, Future<void>.delayed(const Duration(minutes: 5)), process.exitCode]);
|
||||||
|
if (!didExit) {
|
||||||
|
process.stdin.writeln('q');
|
||||||
|
await process.exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
await flutter('install', options: <String>[
|
||||||
|
'--uninstall-only',
|
||||||
|
'-d',
|
||||||
|
device.deviceId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (sawLine)
|
||||||
|
return TaskResult.success(null, benchmarkScoreKeys: <String>[]);
|
||||||
|
return TaskResult.failure('Did not see line "The Flutter DevTools debugger and profiler" in output');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Measures application runtime performance, specifically per-frame
|
/// Measures application runtime performance, specifically per-frame
|
||||||
/// performance.
|
/// performance.
|
||||||
class PerfTest {
|
class PerfTest {
|
||||||
|
@ -169,12 +169,29 @@ abstract class BindingBase {
|
|||||||
return true;
|
return true;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
if (!kReleaseMode && !kIsWeb) {
|
if (!kReleaseMode) {
|
||||||
|
if (!kIsWeb) {
|
||||||
registerSignalServiceExtension(
|
registerSignalServiceExtension(
|
||||||
name: 'exit',
|
name: 'exit',
|
||||||
callback: _exitApplication,
|
callback: _exitApplication,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// These service extensions are used in profile mode applications.
|
||||||
|
registerStringServiceExtension(
|
||||||
|
name: 'connectedVmServiceUri',
|
||||||
|
getter: () async => connectedVmServiceUri ?? '',
|
||||||
|
setter: (String uri) async {
|
||||||
|
connectedVmServiceUri = uri;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
registerStringServiceExtension(
|
||||||
|
name: 'activeDevToolsServerAddress',
|
||||||
|
getter: () async => activeDevToolsServerAddress ?? '',
|
||||||
|
setter: (String serverAddress) async {
|
||||||
|
activeDevToolsServerAddress = serverAddress;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
assert(() {
|
assert(() {
|
||||||
const String platformOverrideExtensionName = 'platformOverride';
|
const String platformOverrideExtensionName = 'platformOverride';
|
||||||
@ -245,23 +262,6 @@ abstract class BindingBase {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
registerStringServiceExtension(
|
|
||||||
name: 'connectedVmServiceUri',
|
|
||||||
getter: () async => connectedVmServiceUri ?? '',
|
|
||||||
setter: (String uri) async {
|
|
||||||
connectedVmServiceUri = uri;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
registerStringServiceExtension(
|
|
||||||
name: 'activeDevToolsServerAddress',
|
|
||||||
getter: () async => activeDevToolsServerAddress ?? '',
|
|
||||||
setter: (String serverAddress) async {
|
|
||||||
activeDevToolsServerAddress = serverAddress;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}());
|
}());
|
||||||
assert(() {
|
assert(() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user