From 67377120674e448257045ea55a9759100509b231 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 12 Jan 2017 14:03:04 -0800 Subject: [PATCH] relax timeouts for some service protocol calls (#7468) * relax timeouts for some service protocol calls * remove 'note that' text --- packages/flutter_tools/lib/src/vmservice.dart | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index 41bc426f33..02c18e0908 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -5,8 +5,8 @@ import 'dart:async'; import 'dart:convert' show BASE64; -import 'package:json_rpc_2/json_rpc_2.dart' as rpc; 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:path/path.dart' as path; import 'package:stream_channel/stream_channel.dart'; import 'package:web_socket_channel/io.dart'; @@ -557,8 +557,7 @@ class VM extends ServiceObjectOwner { } } - // Note that this function does not reload the isolate if it found - // in the cache. + // This function does not reload the isolate if it's found in the cache. Future getIsolate(String isolateId) { if (!loaded) { // Trigger a VM load, then get the isolate. Ignore any errors. @@ -587,8 +586,8 @@ class VM extends ServiceObjectOwner { /// Invoke the RPC and return a ServiceObject response. Future invokeRpc( - String method, [Map params]) async { - Map response = await invokeRpcRaw(method, params); + String method, { Map params, Duration timeout }) async { + Map response = await invokeRpcRaw(method, params, timeout); ServiceObject serviceObject = new ServiceObject._fromMap(this, response); if ((serviceObject != null) && (serviceObject._canCache)) { String serviceObjectId = serviceObject.id; @@ -657,7 +656,7 @@ class VM extends ServiceObjectOwner { String packages, String assetsDirectory) { return invokeRpc('_flutter.runInView', - { + params: { 'viewId': viewId, 'mainScript': main, 'packagesFile': packages, @@ -683,7 +682,7 @@ class VM extends ServiceObjectOwner { } Future refreshViews() async { - await vmService.vm.invokeRpc('_flutter.listViews'); + await vmService.vm.invokeRpc('_flutter.listViews', timeout: kLongRequestTimeout); } FlutterView get mainView { @@ -808,9 +807,9 @@ class Isolate extends ServiceObjectOwner { // Invoke a flutter extension method, if the flutter extension is not // available, returns null. Future> invokeFlutterExtensionRpcRaw( - String method, [Map params]) async { + String method, { Map params, Duration timeout }) async { try { - return await invokeRpcRaw(method, params); + return await invokeRpcRaw(method, params, timeout); } on rpc.RpcException catch (e) { // If an application is not using the framework if (e.code == rpc_error_code.METHOD_NOT_FOUND) @@ -832,13 +831,15 @@ class Isolate extends ServiceObjectOwner { Future> flutterToggleDebugPaintSizeEnabled() async { Map state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint'); if (state != null && state.containsKey('enabled') && state['enabled'] is bool) - state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint', { 'enabled': !state['enabled'] }); + state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint', + params: { 'enabled': !state['enabled'] }); return state; } // Reload related extension methods. Future> flutterReassemble() async { - return await invokeFlutterExtensionRpcRaw('ext.flutter.reassemble'); + return await invokeFlutterExtensionRpcRaw('ext.flutter.reassemble', + timeout: kLongRequestTimeout); } Future flutterFrameworkPresent() async { @@ -851,7 +852,7 @@ class Isolate extends ServiceObjectOwner { Future> flutterEvictAsset(String assetPath) async { return await invokeFlutterExtensionRpcRaw('ext.flutter.evict', - { + params: { 'value': assetPath } );