Unverified Commit 705811fe authored by Gary Roumanis's avatar Gary Roumanis Committed by GitHub

Fix launching DevTools with Flutter Web applications (#72110)

parent 918100f8
......@@ -808,6 +808,11 @@ class _ResidentWebRunner extends ResidentWebRunner {
});
websocketUri = Uri.parse(_connectionResult.debugConnection.uri);
device.vmService = _vmService;
// Update caches to enable the FlutterVmService extensions.
setHttpAddress(_httpUriFromWebsocketUri(websocketUri), device.vmService);
setWsAddress(websocketUri, device.vmService);
// Always run main after connecting because start paused doesn't work yet.
if (!debuggingOptions.startPaused || !supportsServiceProtocol) {
_connectionResult.appConnection.runMain();
......@@ -859,4 +864,10 @@ class _ResidentWebRunner extends ResidentWebRunner {
await device.exitApps();
appFinished();
}
Uri _httpUriFromWebsocketUri(Uri websocketUri) {
const String wsPath = '/ws';
final String path = websocketUri.path;
return websocketUri.replace(scheme: 'http', path: path.substring(0, path.length - wsPath.length));
}
}
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'package:file/file.dart';
import 'package:meta/meta.dart' show required, visibleForTesting;
import 'package:meta/meta.dart' show required;
import 'package:vm_service/vm_service.dart' as vm_service;
import 'base/context.dart';
......@@ -152,13 +152,17 @@ final Expando<Uri> _httpAddressExpando = Expando<Uri>();
final Expando<Uri> _wsAddressExpando = Expando<Uri>();
@visibleForTesting
void setHttpAddress(Uri uri, vm_service.VmService vmService) {
if(vmService == null) {
return;
}
_httpAddressExpando[vmService] = uri;
}
@visibleForTesting
void setWsAddress(Uri uri, vm_service.VmService vmService) {
if(vmService == null) {
return;
}
_wsAddressExpando[vmService] = uri;
}
......
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