Repository navigation
No way to differentiate between Dart VMs per device with mDNS #130623
Copy link
Copy link
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listplatform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Have 2 devices
- Run flutter app through Xcode on Device 1
- Run
flutter attachin project directory, when it prompts you to select a device, pick Device 2
Note: There are other ways in which this can occur, but this is just an easy way to recreate
Actual results
You'll eventually get an error like
Waiting for a connection from Flutter on iPhone SE (3rd generation)...
Connecting to the VM Service is taking longer than expected...
Still attempting to connect to the VM Service...
If you do NOT see the Flutter application running, it might have crashed. The device logs (e.g. from adb or XCode)
might have more details.
If you do see the Flutter application running on the device, try re-running with --host-vmservice-port to use a
specific port known to be available.
Exception attempting to connect to the VM Service: SocketException: Connection refused (OS Error: Connection refused,
errno = 61), address = 127.0.0.1, port = 58122
Behind the scenes, it's using mDNS to find the Dart VM. It finds the Dart VM from device 1 and tries to connect to it using Device 2, which obviously doesn't work.
We should differentiate Dart VMs per device.
Logs
Logs
<!-- Paste your logs here -->
Flutter Doctor output
Doctor output
[!] Flutter (Channel [user-branch], 3.13.0-3.0.pre.32, on macOS 13.4.1 22F82 darwin-arm64, locale en)
! Flutter version 3.13.0-3.0.pre.32 on channel [user-branch] at xxx
Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
If that doesn't fix the issue, reinstall Flutter by following instructions at
https://flutter.dev/docs/get-started/install.
! Upstream repository unknown source is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
• Framework revision 8e80663640 (27 hours ago), 2023-07-13 10:50:24 -0700
• Engine revision 88b8581516
• Dart version 3.1.0 (build 3.1.0-307.0.dev)
• DevTools version 2.25.0
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git"
directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at xxx
• Platform android-33, build-tools 33.0.0
• ANDROID_SDK_ROOT = xxx
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A5195m
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
[✓] VS Code (version 1.80.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.68.0
[✓] Connected device (4 available)
[✓] Network resources
• All expected network resources are available.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listplatform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Activity
huycozy commentedon Jul 17, 2023
Hi @vashworth
Are you seeing this issue with two physical devices?
I checked this issue on a physical device and an emulator. But I received a different error message in stack trace as below. Is this another issue?
vashworth commentedon Jul 17, 2023
@huycozy Yeah I used two physical devices. I would image it's probably the same problem if you use two simulator or one physical device and one simulator - it doesn't differentiate Dart VMs per device.
huycozy commentedon Jul 18, 2023
I still can not attach when using one physical and one emulator device (I have only one physical device).
But when I tried this again with two emulators, this time I got another issue:
Using the first suggested command will make
attachwork. This looks similar to a case mentioned at #122698 (comment). Labeling the issue to have more information.stuartmorgan-g commentedon Jul 24, 2023
Per offline discussion, while the repro case here is with iOS, the issue is with the selection/attach logic more generally.
1 remaining item
flutter-triage-bot commentedon Mar 20, 2024
This issue is marked P1 but has had no recent status updates.
The P1 label indicates high-priority issues that are at the top of the work list. This is the highest priority level a bug can have if it isn't affecting a top-tier customer or breaking the build. Bugs marked P1 are generally actively being worked on unless the assignee is dealing with a P0 bug (or another P1 bug). Issues at this level should be resolved in a matter of months and should have monthly updates on GitHub.
Please consider where this bug really falls in our current priorities, and label it or assign it accordingly. This allows people to have a clearer picture of what work is actually planned. Thanks!
vashworth commentedon Mar 20, 2024
We were able to figure out a imperfect, but good enough workaround
flutter/packages/flutter_tools/lib/src/mdns_discovery.dart
Lines 279 to 282 in 274152f
Deprioritizing.