flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.8k stars 27.16k forks source link

iOS mDNS meta issue #46705

Open zanderso opened 4 years ago

zanderso commented 4 years ago

This issue tracks the problems that have been observed with mDNS lookup for iOS.

If your mDNS issue does not fall into one of those four categories then please comment here with detailed information about your setup including:

Thanks!

zanderso commented 4 years ago

For additional context, from analytics we're seeing iOS mDNS lookup fail, and then the fallback to the log reader fail for about 6% of attempts.

jonahwilliams commented 4 years ago

To help users figure out what is going on here, it might be best to start with a simple FAQ of the known cases such as:

Then catch the mDNS errors and add this link to the tool exit. FYI @sfshaza2

donaldww commented 4 years ago

I ended up here after looking through a series of closed issues. I'm getting the following error when running a debug app on IOS hardware:

Failed to establish a debug connection with 00008020-001C29212130003A using mdns: Invalid argument(s): Cannot find executable for /Users/donaldwilson/flutter/bin/cache/artifacts/usbmuxd/iproxy.

macOS 10.15.1 iOS 13.3 iPhone XR Xcode 11.3 (11C29)

The iphone is plugged directly into the iMac using a USB cable. 'Connect via network' option in Xcode is turned off.

[✓] Flutter (Channel master, v1.13.1-pre.99, on Mac OS X 10.15.1 19B88, locale en-CA) • Flutter version 1.13.1-pre.99 at /Users/donaldwilson/flutter • Framework revision 354f80b84a (4 hours ago), 2019-12-11 16:36:03 -0800 • Engine revision 12bf95fd49 • Dart version 2.7.0 (build 2.7.0-dev.2.1 8b8894648f)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0) • Android SDK at /Users/donaldwilson/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.0 • Java binary at: /Users/donaldwilson/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/192.6018865/Android Studio 3.6 Preview.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3, Build version 11C29 • CocoaPods version 1.8.4

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio • Android Studio at /Users/donaldwilson/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/192.6018865/Android Studio 3.6 Preview.app/Contents • Flutter plugin version 42.1.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3) • IntelliJ at /Users/donaldwilson/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app • Flutter plugin version 42.1.4 • Dart plugin version 193.5731

[✓] VS Code (version 1.40.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.6.0

[✓] Connected device (6 available) • AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator) • Donald’s iPhone • 00008020-001C29212130003A • ios • iOS 13.3 • iPhone 11 Pro Max • B680789E-5FCF-4F00-81F3-5AF749B6F45A • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator) • macOS • macOS • darwin-x64 • Mac OS X 10.15.1 19B88 • Chrome • chrome • web-javascript • Google Chrome 78.0.3904.108 • Web Server • web-server • web-javascript • Flutter Tools

• No issues found! Process finished with exit code 0

I don't know about a dialog that allows Dart connections.

All of my connected devices work, except for the physical iPhone debugging. It worked perfectly under IOS 12.

One thing I would note: it takes a long time for flutter to "install and launch" on the iPhone. Loading used to be quite fast before the current troubles began.

Thanks, DW

zanderso commented 4 years ago

Hi @donaldww, your issue appears to be the missing artifact:

Invalid argument(s): Cannot find executable for /Users/donaldwilson/flutter/bin/cache/artifacts/usbmuxd/iproxy

I'm afraid I don't know how you got into that state, but maybe @christopherfujino can give the best advice on how to get back into a good state.

christopherfujino commented 4 years ago

@donaldww your issue is unrelated to this issue, however we have seen cases of this happening. I just opened a new issue for this, it would be great if you could post there (please include the contents of your libimobiledevice.stamp file, which you can get with cat /Users/donaldwilson/flutter/bin/cache/libimobiledevice.stamp). Thanks!

zanderso commented 4 years ago

@donaldww @christopherfujino I'll mark this discussion hidden here since it is unrelated. Thanks!

jonahwilliams commented 4 years ago

Another data point: The google3 issues are caused by the dart_darwin binary not being signed.

gitgeekaus commented 4 years ago

@zanderso for #47184, I don't have personal hotspot on, I didn't turn on firewall, so its weird. Let me know if you need any other infomation

stx commented 4 years ago

@gitgeekaus Are you on Catalina? Go to System Preferences > Network > iPhone USB > uncheck "Disable unless needed" > Apply. This was the problem for me.

If iPhone USB isn't there, you might need to turn on hotspot in order to get it to appear in order to uncheck that setting. The setting applies with or without hotspot on, and when it is on it will cause mDNS lookup failure.

gitgeekaus commented 4 years ago

Thank @stx, I am still on Mojave, and under System Preferences > Network I have both iPhone USB 3 and iPhone USB 10 showing the status of Not connected. I did do as you said to uncheck "Disable unless needed", but it still not working

nashfive commented 4 years ago

I am on Mojave too, with Flutter 1.9.1 and a iPhoneX on iOS 13.

No matter what I tried to fiddle with (firewall with the Dart binary rule, hotspot, iPhone USB network settings...) It never works and I always have the mdns exception (did not find a observatory port advertised) and the app doesn't start (stuck at the native splash). Also tried with many combinations : no connection/WiFi/Ethernet on the macbook and Airplane/4G/WiFi on the device, to no avail.

Same setup but with a iPhone 11, everything works, even though I still have the mdns exception about the observatory port, but this time, the app launches correctly and I can see my debug logs (using the dart:developer log method).

With Catalina (another macbook), I have no issues deploying to my iPhone iOS 13, hotspot is ON, firewall is ON (incoming connections accepted via the popup). It works correctly with Flutter stable versions 1.12.13 and 1.9.1.

Sounds like a bad mix of macOS and iOS versions. Maybe Flutter's version is also adding something to the mix too 🤯

mennorenkens commented 4 years ago

@gitgeekaus Are you on Catalina? Go to System Preferences > Network > iPhone USB > uncheck "Disable unless needed" > Apply. This was the problem for me.

If iPhone USB isn't there, you might need to turn on hotspot in order to get it to appear in order to uncheck that setting. The setting applies with or without hotspot on, and when it is on it will cause mDNS lookup failure.

This did the trick for me :) thanks a lot! I only unchecked the 'disable unless needed'. Did not do anything else with hotspot.

nashfive commented 4 years ago

Ok I did some more tests on my side about this issue.

Mojave, Flutter 1.9 stable and iOS 13 device => FAIL. I have never been able to do live debug, no matter if I enable/disable the firewall, the hotspot or the USB network connection.

I upgraded to Catalina, kept Flutter 1.9 => FAIL. Same problem.

I finally upgraded to Flutter 1.12 => SUCCESS on all my devices 💯

john-yick commented 4 years ago

I am also hitting this issue again now...

[   +2 ms] mDNS lookup failed, attempting fallback to reading device log.
[        ] Waiting for observatory port.

Tested these settings and it still does not work:

flutter doctor -v

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-GB)
    • Flutter version 1.12.13+hotfix.5 at /Users/xx/Documents/flutter
    • Framework revision 27321ebbad (5 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.8.4

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[✓] VS Code (version 1.41.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (1 available)
    • iPhone • a18cfc5923052375f4d435b94ea205619f16da79 • ios • iOS 13.3

This issue has been kicking around for a few months now, would be good to know when we can expect Flutter to be stable again.

zanderso commented 4 years ago

@john-yick We're working on some improvements to the vm service handshake that will hopefully let us use mdns only as a fallback https://github.com/flutter/flutter/issues/46724.

stefanhenseler commented 4 years ago

I had this issue several times in the last couple of months (in multiple different flutter versions). After trying all the suggested workarounds, I was able to narrow it down to the iPhone Hotspot being enabled. If I disable the Hotspot, it works without issues, at least in my case this seems to be it :).

❯ flutter doctor -v                
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-CH)
    • Flutter version 1.12.13+hotfix.5 at /Users/stefan/flutter
    • Framework revision 27321ebbad (7 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/stefan/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.41.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (1 available)
    • synax_mobile • a492df5ee130e1661d21fa53e7eb5f4852573ac7 • ios • iOS 13.3
jonahwilliams commented 4 years ago

We've recently landed some improvements to the process that should avoid using mDNS if possible. This was released with v1.15.3 which is currently on the dev channel.

ristiisa commented 4 years ago

We've recently landed some improvements to the process that should avoid using mDNS if possible. This was released with v1.15.3 which is currently on the dev channel.

I'm using mac mini and a windows machine at parallel for development. I use synergy for KVM and to minimize lag I had connected the two machines using a patch cable. I had also enabled "internet sharing" on the mac, when this setting is enabled running flutter run hangs mostly all the time. On dev channel this is the log:

[  +47 ms] Application launched on the device. Waiting for observatory port.
[   +9 ms] Attempting to forward device port 65353 to host port 1024
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1024 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[+1010 ms] Forwarded port ForwardedPort HOST:1024 to DEVICE:65353
[  +13 ms] HttpException: Connection closed before full header was received, uri = http://localhost:1024/ws
[+2012 ms] HttpException: , uri = http://localhost:1024/ws
[+2010 ms] HttpException: , uri = http://localhost:1024/ws
[+2010 ms] HttpException: , uri = http://localhost:1024/ws
[+2007 ms] HttpException: , uri = http://localhost:1024/ws
[+2006 ms] Failed to connect directly, falling back to mDNS
[   +3 ms] Checking for advertised Dart observatories...
[+5018 ms] No pointer records found.
[   +1 ms] mDNS query failed. Checking for an interface with a ipv4 link local address.
[   +1 ms] Found interface "en0":
[        ]  Bound address: "169.254.218.39" link local
[        ] Found interface "en1":
[        ]  Bound address: "192.168.1.178" 
[        ] Found interface "en5":
[        ]  Bound address: "172.20.10.2" 
[        ] Found interface "bridge100":
[        ]  Bound address: "192.168.2.1" 
[        ] An interface with an ipv4 link local address was found.
[        ] Failed to connect with mDNS, falling back to log scanning

If I disable "internet sharing" flutter run runs fine mosty all the time, but some times still hangs (this was with personal hotspot enabled):

[  +46 ms] Application launched on the device. Waiting for observatory port.
[   +6 ms] Attempting to forward device port 65353 to host port 1024
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1024 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[+1009 ms] Forwarded port ForwardedPort HOST:1024 to DEVICE:65353
[  +13 ms] HttpException: Connection closed before full header was received, uri = http://localhost:1024/ws
[+2007 ms] HttpException: , uri = http://localhost:1024/ws
[+2008 ms] HttpException: , uri = http://localhost:1024/ws
[+2010 ms] HttpException: , uri = http://localhost:1024/ws
[+2009 ms] HttpException: , uri = http://localhost:1024/ws
[+2006 ms] Failed to connect directly, falling back to mDNS
[   +3 ms] Checking for advertised Dart observatories...
[+5018 ms] No pointer records found.
[   +1 ms] mDNS query failed. Checking for an interface with a ipv4 link local address.
[   +1 ms] Found interface "en1":
[        ]  Bound address: "192.168.1.178" 
[        ] Found interface "en5":
[        ]  Bound address: "172.20.10.2" 
[   +1 ms] 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
https://github.com/flutter/flutter/issues/46698 for
           details.
[   +1 ms] Failed to connect with mDNS, falling back to log scanning

Running though vs code hangs mostly all the time...

Hejianghao commented 4 years ago

I remove my project from the disk, and git clone it again. And it's OK Now.

ristiisa commented 4 years ago

Flutter (Channel dev, v1.15.3, on Mac OS X 10.14.6 18G103, locale en-EE)

[  +62 ms] Application launched on the device. Waiting for observatory port.
[   +7 ms] Attempting to forward device port 65353 to host port 1024
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1024 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[  +14 ms] Attempting to forward device port 65353 to host port 1025
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1025 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[  +12 ms] Attempting to forward device port 65353 to host port 1026
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1026 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[  +11 ms] Attempting to forward device port 65353 to host port 1027
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1027 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[  +11 ms] Attempting to forward device port 65353 to host port 1028
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1028 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[  +12 ms] Attempting to forward device port 65353 to host port 1029
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1029 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[  +12 ms] Attempting to forward device port 65353 to host port 1030
[        ] executing: /Users/silver/flutter/bin/cache/artifacts/usbmuxd/iproxy 1030 65353 94c516d20a75ea2e12d02bf25e8e13fb8bbcd8cc
[+1005 ms] Forwarded port ForwardedPort HOST:1030 to DEVICE:65353
[  +15 ms] HttpException: Connection closed before full header was received, uri = http://localhost:1030/ws
[+2017 ms] HttpException: , uri = http://localhost:1030/ws
[+2009 ms] HttpException: , uri = http://localhost:1030/ws
[+2013 ms] HttpException: , uri = http://localhost:1030/ws
[+2009 ms] HttpException: , uri = http://localhost:1030/ws
[+2007 ms] Failed to connect directly, falling back to mDNS
[   +6 ms] Checking for advertised Dart observatories...
[+5024 ms] No pointer records found.
[   +1 ms] mDNS query failed. Checking for an interface with a ipv4 link local address.
[   +4 ms] An interface with an ipv4 link local address was found.
[        ] Failed to connect with mDNS, falling back to log scanning
jonahwilliams commented 4 years ago

My changes won't help the case with personal hotspot or other networking conditions that prevent iproxy from working at all unfortunately. We're still investigating what else we can do here

ristiisa commented 4 years ago

My changes won't help the case with personal hotspot or other networking conditions that prevent iproxy from working at all unfortunately. We're still investigating what else we can do here

What are the expected network conditions?

fredlee12345678 commented 4 years ago

flutter doctor -v [✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G95, locale zh-Hans-CN) • Flutter version 1.9.1+hotfix.6 at /Users/lixuepeng/Software/flutter • Framework revision 68587a0916 (5 months ago), 2019-09-13 19:46:58 -0700 • Engine revision b863200c37 • Dart version 2.5.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/lixuepeng/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME = /Users/lixuepeng/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3, Build version 11C29 • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 42.1.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 39.0.4 • Dart plugin version 192.7761

[✓] Connected device (1 available) • iPhone • 00008030-000D71511406802E • ios • iOS 13.3

• No issues found!

hostpot OFF. firewall OFF.

Checking for advertised Dart observatories...

Pending

briefguo commented 4 years ago

@gitgeekaus Are you on Catalina? Go to System Preferences > Network > iPhone USB > uncheck "Disable unless needed" > Apply. This was the problem for me.

If iPhone USB isn't there, you might need to turn on hotspot in order to get it to appear in order to uncheck that setting. The setting applies with or without hotspot on, and when it is on it will cause mDNS lookup failure.

It works for me. Thank you.

dgurudot commented 4 years ago

I switched to dev channel and started getting compiler errors to switched back to stable channel. Now, I stopped getting the following error

Failed to establish a debug connection with 71abd87bd654537024591e3131cb4fd1ade326c6 using mdns: Exception: Did not find a observatory port advertised for

but app is now stuck on "Installing and Launching". Sharing my flutter doctor -v output below:

vwork@vWork-iMac ~ % flutter doctor -v [✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.3 19D76, locale en-US) • Flutter version 1.12.13+hotfix.8 at /users/vwork/development/flutter • Framework revision 0b8abb4724 (4 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at /Users/vwork/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3.1, Build version 11C504 • CocoaPods version 1.8.4

[✓] Android Studio (version 3.6) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] Connected device (2 available) • VIPhone • 71abd87bd654537024591e3131cb4fd1ade326c6 • ios • iOS 13.3.1 • iPhone 11 • B5CCF2FF-CE75-4AE4-AFEB-A408C1460E32 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

• No issues found! vwork@vWork-iMac ~ %

dgurudot commented 4 years ago

I even tried enabling the hotspot and disabling the checkbox under network preferences as suggested above and it didn't help.

jonahwilliams commented 4 years ago

@dgurudot this is not fixed on the stable channel, it is only available on dev/master so this is entirely expected

karim-8 commented 4 years ago

Did anyone have a workaround for that, the logs was appearing then now dissapered and i even can't debug anymore in iOS 13 !

jmagman commented 4 years ago

Some notes: I was able to read the observatory port log line with ios-deploy by attaching to lldb with --debug instead of --justlaunch

ios-deploy --id <device-id> --bundle build/ios/iphoneos/Runner.app --debug  
...
(lldb)     connect
(lldb)     run
success
2020-03-17 17:32:39.410811-0700 Runner[633:132633] flutter: Observatory listening on http://127.0.0.1:55084/kiP-Z29onwQ=/

Or install and launch just the debugserver with --nolldb and store that port somewhere:

ios-deploy --id <device-id> --bundle build/ios/iphoneos/Runner.app --nolldb
...
-------------------------
debugserver port: 57168
App path: /private/var/containers/Bundle/Application/666A4C8D-C54D-4C55-8594-1E1FE56406CD/Runner.app

Then later attach to that port with --noinstall (which launches if it's not already running):

ios-deploy --id <device-id> --bundle build/ios/iphoneos/Runner.app --noinstall --port 57168 
...
(lldb)     connect
(lldb)     run
success
2020-03-17 17:35:05.399716-0700 Runner[636:133192] flutter: Observatory listening on http://127.0.0.1:55427/ifXCFq2E91c=/

And even when it's running, I was able to print the observatory port for a standard app (the FlutterController wouldn't necessarily by the rootViewController for add-to-app) by interrupting after interrupting the process (app would be briefly locked until resumed).

(lldb) process interrupt
Process 639 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00000001aa144198 libsystem_kernel.dylib`mach_msg_trap + 8
libsystem_kernel.dylib`mach_msg_trap:
->  0x1aa144198 <+8>: ret    

libsystem_kernel.dylib`mach_msg_overwrite_trap:
    0x1aa14419c <+0>: mov    x16, #-0x20
    0x1aa1441a0 <+4>: svc    #0x80
    0x1aa1441a4 <+8>: ret    
Target 0: (Runner) stopped.
(lldb)  po ((FlutterEngine *)[UIApplication.sharedApplication.keyWindow.rootViewController engine]).observatoryUrl.port
56889

(lldb) process continue
Process 639 resuming
VivianLinTY commented 4 years ago

I fixed the issue by turning on wifi.

markathomas commented 4 years ago

Just a heads up here. My issue was that I had NoMachine server running which binds to mDNS on same IPs and port as Flutter is trying to.

jmagman commented 4 years ago

@markathomas You can give port hints with--host-vmservice-port and --device-vmservice-port

ArtfulDodgerB92 commented 4 years ago

@gitgeekaus Are you on Catalina? Go to System Preferences > Network > iPhone USB > uncheck "Disable unless needed" > Apply. This was the problem for me.

If iPhone USB isn't there, you might need to turn on hotspot in order to get it to appear in order to uncheck that setting. The setting applies with or without hotspot on, and when it is on it will cause mDNS lookup failure.

On my Catalina system there is no "iphone USB" under System Preferences > Network. Even with the iphone connected via USB.

mdrideout commented 4 years ago

Just commenting that I am using a test iPhone device with no sim card. Disabling wifi on the iphone fixed the issue. This only works for me because I'm developing an offline app, but I was also unable to do the network thing from this comment https://github.com/flutter/flutter/issues/46705#issuecomment-566813481 because I don't have that option.

Edit: I guess what is actually fixing it is me toggling my iphone between being in and out of airplane mode. Any time it fails to install, I toggle airplane mode, and it will install.

Edit 2: I guess it's completely random when I can get it to work because this isn't consistently helping anymore.

haristhohir commented 4 years ago

@gitgeekaus Are you on Catalina? Go to System Preferences > Network > iPhone USB > uncheck "Disable unless needed" > Apply. This was the problem for me.

If iPhone USB isn't there, you might need to turn on hotspot in order to get it to appear in order to uncheck that setting. The setting applies with or without hotspot on, and when it is on it will cause mDNS lookup failure.

It works for me, Thanks.

ArtfulDodgerB92 commented 4 years ago

Just commenting that I am using a test iPhone device with no sim card. Disabling wifi on the iphone fixed the issue. This only works for me because I'm developing an offline app, but I was also unable to do the network thing from this comment #46705 (comment) because I don't have that option.

Edit: I guess what is actually fixing it is me toggling my iphone between being in and out of airplane mode. Any time it fails to install, I toggle airplane mode, and it will install.

This makes no difference for me at all, and the issue still persists.

ArtfulDodgerB92 commented 4 years ago

Any update with this one? Still getting this issue and possible solution comments have dried up completely.

theklayd commented 4 years ago

Updated my iOS from 13.3 to 13.4, this is the only solution that worked for me.

theklayd commented 4 years ago

Any update with this one? Still getting this issue and possible solution comments have dried up completely.

I have the same problem with yours. Whats your iOS version? mine is 13.3 updated it to 13.4, then suddenly worked great.

mdrideout commented 4 years ago

I'm on Catalina 10.15.4 with iOS 13.4.1 and still have this issue, with the latest version of xCode / Flutter stable / Android Studio / Pods / etc.

theklayd commented 4 years ago

This problem is very frustrating. Its working but eating "other" storage on my macOS Catalina

jmagman commented 4 years ago

@theklayd What exactly is consuming your storage? That is probably worth a new GitHub issue.

theklayd commented 4 years ago

@jmagman I found out that when I do "flutter run -v" its trashing a files on my trash, macOS Catalina

1rach commented 4 years ago

Yes, very annoying... I'am on Catalina, can't debug simply... I'm on the last tools (Catalina 10.15.4, Xcode 11.4.1) as @mdrideout. I have a cellular iPad 13.4.1. Initially I was on 13.3.1 and the debugging was working perfectly in vscode or android studio.

My error was to update my iPad to 13.4.1 :(.

I've done an iOS update with version > 13.3.1 few weeks ago, it was an error, but I realized the bug, I've downgraded my iPad to 13.3.1. Now it's impossible because Apple don't sign the iOS 13.3.1 firmware...and I've no saved my SHSH blob... and I've tested different flutter channel (beta, dev, master...).

I have a second Ipad not cellular With iOS 13.3.1 and debugging works perfectly, so I can confirm it works with or without cellular on iOS 13.3.1.

The solution wich consist to enable the hotspot and uncheck "Disable unless needed" is not stable for me : if i run "flutter run -v", sometimes (majority of cases) i get stuck on "Waiting for observatory port to be available the majority of time.".

The solution which works in 100% of cases, based on @jmagman commands :

I created two scripts :

RESULT : 0% error mDNS lookup failure on iOS, iPhone or iPad, all versions !!! YEAH !

AUTOMATISATION IN VSCODE

I created some tasks in visual studio code to automate all this stuff. Objective: press a key to launch the debugger and attach it to the correct url automatically. You can find these tasks in my tasks.json here.

I also adapted the launch.json file to launch the debugger in attached mode by providing it with the correct url.

I used the extension "Tasks: Shell input" because it is not possible without extension to launch shell scripts from attach section configuration in the file launch.json without extensions (am I wrong?).

How does it works ? 1 - Lauch the main task by pressing CTRL + SHIFT + P in VsCode 2 - Choose the task "1 - FLUTTER IOS DEBUG (getting observatoryUri first)" 3 - Wait few seconds ;) :

The debugger will be launched automaticlly.

Explanations : 1 - All tasks will be launched, and the ObservatoryUri url will be created in the file observatoryUri.txt. 2 - Vscode will be able to read this url before launching the debugger, then the debugger will be launched and attached to your device with this url.

The scripts can be optimized for sure, they just works. Feel free to comment and improve.

source code here : https://github.com/rachonzedev/flutter-debug-attach-ios

Happy debugging !

jonz-tech commented 4 years ago

To help users figure out what is going on here, it might be best to start with a simple FAQ of the known cases such as:

  • Public Wifi
  • Hotspot
  • Permission Dialog

Then catch the mDNS errors and add this link to the tool exit. FYI @sfshaza2

work for me after i close hotspot

1rach commented 4 years ago

@zanderso My contribution, hopping this bug will be solved (I like Flutter!) :

I did a lot of tests on my Ipad 7 cellular/Wifi with a valid SIM card :

On MacOS :

I'm behind a router with a DHCP, using dnsmasq if it is useful...

I did all the tests on all flutter channel : beta, dev, stable... And when switching channel, I created a new app each time.

I can't push more informations, but if you have some questions ;)

And i encontered this bug the majority of time... :( that's I switched to the tasks solution with iOS-deploy. no problem on a second Ipad iOS 13.3.1 (wifi).

chinmaygarde commented 4 years ago

Engine Triage: Unclear what the engine action items are. Removing that label. Please add it back if this is an error.

santervo commented 4 years ago

I have similar issue with iPad.

[+1011 ms] Forwarded port ForwardedPort HOST:1030 to DEVICE:56879
[  +15 ms] HttpException: Connection closed before full header was received, uri = http://localhost:1030/ws
[+2009 ms] HttpException: , uri = http://localhost:1030/ws
[+2010 ms] HttpException: , uri = http://localhost:1030/ws
[+2009 ms] HttpException: , uri = http://localhost:1030/ws
[+2007 ms] HttpException: , uri = http://localhost:1030/ws
[+2001 ms] Failed to connect directly, falling back to mDNS
[   +4 ms] Checking for advertised Dart observatories...
[+5020 ms] No pointer records found.
[   +2 ms] mDNS query failed. Checking for an interface with a ipv4 link local address.
[   +2 ms] Found interface "en0":
[        ]      Bound address: "192.168.1.75" 
[        ] Found interface "en7":
[        ]      Bound address: "169.254.30.75" link local
[        ] Found interface "utun2":
[        ]      Bound address: "10.8.0.14" 
[        ] An interface with an ipv4 link local address was found.
[        ] Failed to connect with mDNS, falling back to log scanning
jverhoeven commented 4 years ago

Just a heads up here. My issue was that I had NoMachine server running which binds to mDNS on same IPs and port as Flutter is trying to.

Please check this from @markathomas: I tried everything and uninstalling NoMachine finally did the trick for me. Thanks for sharing!

stevenspiel commented 4 years ago

MacOS 10.15.5 (Catalina) Flutter 1.17.4 iOS 13.5.1

I couldn't get to System Preferences > Network > iPhone USB because my carrier doesn't allow personal hotspots. I've searched all the forums I could find with this issue and the only thing that I've found that helps is to:

  1. Plug phone into Mac with USB
  2. Open the Music app and manually eject the phone
  3. Unplug phone and plug it back in
  4. flutter run ...

Screen Shot 2020-07-02 at 10 35 35 AM

Unfortunately, I have to do this frequently (every 3 or so flutter runs). Maybe there's a way to automate it, but I haven't looked into it.