Repository navigation
Teach flutter_tools how to use mDNS to find the iOS observatory port #23164
Description
flutter-team-archive/engine#6533 added the ability to have iOS apps advertise the Dart observatory port over mDNS. The following command on macOS can display that information:
dns-sd -Z _dartobservatory._tcpwhich has output similar to the following:
Browsing for _dartobservatory._tcp
DATE: ---Tue 16 Oct 2018---
11:00:09.974 ...STARTING...
; To direct clients to browse a different domain, substitute that domain in place of '@'
lb._dns-sd._udp PTR @
; In the list of services below, the SRV records will typically reference dot-local Multicast DNS names.
; When transferring this zone file data to your unicast DNS server, you'll need to replace those dot-local
; names with the correct fully-qualified (unicast) domain name of the target host offering the service.
_dartobservatory._tcp PTR com\.example\.iosTestMod@dans-iphone\.local._dartobservatory._tcp
com\.example\.iosTestMod@dans-iphone\.local._dartobservatory._tcp SRV 0 0 49198 Dans-iPhone.local. ; Replace with unicast FQDN of target host
com\.example\.iosTestMod@dans-iphone\.local._dartobservatory._tcp TXT ""
indicating the observatory port is running on 49198 from the SRV record. Running flutter attach --debug-port 49198 will successfully attach to that observatory port.
Unfortunately, dns-sd is not suitable for scripting (it never "finishes" processing, the output and command flags are explicitly not guaranteed), and we'd like to avoid adding more Ruby/Python/etc. scripts to support this.
Writing the mDNS query in Dart (particularly on macOS) is currently blocked by dart-lang/sdk#34799. A patch has been created, and using that source I've been able to successfully query the service using Dart on macOS.
Once that lands, we should be able to either implement mDNS in the Dart SDK (e.g. in dart:io), or at least have a simple client in the flutter_tools package that can discover the port automatically for flutter attach without any additional steps.
Activity
dnfield commentedon Oct 18, 2018
Once flutter/packages#7 lands, we should be able to consume it in
flutter_tools. From there it should be pretty straightforward.Hixie commentedon Nov 21, 2018
Moving to bucket12 due to code freeze.
dnfield commentedon Dec 19, 2018
This will require some changes upstream in Dart - I'm working on those, but it will take into January to get to it.
DanTup commentedon Dec 19, 2018
Is this iOS-only, or will it help Android? If Android, will it remove the reliance on
logcatentirely? #25455 shows a device wherelogcatjust stops streaming anything towards the end of boot, which means Flutter is never able to get the VM port (and I'm out of ideas for debugging!).matthew-carroll commentedon Dec 19, 2018
@DanTup Android should be able to utilize ADB directly via Intents which is much simpler than this iOS solution. I've been waiting for the iOS side to finish before worrying about Android because the Android path seems highly confident, whereas the iOS approach has changed a number of times and is still in flux.
1 remaining item
dnfield commentedon Jan 16, 2019
Depends on https://dart-review.googlesource.com/c/sdk/+/89164
dnfield commentedon Feb 6, 2019
This is waiting for Dart to catch up in google3. Updating milestone to March.
jonahwilliams commentedon Feb 15, 2019
I believe this landed, closing!
jonahwilliams commentedon Feb 15, 2019
My bad!
ventureli commentedon May 21, 2020
The mDNS query for an attached iOS device failed. It may be necessary to disable the "Personal Hotspot" on the device, and to ensure that the "Disable unless needed" setting is unchecked under System Preferences > Network > iPhone USB. See #46698 for details.
Waiting for a connection from Flutter on iPhone 11 Pro Max...
I use simulator always get this message,what's wrong?
github-actions commentedon Aug 21, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.