Unverified Commit 66f49077 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "[flutter_tools] update to package vm_service: electric boogaloo (#53809)" (#53951)

This reverts commit 66d7a6c2.
parent 1e86c1fb
......@@ -14,9 +14,9 @@ dependencies:
test_api: 0.2.15
test_core: 0.3.3
build_runner: 1.8.1
build_runner: 1.8.0
build_test: 1.0.0
build_runner_core: 5.0.0
build_runner_core: 4.5.3
dart_style: 1.3.3
code_builder: 3.2.1
build: 1.2.2
......@@ -95,4 +95,4 @@ dartdoc:
# Exclude this package from the hosted API docs.
nodoc: true
# PUBSPEC CHECKSUM: 7c61
# PUBSPEC CHECKSUM: e267
......@@ -4,8 +4,8 @@
import 'dart:async';
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:meta/meta.dart';
import 'package:vm_service/vm_service.dart' as vmservice;
import 'asset.dart';
import 'base/context.dart';
......@@ -423,7 +423,7 @@ class DevFS {
globals.printTrace('DevFS: Creating new filesystem on the device ($_baseUri)');
try {
_baseUri = await _operations.create(fsName);
} on vmservice.RPCError catch (rpcException) {
} on rpc.RpcException catch (rpcException) {
// 1001 is kFileSystemAlreadyExists in //dart/runtime/vm/json_stream.h
if (rpcException.code != 1001) {
rethrow;
......
......@@ -620,7 +620,7 @@ class FuchsiaDevice extends Device {
// loopback (::1).
final Uri uri = Uri.parse('http://[$_ipv6Loopback]:$port');
final VMService vmService = await VMService.connect(uri);
await vmService.getVMOld();
await vmService.getVM();
await vmService.refreshViews();
for (final FlutterView flutterView in vmService.vm.views) {
if (flutterView.uiIsolate == null) {
......@@ -717,7 +717,7 @@ class FuchsiaIsolateDiscoveryProtocol {
continue;
}
}
await service.getVMOld();
await service.getVM();
await service.refreshViews();
for (final FlutterView flutterView in service.vm.views) {
if (flutterView.uiIsolate == null) {
......
......@@ -7,11 +7,11 @@ import 'dart:math' as math;
import 'package:meta/meta.dart';
import 'package:platform/platform.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
import 'package:process/process.dart';
import '../application_package.dart';
import '../artifacts.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
......@@ -514,7 +514,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
// and "Flutter". The regex tries to strike a balance between not producing
// false positives and not producing false negatives.
_anyLineRegex = RegExp(r'\w+(\([^)]*\))?\[\d+\] <[A-Za-z]+>: ');
_loggingSubscriptions = <StreamSubscription<void>>[];
_loggingSubscriptions = <StreamSubscription<ServiceEvent>>[];
}
/// Create a new [IOSDeviceLogReader].
......@@ -554,7 +554,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
RegExp _anyLineRegex;
StreamController<String> _linesController;
List<StreamSubscription<void>> _loggingSubscriptions;
List<StreamSubscription<ServiceEvent>> _loggingSubscriptions;
@override
Stream<String> get logLines => _linesController.stream;
......@@ -575,20 +575,18 @@ class IOSDeviceLogReader extends DeviceLogReader {
if (_majorSdkVersion < _minimumUniversalLoggingSdkVersion) {
return;
}
try {
await connectedVmService.streamListen('Stdout');
} on vm_service.RPCError {
// Do nothing, since the tool is already subscribed.
}
_loggingSubscriptions.add(connectedVmService.onStdoutEvent.listen((vm_service.Event event) {
final String message = utf8.decode(base64.decode(event.bytes));
if (message.isNotEmpty) {
_linesController.add(message);
// The VM service will not publish logging events unless the debug stream is being listened to.
// onDebugEvent listens to this stream as a side effect.
unawaited(connectedVmService.onDebugEvent);
_loggingSubscriptions.add((await connectedVmService.onStdoutEvent).listen((ServiceEvent event) {
final String logMessage = event.message;
if (logMessage.isNotEmpty) {
_linesController.add(logMessage);
}
}));
}
void _listenToSysLog() {
void _listenToSysLog () {
// syslog is not written on iOS 13+.
if (_majorSdkVersion >= _minimumUniversalLoggingSdkVersion) {
return;
......@@ -643,7 +641,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
@override
void dispose() {
for (final StreamSubscription<void> loggingSubscription in _loggingSubscriptions) {
for (final StreamSubscription<ServiceEvent> loggingSubscription in _loggingSubscriptions) {
loggingSubscription.cancel();
}
_idevicesyslogProcess?.kill();
......
......@@ -232,7 +232,7 @@ class FlutterDevice {
: vmService.vm.views).toList();
}
Future<void> getVMs() => vmService.getVMOld();
Future<void> getVMs() => vmService.getVM();
Future<void> exitApps() async {
if (!device.supportsFlutterExit) {
......
......@@ -3,8 +3,10 @@
// found in the LICENSE file.
import 'dart:async';
import 'package:vm_service/vm_service.dart' as vm_service;
import 'package:platform/platform.dart';
import 'package:json_rpc_2/error_code.dart' as rpc_error_code;
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:meta/meta.dart';
import 'package:pool/pool.dart';
import 'base/async_guard.dart';
......@@ -108,10 +110,9 @@ class HotRunner extends ResidentRunner {
// TODO(cbernaschina): check that isolateId is the id of the UI isolate.
final OperationResult result = await restart(pause: pause);
if (!result.isOk) {
throw vm_service.RPCError(
throw rpc.RpcException(
rpc_error_code.INTERNAL_ERROR,
'Unable to reload sources',
RPCErrorCodes.kInternalError,
'',
);
}
}
......@@ -120,10 +121,9 @@ class HotRunner extends ResidentRunner {
final OperationResult result =
await restart(fullRestart: true, pause: pause);
if (!result.isOk) {
throw vm_service.RPCError(
throw rpc.RpcException(
rpc_error_code.INTERNAL_ERROR,
'Unable to restart',
RPCErrorCodes.kInternalError,
'',
);
}
}
......@@ -564,15 +564,16 @@ class HotRunner extends ResidentRunner {
if (benchmarkMode) {
final List<Future<void>> isolateNotifications = <Future<void>>[];
for (final FlutterDevice device in flutterDevices) {
try {
await device.vmService.streamListen('Isolate');
} on vm_service.RPCError {
// Do nothing, we're already subcribed.
}
for (final FlutterView view in device.views) {
isolateNotifications.add(
view.owner.vm.vmService.onIsolateEvent.firstWhere((vm_service.Event event) {
return event.kind == vm_service.EventKind.kServiceExtensionAdded;
view.owner.vm.vmService.onIsolateEvent
.then((Stream<ServiceEvent> serviceEvents) async {
await for (final ServiceEvent serviceEvent in serviceEvents) {
if (serviceEvent.owner.name.contains('_spawn')
&& serviceEvent.kind == ServiceEvent.kIsolateExit) {
return;
}
}
}),
);
}
......@@ -719,12 +720,9 @@ class HotRunner extends ResidentRunner {
if (!result.isOk) {
restartEvent = 'restart-failed';
}
} on vm_service.SentinelException catch (err, st) {
restartEvent = 'exception';
return OperationResult(1, 'hot restart failed to complete: $err\n$st', fatal: true);
} on vm_service.RPCError catch (err, st) {
} on rpc.RpcException {
restartEvent = 'exception';
return OperationResult(1, 'hot restart failed to complete: $err\n$st', fatal: true);
return OperationResult(1, 'hot restart failed to complete', fatal: true);
} finally {
HotEvent(restartEvent,
targetPlatform: targetPlatform,
......@@ -766,7 +764,7 @@ class HotRunner extends ResidentRunner {
);
},
);
} on vm_service.RPCError {
} on rpc.RpcException {
HotEvent('exception',
targetPlatform: targetPlatform,
sdkName: sdkName,
......
......@@ -189,7 +189,7 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool Function(String) libra
Future<VMService> Function(Uri) connector = _defaultConnect,
}) async {
final VMService vmService = await connector(serviceUri);
await vmService.getVMOld();
await vmService.getVM();
final Map<String, dynamic> result = await _getAllCoverage(
vmService, libraryPredicate);
await vmService.close();
......@@ -197,7 +197,7 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool Function(String) libra
}
Future<Map<String, dynamic>> _getAllCoverage(VMService service, bool Function(String) libraryPredicate) async {
await service.getVMOld();
await service.getVM();
final List<Map<String, dynamic>> coverage = <Map<String, dynamic>>[];
for (final Isolate isolateRef in service.vm.isolates) {
await isolateRef.load();
......
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'dart:async';
import 'package:vm_service/vm_service.dart' as vm_service;
import 'base/file_system.dart';
import 'base/logger.dart';
......@@ -46,8 +45,7 @@ class Tracing {
);
try {
final Completer<void> whenFirstFrameRendered = Completer<void>();
await vmService.streamListen('Extension');
vmService.onExtensionEvent.listen((vm_service.Event event) {
(await vmService.onExtensionEvent).listen((ServiceEvent event) {
if (event.extensionKind == 'Flutter.FirstFrame') {
whenFirstFrameRendered.complete();
}
......
......@@ -19,6 +19,7 @@ dependencies:
flutter_template_images: 1.0.0
http: 0.12.0+4
intl: 0.16.1
json_rpc_2: 2.1.0
meta: 1.1.8
multicast_dns: 0.2.2
mustache_template: 1.0.0+1
......@@ -27,8 +28,10 @@ dependencies:
process: 3.0.12
quiver: 2.1.3
stack_trace: 1.9.3
stream_channel: 2.0.0
usage: 3.4.1
webdriver: 2.1.2
web_socket_channel: 1.1.0
webkit_inspection_protocol: 0.5.0+1
xml: 3.6.1
yaml: 2.2.0
......@@ -85,7 +88,6 @@ dependencies:
source_maps: 0.10.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.7.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
sse: 3.2.1 # 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"
stream_transform: 1.2.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"
sync_http: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
......@@ -93,7 +95,6 @@ dependencies:
typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
uuid: 2.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
watcher: 0.9.7+14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
web_socket_channel: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies:
collection: 1.14.12
......@@ -111,4 +112,4 @@ dartdoc:
# Exclude this package from the hosted API docs.
nodoc: true
# PUBSPEC CHECKSUM: a585
# PUBSPEC CHECKSUM: 53c2
......@@ -14,8 +14,8 @@ import 'package:flutter_tools/src/base/net.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:mockito/mockito.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
import '../src/common.dart';
import '../src/context.dart';
......@@ -389,7 +389,7 @@ class MockVM implements VM {
Future<Map<String, dynamic>> createDevFS(String fsName) async {
_service.messages.add('create $fsName');
if (_devFSExists) {
throw vm_service.RPCError('File system already exists', kFileSystemAlreadyExists, '');
throw rpc.RpcException(kFileSystemAlreadyExists, 'File system already exists');
}
_devFSExists = true;
return <String, dynamic>{'uri': '$_baseUri'};
......
......@@ -596,7 +596,7 @@ void main() {
.thenAnswer((Invocation invocation) async => <int>[1]);
when(portForwarder.forward(1))
.thenAnswer((Invocation invocation) async => 2);
when(vmService.getVMOld())
when(vmService.getVM())
.thenAnswer((Invocation invocation) => Future<void>.value(null));
when(vmService.refreshViews())
.thenAnswer((Invocation invocation) => Future<void>.value(null));
......
......@@ -2,18 +2,13 @@
// 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_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/ios/devices.dart';
import 'package:flutter_tools/src/ios/mac.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:mockito/mockito.dart';
import 'package:vm_service/vm_service.dart';
import '../../src/common.dart';
import '../../src/context.dart';
......@@ -142,39 +137,6 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
' with a non-Flutter log message following it.',
]);
});
testWithoutContext('IOSDeviceLogReader can listen to VM Service logs', () async {
final MockVmService vmService = MockVmService();
final DeviceLogReader logReader = IOSDeviceLogReader.test(
useSyslog: false,
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
);
final StreamController<Event> controller = StreamController<Event>();
final Completer<Success> stdoutCompleter = Completer<Success>();
when(vmService.streamListen('Stdout')).thenAnswer((Invocation invocation) {
return stdoutCompleter.future;
});
when(vmService.onStdoutEvent).thenAnswer((Invocation invocation) {
return controller.stream;
});
logReader.connectedVMService = vmService;
stdoutCompleter.complete(Success());
controller.add(Event(
kind: 'Stdout',
timestamp: 0,
bytes: base64.encode(utf8.encode(' This is a message ')),
));
// Wait for stream listeners to fire.
await expectLater(logReader.logLines, emits(' This is a message '));
});
}
class MockArtifacts extends Mock implements Artifacts {}
class MockVmService extends Mock implements VMService, VmService {}
......@@ -23,8 +23,8 @@ import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/run_cold.dart';
import 'package:flutter_tools/src/run_hot.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:json_rpc_2/json_rpc_2.dart';
import 'package:mockito/mockito.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
import '../src/common.dart';
import '../src/context.dart';
......@@ -222,7 +222,7 @@ void main() {
pathToReload: anyNamed('pathToReload'),
invalidatedFiles: anyNamed('invalidatedFiles'),
dillOutputPath: anyNamed('dillOutputPath'),
)).thenThrow(vm_service.RPCError('something bad happened', 666, ''));
)).thenThrow(RpcException(666, 'something bad happened'));
final OperationResult result = await residentRunner.restart(fullRestart: false);
expect(result.fatal, true);
......@@ -327,7 +327,7 @@ void main() {
pathToReload: anyNamed('pathToReload'),
invalidatedFiles: anyNamed('invalidatedFiles'),
dillOutputPath: anyNamed('dillOutputPath'),
)).thenThrow(vm_service.RPCError('something bad happened', 666, ''));
)).thenThrow(RpcException(666, 'something bad happened'));
final OperationResult result = await residentRunner.restart(fullRestart: true);
expect(result.fatal, true);
......
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