remove the flutter view cache; fix the ability to quit the app after a full restart (#11420)
* remove the flutter view cache; fix the ability to quit the app after a full restart * improve test * update test
This commit is contained in:
@@ -33,16 +33,11 @@ class FlutterDevice {
|
||||
DevFS devFS;
|
||||
ApplicationPackage package;
|
||||
|
||||
String _viewFilter;
|
||||
StreamSubscription<String> _loggingSubscription;
|
||||
|
||||
FlutterDevice(this.device);
|
||||
|
||||
String get viewFilter => _viewFilter;
|
||||
set viewFilter(String filter) {
|
||||
_viewFilter = filter;
|
||||
_viewsCache = null;
|
||||
}
|
||||
String viewFilter;
|
||||
|
||||
/// If the [reloadSources] parameter is not null the 'reloadSources' service
|
||||
/// will be registered.
|
||||
@@ -63,33 +58,22 @@ class FlutterDevice {
|
||||
}
|
||||
|
||||
Future<Null> refreshViews() async {
|
||||
if ((vmServices == null) || vmServices.isEmpty)
|
||||
if (vmServices == null || vmServices.isEmpty)
|
||||
return;
|
||||
for (VMService service in vmServices)
|
||||
await service.vm.refreshViews();
|
||||
_viewsCache = null;
|
||||
}
|
||||
|
||||
List<FlutterView> _viewsCache;
|
||||
List<FlutterView> get views {
|
||||
if (_viewsCache == null) {
|
||||
if ((vmServices == null) || vmServices.isEmpty)
|
||||
return null;
|
||||
final List<FlutterView> result = <FlutterView>[];
|
||||
if (_viewFilter == null) {
|
||||
for (VMService service in vmServices) {
|
||||
if (!service.isClosed)
|
||||
result.addAll(service.vm.views.toList());
|
||||
}
|
||||
} else {
|
||||
for (VMService service in vmServices) {
|
||||
if (!service.isClosed)
|
||||
result.addAll(service.vm.allViewsWithName(_viewFilter));
|
||||
}
|
||||
}
|
||||
_viewsCache = result;
|
||||
}
|
||||
return _viewsCache;
|
||||
if (vmServices == null)
|
||||
return <FlutterView>[];
|
||||
|
||||
return vmServices
|
||||
.where((VMService service) => !service.isClosed)
|
||||
.expand((VMService service) => viewFilter != null
|
||||
? service.vm.allViewsWithName(viewFilter)
|
||||
: service.vm.views)
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<Null> getVMs() async {
|
||||
@@ -115,9 +99,9 @@ class FlutterDevice {
|
||||
}
|
||||
|
||||
Future<Uri> setupDevFS(String fsName,
|
||||
Directory rootDirectory, {
|
||||
String packagesFilePath
|
||||
}) {
|
||||
Directory rootDirectory, {
|
||||
String packagesFilePath
|
||||
}) {
|
||||
// One devFS per device. Shared by all running instances.
|
||||
devFS = new DevFS(
|
||||
vmServices[0],
|
||||
|
||||
@@ -207,6 +207,10 @@ class VMService {
|
||||
final String streamId = data['streamId'];
|
||||
final Map<String, dynamic> eventData = data['event'];
|
||||
final Map<String, dynamic> eventIsolate = eventData['isolate'];
|
||||
|
||||
// Log event information.
|
||||
printTrace(data.toString());
|
||||
|
||||
ServiceEvent event;
|
||||
if (eventIsolate != null) {
|
||||
// getFromMap creates the Isolate if necessary.
|
||||
@@ -336,8 +340,7 @@ abstract class ServiceObject {
|
||||
// If we don't have a model object for this service object type, as a
|
||||
// fallback return a ServiceMap object.
|
||||
serviceObject ??= new ServiceMap._empty(owner);
|
||||
// We have now constructed an emtpy service object, call update to
|
||||
// populate it.
|
||||
// We have now constructed an empty service object, call update to populate it.
|
||||
serviceObject.update(map);
|
||||
return serviceObject;
|
||||
}
|
||||
@@ -717,6 +720,8 @@ class VM extends ServiceObjectOwner {
|
||||
Duration timeout,
|
||||
bool timeoutFatal: true,
|
||||
}) async {
|
||||
printTrace('$method: $params');
|
||||
|
||||
assert(params != null);
|
||||
timeout ??= _vmService._requestTimeout;
|
||||
try {
|
||||
@@ -1029,7 +1034,6 @@ class Isolate extends ServiceObjectOwner {
|
||||
return invokeRpcRaw('resume');
|
||||
}
|
||||
|
||||
|
||||
// Flutter extension methods.
|
||||
|
||||
// Invoke a flutter extension method, if the flutter extension is not
|
||||
@@ -1140,6 +1144,9 @@ class Isolate extends ServiceObjectOwner {
|
||||
return result['value'];
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'Isolate $id';
|
||||
}
|
||||
|
||||
class ServiceMap extends ServiceObject implements Map<String, dynamic> {
|
||||
|
||||
Reference in New Issue
Block a user