From 8f93c46c3a6289c5ce93a57c0b54898d1457fc61 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 5 Sep 2019 18:21:10 -0700 Subject: [PATCH 1/2] register reload sources call and make 'r' restart --- .../lib/src/build_runner/resident_web_runner.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart index 6b94a71365d61e..c34baa946a364e 100644 --- a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'package:dwds/dwds.dart'; +import 'package:flutter_tools/src/base/common.dart' as prefix0; import 'package:meta/meta.dart'; import 'package:vm_service/vm_service.dart' as vmservice; @@ -212,6 +213,8 @@ class ResidentWebRunner extends ResidentRunner { printStatus(message); } }); + //prefix0.unawaited(future) + unawaited(_debugConnection.vmService.registerService('reloadSources', 'FlutterTools')); websocketUri = Uri.parse(_debugConnection.uri); } if (websocketUri != null) { @@ -232,9 +235,6 @@ class ResidentWebRunner extends ResidentRunner { String reason, bool benchmarkMode = false, }) async { - if (!fullRestart) { - return OperationResult(1, 'hot reload not supported on the web.'); - } final Stopwatch timer = Stopwatch()..start(); final Status status = logger.startProgress( 'Performing hot restart...', From d5076c94d098ece3fb06cac5ace22477f18d09a9 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 5 Sep 2019 18:26:17 -0700 Subject: [PATCH 2/2] clean ups and test --- .../lib/src/build_runner/resident_web_runner.dart | 12 +----------- .../general.shard/resident_web_runner_test.dart | 15 ++++++++++----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart index c34baa946a364e..39fe79c37bf8f2 100644 --- a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart @@ -5,7 +5,6 @@ import 'dart:async'; import 'package:dwds/dwds.dart'; -import 'package:flutter_tools/src/base/common.dart' as prefix0; import 'package:meta/meta.dart'; import 'package:vm_service/vm_service.dart' as vmservice; @@ -44,11 +43,6 @@ class DwdsWebRunnerFactory extends WebRunnerFactory { } } -// TODO(jonahwilliams): remove this constant when the error message is removed. -// The web engine is currently spamming this message on certain pages. Filter it out -// until we remove it entirely. See flutter/flutter##37625. -const String _kBadError = 'WARNING: 3D transformation matrix was passed to BitmapCanvas.'; - /// A hot-runner which handles browser specific delegation. class ResidentWebRunner extends ResidentRunner { ResidentWebRunner(this.device, { @@ -208,12 +202,8 @@ class ResidentWebRunner extends ResidentRunner { if (supportsServiceProtocol) { _stdOutSub = _debugConnection.vmService.onStdoutEvent.listen((vmservice.Event log) { final String message = utf8.decode(base64.decode(log.bytes)).trim(); - // TODO(jonahwilliams): remove this error once it is gone from the engine #37625. - if (!message.contains(_kBadError)) { - printStatus(message); - } + printStatus(message); }); - //prefix0.unawaited(future) unawaited(_debugConnection.vmService.registerService('reloadSources', 'FlutterTools')); websocketUri = Uri.parse(_debugConnection.uri); } diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index f55ad5a9043d7f..fe17b99c0a36ae 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -114,21 +114,27 @@ void main() { )); final DebugConnectionInfo debugConnectionInfo = await connectionInfoCompleter.future; + verify(mockVmService.registerService('reloadSources', 'FlutterTools')).called(1); expect(bufferLogger.statusText, contains('Debug service listening on ws://127.0.0.1/abcd/')); expect(debugConnectionInfo.wsUri.toString(), 'ws://127.0.0.1/abcd/'); })); - test('Can not hot reload after attaching', () => testbed.run(() async { - _setupMocks(); + test('Can hot reload after attaching', () => testbed.run(() async { + _setupMocks(); final Completer connectionInfoCompleter = Completer(); unawaited(residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, )); await connectionInfoCompleter.future; + when(mockWebFs.recompile()).thenAnswer((Invocation _) async { + return true; + }); + when(mockVmService.callServiceExtension('hotRestart')).thenAnswer((Invocation _) async { + return Response.parse({'type': 'Success'}); + }); final OperationResult result = await residentWebRunner.restart(fullRestart: false); - expect(result.code, 1); - expect(result.message, contains('hot reload not supported on the web.')); + expect(result.code, 0); })); test('Can hot restart after attaching', () => testbed.run(() async { @@ -374,7 +380,6 @@ void main() { })); } - class MockWebDevice extends Mock implements Device {} class MockBuildDaemonCreator extends Mock implements BuildDaemonCreator {} class MockFlutterWebFs extends Mock implements WebFs {}