Unverified Commit cb69bbb4 authored by Michael Klimushyn's avatar Michael Klimushyn Committed by GitHub

Remove unused `l` and `--isolate-filter` tools (#63336)

parent ba92cbed
// 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 'dart:convert';
import 'dart:io';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import 'package:flutter_devicelab/framework/adb.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
const String _kActivityId = 'io.flutter.examples.named_isolates/com.example.view.MainActivity';
const String _kFirstIsolateName = 'first isolate name';
const String _kSecondIsolateName = 'second isolate name';
void main() {
task(() async {
final AndroidDevice device = await devices.workingDevice as AndroidDevice;
await device.unlock();
section('Compile and run the tester app');
Completer<void> firstNameFound = Completer<void>();
Completer<void> secondNameFound = Completer<void>();
final Process runProcess = await _run(device: device, command:
<String>['run', '--disable-service-auth-codes', '--no-fast-start'], stdoutListener: (String line) {
if (line.contains(_kFirstIsolateName)) {
firstNameFound.complete();
} else if (line.contains(_kSecondIsolateName)) {
secondNameFound.complete();
}
});
section('Verify all the debug isolate names are set');
runProcess.stdin.write('l');
await Future.wait<dynamic>(<Future<dynamic>>[firstNameFound.future, secondNameFound.future])
.timeout(const Duration(seconds: 1), onTimeout: () => throw 'Isolate names not found.');
await _quitRunner(runProcess);
section('Attach to the second debug isolate');
firstNameFound = Completer<void>();
secondNameFound = Completer<void>();
final String currentTime = (await device.shellEval('date', <String>['"+%F %R:%S.000"'])).trim();
await device.shellExec('am', <String>['start', '-n', _kActivityId]);
final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]);
print('Found observatory line: $observatoryLine');
final String observatoryUri = RegExp(r'Observatory listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)').firstMatch(observatoryLine)[1];
print('Extracted observatory port: $observatoryUri');
final Process attachProcess =
await _run(device: device, command: <String>['attach', '--debug-uri',
observatoryUri, '--isolate-filter', _kSecondIsolateName], stdoutListener: (String line) {
if (line.contains(_kFirstIsolateName)) {
firstNameFound.complete();
} else if (line.contains(_kSecondIsolateName)) {
secondNameFound.complete();
}
});
attachProcess.stdin.write('l');
await secondNameFound.future;
if (firstNameFound.isCompleted)
throw '--isolate-filter failed to attach to a specific isolate';
await _quitRunner(attachProcess);
return TaskResult.success(null);
});
}
Future<Process> _run({@required Device device, @required List<String> command, @required Function(String) stdoutListener}) async {
final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/named_isolates'));
Process runner;
bool observatoryConnected = false;
await inDirectory(appDir, () async {
runner = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'),
<String>['--suppress-analytics', '-d', device.deviceId, ...command],
isBot: false, // we just want to test the output, not have any debugging info
);
final StreamController<String> stdout = StreamController<String>.broadcast();
// Mirror output to stdout, listen for ready message
final Completer<void> appReady = Completer<void>();
runner.stdout
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
.listen((String line) {
print('run:stdout: $line');
stdout.add(line);
if (parseServicePort(line) != null) {
appReady.complete();
observatoryConnected = true;
}
stdoutListener(line);
});
runner.stderr
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
.listen((String line) {
stderr.writeln('run:stderr: $line');
});
// Wait for either the process to fail or for the run to begin.
await Future.any<dynamic>(<Future<dynamic>>[ appReady.future, runner.exitCode ]);
if (!observatoryConnected)
throw 'Failed to find service port when running `${command.join(' ')}`';
});
return runner;
}
Future<void> _quitRunner(Process runner) async {
runner.stdin.write('q');
final int result = await runner.exitCode;
if (result != 0)
throw 'Received unexpected exit code $result when quitting process.';
}
......@@ -420,13 +420,6 @@ tasks:
# required_agent_capabilities: ["linux/android"]
# flaky: true
named_isolates_test:
description: >
Tests naming and attaching to specific isolates.
stage: devicelab
required_agent_capabilities: ["linux/android"]
flaky: true # https://github.com/flutter/flutter/issues/63016
linux_chrome_dev_mode:
description: >
Run flutter web on the devicelab and hot restart.
......
Integration app for testing multiple named isolates.
\ No newline at end of file
// 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.
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { stream ->
localProperties.load(stream)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "io.flutter.examples.named_isolates"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "0.0.1"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
}
<!-- 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. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.view">
<!-- The INTERNET permission is required for development. Specifically, flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application android:name="io.flutter.app.FlutterApplication" android:label="named_isolates">
<activity android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/Theme.AppCompat"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
// 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.
package com.example.view;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.BasicMessageChannel.MessageHandler;
import io.flutter.plugin.common.BasicMessageChannel.Reply;
import io.flutter.plugin.common.StringCodec;
import io.flutter.view.FlutterMain;
import io.flutter.view.FlutterRunArguments;
import io.flutter.view.FlutterView;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
private FlutterView firstFlutterView;
private FlutterView secondFlutterView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FlutterMain.ensureInitializationComplete(getApplicationContext(), null);
setContentView(R.layout.flutter_view_layout);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.hide();
}
FlutterRunArguments firstRunArguments = new FlutterRunArguments();
firstRunArguments.bundlePath = FlutterMain.findAppBundlePath(getApplicationContext());
firstRunArguments.entrypoint = "first";
firstFlutterView = findViewById(R.id.first);
firstFlutterView.runFromBundle(firstRunArguments);
FlutterRunArguments secondRunArguments = new FlutterRunArguments();
secondRunArguments.bundlePath = FlutterMain.findAppBundlePath(getApplicationContext());
secondRunArguments.entrypoint = "second";
secondFlutterView = findViewById(R.id.second);
secondFlutterView.runFromBundle(secondRunArguments);
}
@Override
protected void onDestroy() {
if (firstFlutterView != null) {
firstFlutterView.destroy();
}
if (secondFlutterView != null) {
secondFlutterView.destroy();
}
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
firstFlutterView.onPause();
secondFlutterView.onPause();
}
@Override
protected void onPostResume() {
super.onPostResume();
firstFlutterView.onPostResume();
secondFlutterView.onPostResume();
}
}
<!-- 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. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<io.flutter.view.FlutterView
android:id="@+id/first"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<io.flutter.view.FlutterView
android:id="@+id/second"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
// 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.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
// 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.
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
// 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:ui' as ui;
import 'package:flutter/material.dart';
// named_isolates_test depends on these values.
const String _kFirstIsolateName = 'first isolate name';
const String _kSecondIsolateName = 'second isolate name';
void first() {
_run(_kFirstIsolateName);
}
void second() {
_run(_kSecondIsolateName);
}
void _run(String name) {
ui.window.setIsolateDebugName(name);
runApp(Center(child: Text(name, textDirection: TextDirection.ltr)));
}
// `first` and `second` are the actual entrypoints to this app, but dart specs
// require a main function.
void main() { }
name: named_isolates
description: Tester app for naming specific isolates.
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
characters: 1.1.0-nullsafety.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
collection: 1.15.0-nullsafety.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
meta: 1.3.0-nullsafety.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
typed_data: 1.3.0-nullsafety.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
vector_math: 2.1.0-nullsafety.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
flutter:
uses-material-design: true
# PUBSPEC CHECKSUM: 98a5
......@@ -83,8 +83,6 @@ Future<void> main(List<String> args) async {
'attach',
'--module',
name,
'--isolate-filter',
name,
'--target',
targetFile,
'--target-model',
......
......@@ -198,11 +198,6 @@ abstract class ResidentWebRunner extends ResidentRunner {
}
}
@override
Future<List<FlutterView>> listFlutterViews() async {
return <FlutterView>[];
}
@override
Future<void> debugDumpApp() async {
try {
......
......@@ -57,7 +57,6 @@ import '../widget_cache.dart';
class AttachCommand extends FlutterCommand {
AttachCommand({bool verboseHelp = false, this.hotRunnerFactory}) {
addBuildModeFlags(defaultToRelease: false);
usesIsolateFilterOption(hide: !verboseHelp);
usesTargetOption();
usesPortOptions();
usesIpv6Flag();
......@@ -380,7 +379,6 @@ class AttachCommand extends FlutterCommand {
flutterProject: flutterProject,
fileSystemRoots: stringsArg('filesystem-root'),
fileSystemScheme: stringArg('filesystem-scheme'),
viewFilter: stringArg('isolate-filter'),
target: stringArg('target'),
targetModel: TargetModel(stringArg('target-model')),
buildInfo: getBuildInfo(),
......
......@@ -470,7 +470,6 @@ class AppDomain extends Domain {
final FlutterDevice flutterDevice = await FlutterDevice.create(
device,
flutterProject: flutterProject,
viewFilter: isolateFilter,
target: target,
buildInfo: options.buildInfo,
widgetCache: WidgetCache(featureFlags: featureFlags),
......
......@@ -73,7 +73,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
usesIpv6Flag();
usesPubOption();
usesTrackWidgetCreation(verboseHelp: verboseHelp);
usesIsolateFilterOption(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesDeviceUserOption();
}
......@@ -526,7 +525,6 @@ class RunCommand extends RunCommandBase {
flutterProject: flutterProject,
fileSystemRoots: stringsArg('filesystem-root'),
fileSystemScheme: stringArg('filesystem-scheme'),
viewFilter: stringArg('isolate-filter'),
experimentalFlags: expFlags,
target: stringArg('target'),
buildInfo: getBuildInfo(),
......
......@@ -42,7 +42,6 @@ class FlutterDevice {
@required this.buildInfo,
this.fileSystemRoots,
this.fileSystemScheme,
this.viewFilter,
TargetModel targetModel = TargetModel.flutter,
TargetPlatform targetPlatform,
ResidentCompiler generator,
......@@ -76,7 +75,6 @@ class FlutterDevice {
@required BuildInfo buildInfo,
List<String> fileSystemRoots,
String fileSystemScheme,
String viewFilter,
TargetModel targetModel = TargetModel.flutter,
List<String> experimentalFlags,
ResidentCompiler generator,
......@@ -165,7 +163,6 @@ class FlutterDevice {
device,
fileSystemRoots: fileSystemRoots,
fileSystemScheme:fileSystemScheme,
viewFilter: viewFilter,
targetModel: targetModel,
targetPlatform: targetPlatform,
generator: generator,
......@@ -188,7 +185,6 @@ class FlutterDevice {
String fileSystemScheme;
StreamSubscription<String> _loggingSubscription;
bool _isListeningForObservatoryUri;
final String viewFilter;
/// Whether the stream [observatoryUris] is still open.
bool get isWaitingForObservatory => _isListeningForObservatoryUri ?? false;
......@@ -947,18 +943,6 @@ abstract class ResidentRunner {
throw Exception('Canvaskit not supported by this runner.');
}
/// List the attached flutter views.
Future<List<FlutterView>> listFlutterViews() async {
final List<List<FlutterView>> views = await Future.wait(<Future<List<FlutterView>>>[
for (FlutterDevice device in flutterDevices)
if (device.vmService != null)
device.vmService.getFlutterViews()
]);
return views
.expand((List<FlutterView> viewList) => viewList)
.toList();
}
/// Write the SkSL shaders to a zip file in build directory.
///
/// Returns the name of the file, or `null` on failures.
......@@ -1532,13 +1516,6 @@ class TerminalHandler {
return true;
}
return false;
case 'l':
final List<FlutterView> views = await residentRunner.listFlutterViews();
globals.printStatus('Connected ${pluralize('view', views.length)}:');
for (final FlutterView v in views) {
globals.printStatus('${v.uiIsolate.name} (${v.uiIsolate.id})', indent: 2);
}
return true;
case 'L':
if (residentRunner.supportsServiceProtocol) {
await residentRunner.debugDumpLayerTree();
......
......@@ -396,14 +396,6 @@ abstract class FlutterCommand extends Command<void> {
);
}
void usesIsolateFilterOption({ @required bool hide }) {
argParser.addOption('isolate-filter',
defaultsTo: null,
hide: hide,
help: 'Restricts commands to a subset of the available isolates (running instances of Flutter).\n'
"Normally there's only one, but when adding Flutter to a pre-existing app it's possible to create multiple.");
}
void usesDeviceUserOption() {
argParser.addOption(FlutterOptions.kDeviceUser,
help: 'Identifier number for a user or work profile on Android only. Run "adb shell pm list users" for available identifiers.',
......
......@@ -207,20 +207,6 @@ void main() {
});
});
testUsingContext('FlutterDevice can list views with a filter', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews,
]);
final MockDevice mockDevice = MockDevice();
final FlutterDevice flutterDevice = FlutterDevice(
mockDevice,
buildInfo: BuildInfo.debug,
viewFilter: 'b', // Does not match name of `fakeFlutterView`.
);
flutterDevice.vmService = fakeVmServiceHost.vmService;
}));
testUsingContext('ResidentRunner can attach to device successfully', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews,
......@@ -1640,17 +1626,6 @@ void main() {
expect(fakeVmServiceHost.hasRemainingExpectations, false);
}));
testUsingContext('listViews handles a null VM service', () => testbed.run(() async {
final FlutterDevice device = FlutterDevice(mockDevice, buildInfo: BuildInfo.debug);
final ResidentRunner residentRunner = HotRunner(
<FlutterDevice>[device],
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug)
);
expect(await residentRunner.listFlutterViews(), isEmpty);
}));
testUsingContext('ResidentRunner debugDumpApp calls flutter device', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
await residentRunner.debugDumpApp();
......
......@@ -8,7 +8,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:mockito/mockito.dart';
import '../src/common.dart';
......@@ -155,19 +154,6 @@ void main() {
});
testUsingContext('l - list flutter views', () async {
final MockFlutterDevice mockFlutterDevice = MockFlutterDevice();
when(mockResidentRunner.isRunningDebug).thenReturn(true);
when(mockResidentRunner.flutterDevices).thenReturn(<FlutterDevice>[mockFlutterDevice]);
when(mockResidentRunner.listFlutterViews()).thenAnswer((Invocation invocation) async {
return <FlutterView>[];
});
await terminalHandler.processTerminalInput('l');
expect(testLogger.statusText, contains('Connected views:\n'));
});
testUsingContext('L - debugDumpLayerTree with service protocol', () async {
await terminalHandler.processTerminalInput('L');
......
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