Commit 67377120 authored by Devon Carew's avatar Devon Carew Committed by GitHub

relax timeouts for some service protocol calls (#7468)

* relax timeouts for some service protocol calls

* remove 'note that' text
parent 4f9e5c8d
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert' show BASE64; 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/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:path/path.dart' as path;
import 'package:stream_channel/stream_channel.dart'; import 'package:stream_channel/stream_channel.dart';
import 'package:web_socket_channel/io.dart'; import 'package:web_socket_channel/io.dart';
...@@ -557,8 +557,7 @@ class VM extends ServiceObjectOwner { ...@@ -557,8 +557,7 @@ class VM extends ServiceObjectOwner {
} }
} }
// Note that this function does not reload the isolate if it found // This function does not reload the isolate if it's found in the cache.
// in the cache.
Future<Isolate> getIsolate(String isolateId) { Future<Isolate> getIsolate(String isolateId) {
if (!loaded) { if (!loaded) {
// Trigger a VM load, then get the isolate. Ignore any errors. // Trigger a VM load, then get the isolate. Ignore any errors.
...@@ -587,8 +586,8 @@ class VM extends ServiceObjectOwner { ...@@ -587,8 +586,8 @@ class VM extends ServiceObjectOwner {
/// Invoke the RPC and return a ServiceObject response. /// Invoke the RPC and return a ServiceObject response.
Future<ServiceObject> invokeRpc( Future<ServiceObject> invokeRpc(
String method, [Map<String, dynamic> params]) async { String method, { Map<String, dynamic> params, Duration timeout }) async {
Map<String, dynamic> response = await invokeRpcRaw(method, params); Map<String, dynamic> response = await invokeRpcRaw(method, params, timeout);
ServiceObject serviceObject = new ServiceObject._fromMap(this, response); ServiceObject serviceObject = new ServiceObject._fromMap(this, response);
if ((serviceObject != null) && (serviceObject._canCache)) { if ((serviceObject != null) && (serviceObject._canCache)) {
String serviceObjectId = serviceObject.id; String serviceObjectId = serviceObject.id;
...@@ -657,7 +656,7 @@ class VM extends ServiceObjectOwner { ...@@ -657,7 +656,7 @@ class VM extends ServiceObjectOwner {
String packages, String packages,
String assetsDirectory) { String assetsDirectory) {
return invokeRpc('_flutter.runInView', return invokeRpc('_flutter.runInView',
<String, dynamic> { params: <String, dynamic> {
'viewId': viewId, 'viewId': viewId,
'mainScript': main, 'mainScript': main,
'packagesFile': packages, 'packagesFile': packages,
...@@ -683,7 +682,7 @@ class VM extends ServiceObjectOwner { ...@@ -683,7 +682,7 @@ class VM extends ServiceObjectOwner {
} }
Future<Null> refreshViews() async { Future<Null> refreshViews() async {
await vmService.vm.invokeRpc('_flutter.listViews'); await vmService.vm.invokeRpc('_flutter.listViews', timeout: kLongRequestTimeout);
} }
FlutterView get mainView { FlutterView get mainView {
...@@ -808,9 +807,9 @@ class Isolate extends ServiceObjectOwner { ...@@ -808,9 +807,9 @@ class Isolate extends ServiceObjectOwner {
// Invoke a flutter extension method, if the flutter extension is not // Invoke a flutter extension method, if the flutter extension is not
// available, returns null. // available, returns null.
Future<Map<String, dynamic>> invokeFlutterExtensionRpcRaw( Future<Map<String, dynamic>> invokeFlutterExtensionRpcRaw(
String method, [Map<String, dynamic> params]) async { String method, { Map<String, dynamic> params, Duration timeout }) async {
try { try {
return await invokeRpcRaw(method, params); return await invokeRpcRaw(method, params, timeout);
} on rpc.RpcException catch (e) { } on rpc.RpcException catch (e) {
// If an application is not using the framework // If an application is not using the framework
if (e.code == rpc_error_code.METHOD_NOT_FOUND) if (e.code == rpc_error_code.METHOD_NOT_FOUND)
...@@ -832,13 +831,15 @@ class Isolate extends ServiceObjectOwner { ...@@ -832,13 +831,15 @@ class Isolate extends ServiceObjectOwner {
Future<Map<String, dynamic>> flutterToggleDebugPaintSizeEnabled() async { Future<Map<String, dynamic>> flutterToggleDebugPaintSizeEnabled() async {
Map<String, dynamic> state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint'); Map<String, dynamic> state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint');
if (state != null && state.containsKey('enabled') && state['enabled'] is bool) if (state != null && state.containsKey('enabled') && state['enabled'] is bool)
state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint', <String, dynamic>{ 'enabled': !state['enabled'] }); state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint',
params: <String, dynamic>{ 'enabled': !state['enabled'] });
return state; return state;
} }
// Reload related extension methods. // Reload related extension methods.
Future<Map<String, dynamic>> flutterReassemble() async { Future<Map<String, dynamic>> flutterReassemble() async {
return await invokeFlutterExtensionRpcRaw('ext.flutter.reassemble'); return await invokeFlutterExtensionRpcRaw('ext.flutter.reassemble',
timeout: kLongRequestTimeout);
} }
Future<bool> flutterFrameworkPresent() async { Future<bool> flutterFrameworkPresent() async {
...@@ -851,7 +852,7 @@ class Isolate extends ServiceObjectOwner { ...@@ -851,7 +852,7 @@ class Isolate extends ServiceObjectOwner {
Future<Map<String, dynamic>> flutterEvictAsset(String assetPath) async { Future<Map<String, dynamic>> flutterEvictAsset(String assetPath) async {
return await invokeFlutterExtensionRpcRaw('ext.flutter.evict', return await invokeFlutterExtensionRpcRaw('ext.flutter.evict',
<String, dynamic>{ params: <String, dynamic>{
'value': assetPath 'value': assetPath
} }
); );
......
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