New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binding to multicast socket fails in iOS >= 11.0 #42250
Comments
Error seems to be coming from this bit of native code EDIT: actual native code described here: #42250 (comment) |
@zanderso do you happen to know the best person to poke about this? |
Thanks for reporting. Let me assign myself first! |
@bugeats From your description, I think this is a problem of iOS instead of Dart. If it worked on iOS 10.3, it means our setup is good and something internal has changed since 10.3. But I was not able to find the relative docs or articles. Apple doesn't have a clear documentation on low-level POSIX APIs. |
@zichangg I opened a Feedback Assistant issue with Apple yesterday and pointed them to this ticket. I also reviewed iOS change logs and documentation and didn't find any mention of changes to POSIX sockets or anything like that. My hope is that someone familiar with the Dart native internals like |
@bugeats - it boils down to sdk/runtime/bin/socket_base_macos.cc Lines 447 to 448 in 97e291b
It is possible that if you only tested this on the simulator, yo uwere actually using more like the host API than iOS API. Did this work for you on an iOS 10.3 device? |
@dnfield I only tested simulators, bisecting iOS versions until I arrived at 10.3. This was after I discovered the failure on my 13.5 physical device. I'm going to go grab an old iPhone and install 10.3, but I suspect the simulator is a red herring. EDIT: I'm afraid Apple does not allow downgrading devices. I can't repro on a 10.3 physical device without going down a jailbreak rabbit hole, and ain't nobody got time for that. |
I meet the same problem, my iPhone version is 11.2.6; but the test on the Android phone is normal |
Any Time Frame on a fix for this, It's a blocking issue for me atm. |
Same here - this issue also extends to macOS, meaning any app that requires UDP multicasting/broadcasting can't be ported to any Apple devices. |
@hacker1024 Which version of macOS you are running? Can you also provide a piece of reproduction code if possible? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hey all I finally got a response from the Apple ticket I submitted a month ago. Here it is verbatim:
|
@bugeats Our network interfaces are definitely up, I made sure of that as that seems to cause this issue in unrelated apps. @zichangg I'm on Big Sur Beta 2, so perhaps it's only broken in that version. For sample code, I'm calling the following method in the UDP.bind(Endpoint.broadcast(port: 2925)); I tried a range of ports, including 25565 (which I know the Minecraft server binds to for UDP broadcasts), so I don't think the port has anything to do with it - some people report that the port can cause the error in other non-Flutter circumstances. |
Just tried reproducing on xcode 11.3 simulator, but it seems to work fine.
and it seems to work fine(after I accept pop-up permissions dialog):
|
@aam simulator always fine on my side, but physical device is not |
@CimZzz are you able to run repro sample from above on your device? Can you share the output/how does it fail? |
I tried it in my current project and I also get an error 49. But i get the name of the network interface (en0) and an ip address, so the answer @bugeats did get from apple is not 100% correct I assume. |
Looks like no evidence proves this is a VM bug. I'll unassign myself first. |
dart is 2.9.3 error is below: 2020-09-27 18:21:00.870410+0800 Runner[852:721510] flutter: InternetAddress('224.0.0.251', IPv4) |
this entitlement requires ios 14.0+, my ios is 13.7; |
This issue exists on my super old iPad 3 which does not update beyond iOS 9.3.6. I bet the issue is not about iOS version, but the macOS/iOS specifics, which is already mentioned in the code. Take a look at the sdk/sdk/lib/_internal/vm/bin/socket_patch.dart Lines 1343 to 1345 in 318babd
Since both macOS and iOS share the same underlying native implementation it should be: if ((Platform.isMacOS || Platform.isIOS) && addr.type == InternetAddressType.IPv4) { Someone asked if it ever worked in iOS. Well you can make it work right now. Joining a multicast group is actually setting special socket option. // Join multicast on this interface.
// _incoming.joinMulticast(_mDnsAddress, interface);
final value = Uint8List.fromList(_mDnsAddress.rawAddress + interface.addresses[0].rawAddress);
_incoming.setRawOption(RawSocketOption(RawSocketOption.levelIPv4, 12, value)); |
The socket implementation has a workaround for MacOS, which is also required on iOS. @alexbatalov suggested this fix in #42250 (comment). Verified on iPhone 11 with iOS 14.6. Bug: http://dartbug.com/42250 TEST=Existing test base. Manually verified on iOS Change-Id: I9942ccaf3bdd65e04842a38697eadc19feb317d9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206020 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com> Auto-Submit: Marcin Radomski <dextero@google.com>
Starting with iOS 11.0 the
dart:io
network interface library fails with an OS error when trying to join a multicast group:I have confirmed that the above works as expected with Flutter in Linux, and on an iOS simulator running 10.3.
This bug affects the Flutter multicast_dns package as described in flutter/flutter#42102 , but it appears to be fundamentally a Dart SDK issue. As of this moment, the current version of iOS is 13.5.1 so this regression has snuck by several major updates.
The text was updated successfully, but these errors were encountered: