Bug 44296 - Multicast not working on Android 7.0 devices
Summary: Multicast not working on Android 7.0 devices
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 7.0 (C8)
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Marek Habersack
Depends on:
Reported: 2016-09-14 15:09 UTC by Sid Dubey
Modified: 2016-10-28 19:36 UTC (History)
7 users (show)

Tags: XATriaged
Is this bug a regression?: ---
Last known good build:

Sample App for Repro (239.45 KB, application/x-zip-compressed)
2016-09-14 15:09 UTC, Sid Dubey
Screenshot on Android 7.0 device (76.17 KB, image/png)
2016-09-14 15:17 UTC, Sid Dubey
Screenshot on Android 5.0 device (288.06 KB, image/png)
2016-09-14 15:38 UTC, Sid Dubey
Version Information (1.92 KB, text/plain)
2016-09-14 17:25 UTC, Sid Dubey
Logs (65.49 KB, text/plain)
2016-09-14 17:26 UTC, Sid Dubey
Application Output (42.45 KB, text/plain)
2016-09-14 17:26 UTC, Sid Dubey

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Sid Dubey 2016-09-14 15:09:31 UTC
Created attachment 17463 [details]
Sample App for Repro

Multicast DNS discovery has worked flawlessly on all Android platforms up until 7.0 (API 24).  On Android 7.0, every single network interface reports back false, whereas on previous versions, the WIFI connection reports back true. 

A sample application which can reproduce the issue is attached. This sample Xamarin.Android app enumerates all the interfaces using System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(). And for each interface returned,  it checks the SupportsMulticast property. This property returns false for every network interface when the app is run on Android 7 devices.
Comment 1 Sid Dubey 2016-09-14 15:17:24 UTC
Created attachment 17464 [details]
Screenshot on Android 7.0 device
Comment 2 Sid Dubey 2016-09-14 15:38:36 UTC
Created attachment 17465 [details]
Screenshot on Android 5.0 device

As you can see here WLAN0 returns TRUE
Comment 3 Sid Dubey 2016-09-14 17:25:39 UTC
Created attachment 17471 [details]
Version Information
Comment 4 Sid Dubey 2016-09-14 17:26:01 UTC
Created attachment 17472 [details]
Comment 5 Sid Dubey 2016-09-14 17:26:22 UTC
Created attachment 17473 [details]
Application Output
Comment 6 Rob DeRosa 2016-09-29 19:49:53 UTC
From a customer:

"We have found that Bonjour browsing unexpectedly stops working on Android 7.0. After the investigation we’ve discovered, that the issue was related to usage of Wi-Fi network interface in general and it was caused by the changes in system WifiManager API.
To address the issue are now using the ConnectivityManager API.
We were using the WiFiManager API to get the WiFi MAC address to pick the proper network for mDNS search.
Starting in Android 6.0 the programmatic access to the WiFi MAC address was disable, thusly the WiFiManager doesn’t report the actual identifier. In Android 6.0 we had mechanism to use the first non-loopback interface if no interfaces were found with the current MAC. This would happen on Android 6.0.  For Android 7.0 the first loopback network interface is a fake, so it now fails.
Because of this we moved to the ConnectivityManager API for Android 5+ devices.  We can detect the WiFI interface without knowing the MAC address.
I don’t know how the lower level networking is handled by the Xamarin libraries, but from the behaviors exhibited I would assume it is similar. I’m passing this along in hopes that it will speed up the fix for the defect that we are waiting on for a fix."
Comment 7 Marek Habersack 2016-09-30 13:09:14 UTC
The original issue happens because Google disabled access to some files in the /sys/class/net/[INTERFACE] files (for instance "flags", "operstate") which are what we use to determine the status of the interface including its multicast capability.
I'm working on a different way to obtain the information from the system.
Comment 8 Marek Habersack 2016-09-30 14:17:40 UTC
Relevant upstream bug https://code.google.com/p/android/issues/detail?id=205565
Comment 9 Marek Habersack 2016-10-13 19:59:57 UTC
PRs with a fix/workaround are up: https://github.com/xamarin/xamarin-android/pull/261 and https://github.com/xamarin/monodroid/pull/522 - once those are accepted another PR, this time for Mono, will be opened and complete the fix for this issue.

Alas, we won't be able to obtain arbitrary interface MAC - even Java classes can't provide us with the information.
Comment 10 Marek Habersack 2016-10-28 19:36:42 UTC
Mono PR https://github.com/mono/mono/pull/3781

With the acceptance of the above (and its backport to mono 4.8 in commit 1db9061145385d28dc6ce5cbda768bdefe406b16) the bug is fixed.