Commit 59cacd71 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Some fixes for the microbenchmarks (#7781)

* Return null from VM.mainView if no view exists
* Retry in connectToServiceProtocol if a view is not yet available
* Do not explicitly call exit from the benchmarks - it will not cleanly shut down the engine
parent fe01c71c
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'data/velocity_tracker_data.dart'; import 'data/velocity_tracker_data.dart';
...@@ -33,5 +32,4 @@ void main() { ...@@ -33,5 +32,4 @@ void main() {
name: 'velocity_tracker_iteration', name: 'velocity_tracker_iteration',
); );
printer.printToStdout(); printer.printToStdout();
exit(0);
} }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -102,6 +101,4 @@ Future<Null> main() async { ...@@ -102,6 +101,4 @@ Future<Null> main() async {
name: 'stock_animation_subsequent_frame_average', name: 'stock_animation_subsequent_frame_average',
); );
printer.printToStdout(); printer.printToStdout();
exit(0);
} }
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -47,5 +46,4 @@ Future<Null> main() async { ...@@ -47,5 +46,4 @@ Future<Null> main() async {
name: 'stock_build_iteration', name: 'stock_build_iteration',
); );
printer.printToStdout(); printer.printToStdout();
exit(0);
} }
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -46,5 +45,4 @@ Future<Null> main() async { ...@@ -46,5 +45,4 @@ Future<Null> main() async {
name: 'stock_layout_iteration', name: 'stock_layout_iteration',
); );
printer.printToStdout(); printer.printToStdout();
exit(0);
} }
...@@ -15,6 +15,7 @@ import 'base/io.dart'; ...@@ -15,6 +15,7 @@ import 'base/io.dart';
import 'asset.dart'; import 'asset.dart';
import 'base/common.dart';
import 'base/logger.dart'; import 'base/logger.dart';
import 'build_info.dart'; import 'build_info.dart';
import 'dart/dependencies.dart'; import 'dart/dependencies.dart';
...@@ -172,8 +173,15 @@ abstract class ResidentRunner { ...@@ -172,8 +173,15 @@ abstract class ResidentRunner {
// Refresh the view list. // Refresh the view list.
await vmService.vm.refreshViews(); await vmService.vm.refreshViews();
for (int i = 0; vmService.vm.mainView == null && i < 5; i++) {
// If the VM doesn't yet have a view, wait for one to show up.
printTrace('Waiting for Flutter view');
await new Future<Null>.delayed(new Duration(seconds: 1));
await vmService.vm.refreshViews();
}
currentView = vmService.vm.mainView; currentView = vmService.vm.mainView;
assert(currentView != null); if (currentView == null)
throwToolExit('No Flutter view is available');
// Listen for service protocol connection to close. // Listen for service protocol connection to close.
vmService.done.whenComplete(() { vmService.done.whenComplete(() {
......
...@@ -686,7 +686,7 @@ class VM extends ServiceObjectOwner { ...@@ -686,7 +686,7 @@ class VM extends ServiceObjectOwner {
} }
FlutterView get mainView { FlutterView get mainView {
return _viewCache.values.first; return _viewCache.values.isEmpty ? null : _viewCache.values.first;
} }
} }
......
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