2

Nearby Share sometimes uses bluetooth to transfer the files because of which it is very slow. Sometimes it is not at all handy to transfer files that are more than 100 MB. Initially I thought Bluetooth is used only for handshaking purposes. But later I realized that the files are itself transferred via bluetooth. I'm curious to know why should the files be transferred via bluetooth when it can be transferred via wifi direct. A lot of third party apps including Google Files use wifi direct to transfer the files. So why does a built-in functionality like Nearby Share should use bluetooth. The sole purpose of Nearby Share itself is to achieve fast file transfer with wifi direct and without internet. So if the files are transferred via bluetooth there is no point in using Nearby Share.

I'm also curious to know the various modes of file transfer present in Nearby share. There are three modes: Data, Wifi Only and Without Internet. I'm really curious to know why is an internet connection required to transfer files when Nearby Share is meant for file transfer without Internet. Is it meant for handshaking purposes in Web RTC?

  • Where is your source for this: *"The sole purpose of Nearby Share itself is to achieve fast file transfer with wifi direct and without internet"*? As far as I was aware, Nearby Share chooses the best option at the time. – Henry Twist Jan 31 '22 at 07:15
  • Hi Henry, Actually I'm not sure of it. Just like airdrop that allows file transfer with wifi direct in IOS devices, I thought Nearby Share would serve the same purpose in Android. Android already had bluetooth file transfer facility even before Nearby Share. But it didn't have a wifi-direct file transfer facility which is faster than bluetooth and because of this people had to rely on third party apps. And as you know not everyone will use the same third party app, Google itself gave us a solution for this in the form of Nearby Share. – Sajidh15Kareem Jan 31 '22 at 08:53
  • You can take a read of their blog post on its release which should cover some of the content: https://blog.google/products/android/nearby-share/ – Henry Twist Jan 31 '22 at 13:04
  • Hi Henry, I read the blog. There also they've mentioned that it chooses the best protocol like you said. I've also seen this in many websites talking about Nearby Share. But I'm not able to understand why should it choose bluetooth to transfer the files instead of wifi-direct. If I wanted to use bluetooth I don't even have to use Nearby Share. I can simply send the file via built-in bluetooth option. People opt for Nearby Share just to transfer the file faster via Wifi-Direct. If its going to transfer via bluetooth they can simply use the built-in bluetooth option. – Sajidh15Kareem Jan 31 '22 at 13:12
  • These are my own thoughts, so I can't speak directly for the Google team, but Nearby share is just a wrapper over these multiple services. You could obviously just use Bluetooth, but Nearby Share makes an educated decision on what service to use without you having to decide, not to mention the convenience factor that it offers in terms of not having to pair etc. It's similar to the way that Android handles location services, they provide a wrapper around using Wi-Fi/Cellular/GPS and choose depending on the situation and predicted use-case. – Henry Twist Jan 31 '22 at 13:24
  • You keep quoting the idea that *"People opt for Nearby Share just to transfer the file faster via Wifi-Direct"* but I don't think that's what Nearby Share is for. – Henry Twist Jan 31 '22 at 13:25
  • Thank You Buddy.. But I still would like some clear answer to the question. I wish someone from Google itself sees this and gives me a satisfying answer. This question has been bugging me for a very long time and I'm not able to find answers to this anywhere in the internet. – Sajidh15Kareem Jan 31 '22 at 13:28
  • You cannot do anything else apart from sharing files with Nearby Share buddy. For almost a decade android didn't have any file sharing capabilities and people had to rely on bluetooth which is very slow or any third party app which is not uniform across everyone. But Ios users enjoyed this facility with Airdrop. You can see in many Authorized sites and blogs that Nearby Share is the Airdrop for Android devices. But the way it works is not reliable at all. – Sajidh15Kareem Jan 31 '22 at 14:54

1 Answers1

4

(Disclaimer: I work on Nearby Share)

Nearby Share will always attempt to upgrade to WiFi before sending files larger than 1MB. A grace period of 10sec is given for that upgrade before fallback mechanisms kick in and the file is sent over Bluetooth as a last resort. Even after falling back to Bluetooth, the devices will continue to attempt to upgrade to WiFi in the background, but some failures are unrecoverable and the file will fully send over Bluetooth. Note that urls and very small files will immediately send over Bluetooth.


This upgrade can fail for a multitude of reasons. Most commonly, it's a concurrency issue. The same radio is used for Bluetooth, p2p WiFi, and your normal access point connection and it must be time-shared accordingly. If all 3 want to be on different channels, you will miss messages -- it's a guarantee. If these messages are important, such as the authentication frames when connecting over WiFi Direct, then the connection will fail. If these messages are less important, they may be resent until successfully received, but it will lower throughput for the transfer such that even 5GHz WiFi can look to be as slow as Bluetooth.

Nearby Share tries to avoid this in a few ways. When regulations allow, we will attempt to start the WiFi Direct group on the same channel as the access point. This way, the phone doesn't have to timeshare (although it does have the side effect of colliding with messages from the access point. But generally, both sides will back off a random amount and retransmit, and the loss is less than the loss of multi-channel concurrency). Unfortunately, many countries do have regulations that allow certain (or all) 5GHz channels only indoors -- in those cases, the access point can be set up to utilize it but WiFi Direct cannot.

We also prefer mediums like WiFi Direct over Hotspot, as WiFi Direct commonly uses CTS2SELF frames to advertise "Do not transmit for this duration". Unfortunately it's not as straightforward a message as "I am going off channel, do not try to communicate with me" -- CTS2SELF has the side affect of quieting all communication over the access point even if it wasn't directed to the phone -- but it does get the point across.

We pause any Bluetooth activity we have control over, to reduce the need to timeshare with it. In some severe cases, where the OEM has implemented timesharing that's too aggressive, we will turn off the Bluetooth radio to forcefully interrupt Bluetooth activity, but this is disruptive and usually a bad user experience.

We may try to send the data over your access point itself instead of setting up WiFi Direct. This can avoid the MCC situation described above, but comes at the cost that the data needs to be re-encrypted (because we don't know what other devices are connected over LAN and might be eavesdropping), and it does introduce another hop, as the data needs to go through the AP even if the devices are side-by-side. TDLS helps avoid that last issue, but it has limitations (eg. it won't use 40/80/160MHz bandwidth if the AP isn't set up for it, and it'll send over 2.4GHz if the AP is on 2.4GHz).


Other possible failures include the device getting into a bad state (toggling airplane mode can help here), the Android version being too low (ideally both devices should be R+, as it's almost impossible to fix bugs on older Android OS versions, even though we try), or just bad luck.

Xlythe
  • 1,958
  • 1
  • 8
  • 12
  • Some optimizations are also hardware specific; Pixel 6 & 6 Pro have full dual band support, so Bluetooth (2.4GHz) and WiFi (5GHz) do not interfere. Most phones have partial dual band support, such that BT and WiFi (5GHz) can simultaneously operate but both at a reduced throughput. – Xlythe Jan 31 '22 at 21:12
  • Thanks a lot Xlythe, Glad that a person from Nearby Share itself answered it. – Sajidh15Kareem Feb 01 '22 at 08:49
  • Hi Xlythe, Based on your above explanation I can very well understand that there are so many obstacles in using wifi-direct. But I would like to know how do those third party apps like google files overcome these obstacles and transfer the files always via wifi-direct. I tried transferring 500 MB data with google files and also tried playing a youtube video in both the phones between which the file is being transferred. Mobile data was turned off in both phones so the youtube videos could be played only via wifi connection. – Sajidh15Kareem Feb 02 '22 at 10:24
  • So when the transfer happend the internet connection in the receiving device was cut off. Does that make sense with the obstacles you explained above? And are these the kind of obstacles Nearby Share is trying to overcome in order to give users the ability to use internet via wifi and also make file transfers via wifi-direct at the same time? – Sajidh15Kareem Feb 02 '22 at 10:24
  • Yes, that's correct. We want users to be able to continue using the internet while they receive a large incoming transfer (although we may also fallback to disconnecting the user in some situations) – Xlythe Feb 03 '22 at 13:15
  • Hi Xlythe, Is there any plans to bring nearby share to windows pc? At the beginning of the year I heard that Google is bringing nearby share and fast pair to windows. Is it coming anytime soon? – Sajidh15Kareem Nov 28 '22 at 18:53
  • Nearby Share's in an internal dogfood on Windows (I use it regularly). Fast Pair is still in development. I can't share a release date, though, since the most recent feedback was "keep polishing it before launching". – Xlythe Nov 29 '22 at 06:53
  • Hi Xlythe, I'm not sure if you already knew it. But just to bring it to your attention. The Nearby Share beta app on my windows pc doesn't work at all. It doesn't discover any of my android devices. I'm using an intel powered windows 10 pc. I tried all the trouble shooting steps like turning airplane mode, wifi, bluetooth on and off on both devices and also rebooting. I tried using it while both signed in and out. I also tried with all the visibility settings. But none seemed to work. Whenever I attempt to share a file the app on windows keep on trying to discover other devices. – Sajidh15Kareem Apr 23 '23 at 14:15
  • You can take a bug report with ctrl+alt+i and send the zip to me at xlythe@google.com and we can take a look. Bug reports have personal information, though, so only send them if you're comfortable sharing. We have updates planned that address some issues as well -- I can't promise it'll fix your issue in particular but do try the update when it lands. – Xlythe Apr 24 '23 at 03:35
  • I don't mind sending a bug report. But nothing happens when I press ctrl+alt+i. – Sajidh15Kareem Apr 25 '23 at 06:41