0

My glass/android app continuously receives data from other computer using TCP or UCP connection, and the received data are used for visualization on the fly.

I'm wondering how we can maintain a certain FPS (for example FPS 30), and also stably and continuously receive data.

Just having infinite loop for TCP data transfer seems causing some problems like device overheat, and occasional network halts.

So basically I'm wondering what is the best to visualize GUI while maintain a certain FPS and also continuously receive data over the internet.

Thank you so much!!!

1 Answers1

0

I would suggest using a worker thread to receive the network data and having that worker thread save the received data somewhere which is accessible to the UI code. Then you can be receiving data in parallel to the displaying of the data. The display updates can then be set to a fixed interval giving you the constant FPS you're looking for (aside from variations in system load which could slow things down). In this way the received network data is updated at whatever interval it comes across the pipe but the UI has a fixed rate of update. You'll likely want to synchronize access to the state which is shared between the network worker thread and the UI thread.

I've done UDP receive in an infinite loop and haven't seen heat or halt issues as a result. I just block for the next UDP packet, save the results and do it again in a loop. In my case I notify the UI thread when this happens and it updates based on that.

Nerdtron
  • 1,486
  • 19
  • 32