Flash socket performance issue with Android
I'm writing a Flash AS3 client for a Java real time data server. The data server pumps out 10-byte CR-separated messages every 20ms, which the client is to display in real time. Everything works, except that on some platforms the data doesn't arrive smoothly, but in periodic chunks. On some of these platforms the periods are short, but on others they are surprisingly long, especially Android (which is my planned target client, of course). No data is lost, but the delay could kill the real-time favor of the system.
Some examples of period lengths (data server always hosted under OS X):
- Running in browser (Camino) on host machine: 20ms (i.e. no apparent delay)
- Running in Flash authoring system on host machine: 50ms
- Running in browser (Camino) on separate OS X machine: 16-30ms
- Running in browser (Firefox) on separate Windows 7 machine: 200ms!
- Running in native browser on Android tablet (Android 2.2 on eLocity A7 w 1GHz processor): 400ms!!!
Here are some of the things I've tried:
- Wondering if this was a CPU loading issue, I checked the frame rate. Nope: the underlying Flash movie is set to 50fps, and (simple) animations in the client displaysmoothly at that rate on all the platforms.
- Instead of waiting for the Socket's ProgressEvent.SOCKET_DATA event, I tried adding a timer that polls the socket for data every 20ms. No good: although the poll displays at 20ms intervals, most of the time there's no data waiting, so the data still appears in the same chunks.
- Wondering if TCP/IP was being "helpful" by grouping the data into the chunks, I added a bunch of padding to the data being sent by the Java server to make the data seem more "urgent". This sped up the Win7 client substantially (to about 40ms periods), but did nothing on the other platforms (e.g. Android).
- Wondering if my server was bunching the data, I fired up Wireshark on my host while it was talking to Android. Only slightly: the TCP/IP packets are departing every 20-40ms, each containing 1-2 of the original data messages.
Any ideas? Flash video plays beautifully on the Android tablet (not to mention the Win7 system), so there's no fundamendal reason why things have to be slow (although I can't tell if there are delays in the video data delivery). I'm pretty sure there aren't any "Don't Slow Things Down" flags I could set in Flash, although I'm less sure about Android.
Thanks in advance,