Skip to content

Commit b41c8e0

Browse files
authored
Fix bug with debugging support code not getting injected on edge devices (flutter#168073)
This PR addresses [flutter#167102](flutter#167102), where debugging support code was not being properly injected when running on Edge `flutter run -d edge`. The issue was due to missing conditions in the injection logic that prevented the debugger service from initializing correctly in this environment. This change ensures that debugging support is consistently injected when connected devices are present and the user has selected one of them. fix flutter#167102.
1 parent 3c6f74c commit b41c8e0

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

packages/flutter_tools/lib/src/isolated/devfs_web.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@ class WebAssetServer implements AssetReader {
374374
logging.Logger.root.level = logging.Level.ALL;
375375
logging.Logger.root.onRecord.listen(log);
376376

377+
// Retrieve connected web devices.
378+
final List<Device>? devices = await globals.deviceManager?.getAllDevices();
379+
final Set<String> connectedWebDeviceIds =
380+
devices
381+
?.where((Device d) => d.platformType == PlatformType.web && d.isConnected)
382+
.map((Device d) => d.id)
383+
.toSet() ??
384+
<String>{};
385+
377386
// In debug builds, spin up DWDS and the full asset server.
378387
final Dwds dwds = await dwdsLauncher(
379388
assetReader: server,
@@ -424,10 +433,12 @@ class WebAssetServer implements AssetReader {
424433
),
425434
appMetadata: AppMetadata(hostname: hostname),
426435
),
427-
// Defaults to 'chrome' if deviceManager or specifiedDeviceId is null,
428-
// ensuring the condition is true by default.
436+
// Inject the debugging support code if connected web devices are present,
437+
// and user specified a device id that matches a connected web device.
438+
// If the user did not specify a device id, we use chrome as the default.
429439
injectDebuggingSupportCode:
430-
(globals.deviceManager?.specifiedDeviceId ?? 'chrome') == 'chrome',
440+
connectedWebDeviceIds.isNotEmpty &&
441+
connectedWebDeviceIds.contains(globals.deviceManager?.specifiedDeviceId ?? 'chrome'),
431442
);
432443
shelf.Pipeline pipeline = const shelf.Pipeline();
433444
if (enableDwds) {

0 commit comments

Comments
 (0)