The Airsource Blog

Save the Bits - Part II

Back in my original Save the Bits article, I noted that a foreign currency application on the iPhone, which I'll refer to as AppX, uploaded 16K of data and downloaded 136K just to render a graph.

I said I'd get back when I'd run a packet sniffer. I've just done that, and the results aren't pretty. It uses HTTP, to talk to the server, which is as you'd expect. Writing a custom protocol is always painful. But instead of the logical thing to do, which is a short sweet transaction to get the data, and any associated metadata like an ad, like this.

  • Client: Hi, can I have some data
  • Server: Here's your data, and an ad to go with it
  • Client: (Draws graph)

What's actually going on is an extended chat, whereby AppX does something like this

  • Client: Hi
  • Server: Hi, have a cookie
  • Client: Here's my cookie
  • Server: Here's an ad for you to display

OK, not too many complaints so far, apart from the amount of to-ing and fro-ing which makes the most of all those round trip high latency transaction, but now it gets really fun:

  • Client: Hi again
  • Server: Here's a whopping great piece of Javascript code
  • Client: Can I have some more?
  • Server: Sure
  • Client: And an image to represent my graph? I don't fancy drawing all that data myself.
  • Server: No problem
  • Client: And maybe some more JavaScript?
  • Server: You got it

In other words, AppX isn't recently doing much itself. Instead it's fetching an entire JavaScript sub-application which it runs in a WebView and which fetches all the data and renders it.

No wonder it's slow. I've heard of Whale Song, but this is ridiculous...