6

I am trying to transfer 2 megabytes worth of data using the new multi-peer connectivity framework in iOS 7. I am finding that sending and receiving 2 megabytes of data takes at least 5 minutes. This seems very odd. This is between an iPhone 5S and an iPad 3 in the same room. Problem happens regardless of whether WiFi or Bluetooth are enabled or disabled and whether reliable is on/off.

// self.session is an open MCSession, packet is the 2 MB of data, reliable is YES or NO, both are slow
[self.session sendData:packet toPeers:peers withMode:MCSessionSendDataReliable error:&error];
Marco
  • 6,692
  • 2
  • 27
  • 38
jjxtra
  • 20,415
  • 16
  • 100
  • 140
  • Both may be enabled, but can you confirm which is being used? Don't expect much out of Bluetooth – borrrden Oct 25 '13 at 03:49
  • How to tell which one is being used? – jjxtra Oct 25 '13 at 03:49
  • Well you can start by disabling Bluetooth and testing again. That will rule out the possibility that Bluetooth is being used. – borrrden Oct 25 '13 at 03:50
  • I'll try without Bluetooth. Seems like Apple would pick the fastest mechanism, but I'll post my results with Bluetooth off. – jjxtra Oct 25 '13 at 03:50
  • With bluetooth off, I'm at 2 minutes and still waiting for the message receive event... – jjxtra Oct 25 '13 at 03:53
  • It's impossible to tell you what is going on because so many factors affect wireless connections. There is signal noise, router settings, distance from router, etc. I guess one piece of advice I can give from my experience developing this kind of framework before this was available is reset your router to its factory default and try again. Also see if unreliable makes any difference. – borrrden Oct 25 '13 at 03:54
  • Have you tried breaking it up? In my testing ten 200kb files moved a lot quicker than one 2MB. – ChrisH Oct 25 '13 at 15:55
  • @ChrisH I haven't tried that but I will give it a go. I am floored by how slow data is transferring. How did this make it into the SDK? I have tested many combinations of WiFi, Bluetooth and routers and all are slow. – jjxtra Oct 25 '13 at 16:13
  • My guess is this framework got put on the back burner when Apple ran into delays with iOS7. Very little documentation on it and at least one serious bug. Didn't work at all in DP1. – ChrisH Oct 25 '13 at 16:19
  • @ChrisH what good alternatives are there for this sort of thing? I'm fine with rolling my own implementation on top of another framework. – jjxtra Oct 25 '13 at 16:26
  • @ChrisH What bug are you referring to? – jjxtra Oct 25 '13 at 16:27
  • http://stackoverflow.com/questions/19475366/multipeer-connectivity-crash-when-inviting-peer-that-stopped-advertising – ChrisH Oct 25 '13 at 16:31

1 Answers1

6

I'm pretty sure this is because the iPad 3 is the bottleneck. Transfer from iPhone 5S to iPad Simulator on my MacBook Air for a 10 MB file was about 1 second. My theory is that only AirDrop enabled devices will get fast transfer speeds - http://en.wikipedia.org/wiki/AirDrop.

EDIT My assumption was wrong, transfer between two iPhone 5s is just as slow :(

EDIT Switched to streams API and it's much better

EDIT Tweaking wifi channel settings on my router has helped performance, but it still seems slower than it should be. 10 MB transfer now takes 30-60 seconds instead of 5 minutes.

EDIT I solved the problem by converting the images to JPEG2000 which is vastly smaller than PNG, even though the transfer is only like 100K a second it now finishes in a reasonable 5-10 seconds. See this stackoverflow answer: How do I convert UIImage to J2K (JPEG2000) in iOS?

EDIT Disabling encryption has also helped with transfer speed

Community
  • 1
  • 1
jjxtra
  • 20,415
  • 16
  • 100
  • 140
  • one improvement is to use MCSessionSendDataUnreliable when droping a frame is an option – Peter Lapisu Nov 30 '14 at 11:25
  • @PeterLapisu I seem to remember doing that, but still had the problem – jjxtra Dec 01 '14 at 18:22
  • i'am doing transfer aprx. 20k per sec and getting drops :/ it a shame that the framework can't do any better... what also helped was disabling the encryption and a bugfix for issues in iOS7 – Peter Lapisu Dec 01 '14 at 19:15
  • iam streaming images, but iam not using the stream method, but just the regular send data, you thing that using stream will work better? – Peter Lapisu Dec 01 '14 at 19:16
  • 1
    @PeterLapisu streaming method will work way better, you should switch to it if you are sending anything bigger than a small packet of data. – jjxtra Dec 01 '14 at 20:36
  • great, i managed to implement streaming and it looks faster and more stable... however it looks like iam getting faulted data sometimes... how did you managed to handle them? – Peter Lapisu Dec 04 '14 at 00:20