3

I have an iPad app that receives data using UDP sockets. And it has a UIWebView to browse webpages. But while doing scroll in the UIWebView, everything freezes and no data is received. I've been searching and it has something to do with runloops and threads. But if the UIWebView can't run in another thread other than the main one, how can I receive data while doing scroll? It is critical to keep receiving data.

The project uses the AsyncUdpSocket class from Cocoa AsyncSocket that works quite well. And also the singleton class from Matt Gallagher. Everything is running in the main thread, UDP reception and UI.

Thanks in advance!

  • You need to say more about how you are dealing with UDP. And I recommend using AsyncSocket (it does TCP and UDP). – jbat100 Oct 12 '11 at 12:51
  • Sounds like your waiting for UDP packets on the main thread, blocking the UI. – jbat100 Oct 12 '11 at 13:00
  • I'm using the **AsyncUdpSocket** class from Cocoa AsyncSocket [link](http://code.google.com/p/cocoaasyncsocket/) that works quite well. And also the singleton class from Matt Gallagher [link](http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html). I have everything running in the main thread, UDP reception and UI. – Rafa Castelblanque Oct 12 '11 at 16:26

1 Answers1

1

When you do a scroll, the runloop enters a different mode (UITrackingRunLoopMode) and stops responding to network activity on the main thread. This is done for performance reasons.

You should be able to schedule those updates on the proper runloop mode (UITrackingRunLoopMode I believe). Though, I wouldn't recommend this.

Instead, try setting up your UDP networking code on another thread (or queue, yay GCD!) and schedule callbacks on the main thread to update the UI. This will guarantee the networking thread has the proper runloop mode when getting data back on the socket.

Brandon A
  • 926
  • 7
  • 6