Andy Davies

Web Performance Consultant

Adding iOS Agents to a WebPagetest Instance

Back in September I explained how to create a private instance of Web Page Test running IE, Firefox and Chrome on Windows 7.

Recently I needed to add some iOS agents, after a bit of trial and error this is the approach I used.

I've added the mobile agents to my existing 'all-in-one' WebPageTest instance so if you've not read the original post it's worth having a quick scan first: Configuring an ‘all-in-one’ WebPageTest Private Instance

At a minimum you'll need access to a Mac with Xcode and iOS Simulator installed. If you want to use a real device as a test agent you will need an iPhone or iPad and an iOS developer account.

Building the Mobitest Agent

Confusingly there's some source code for a mobile agent in the WebPageTest SVN respository but as I discovered that's not the source we want!

We want the code for the Mobiletest agent that Guy Podjarny & Co created at Blaze (now part of Akamai).

  • Download the Mobitest source and build it using Xcode.

Install and Configure the Agent

  • Using Xcode launch the Mobitest App on the iOS Simulator or a physical device.

Mobitest has a set of default settings that need updating to match the WebPageTest instance, for example:

Default settings on left, settings for my install on right.

  • Update Jobs URL 1 to match the URL of your WebPageTest instance, and set the Unique Agent Name and Location (location must match the location you configure in WebPageTest).

  • Unless you are using using keys you'll need to remove the default Location Key too.

  • I also enable Restart After Each Job and Auto-Poll (scroll down for these settings)

  • Go back to the iOS home screen, launch Mobitest, press Poll Now and the agent should now poll the server for jobs.

Add the agent to WebPageTest

Once the test agent is up and running we need to update WebPageTest's configuration so jobs can be scheduled for the new agent.

  • Edit settings\locations.ini

Add the new agent under the relevant location section ([Local] and 3=Local-iPhone in the example below)

  • Add a section for the agent itself.

N.B. Section name must match the name set in [Local] and the Location field of Mobitest Agent settings

  • Save locations.ini

Check it's working

I find getLocations.php to be the easiest way of checking agents are configured correctly and requesting jobs.

  • Go to (replace IP address with your WebPageTest URL) in your browser and you should see a list of all the current test agents, their status, and the number of jobs in their queues e.g.

List of test agents and their current status (priorities 2-8 omitted from table)

If either Idle Testers or Being Tested columns are greater than zero then the test agent is successfully communicating with the WebPageTest instance.

You should now be able to use the normal WebPageTest interface to run tests on the device you've just configured.

Shaping the Connection

On, the mobile agents connect via WiFi to a Linux bridge that shapes the network connection.

For my testing I use the Network Link Conditioner that's available on iOS devices registered for development (Settings > Developer > Network Link Conditioner).

If you're using the iOS Simulator for testing then unfortunately the Network Link Conditioner isn't installed. You can use the OSX version of the Network Link Condition instead but that will shape the connection for the whole of OSX.

In either situation you can force the WebPageTest connection dropdown to only show a single label by adding a connectivity entry to the location in settings.ini

In the example below I've added a label that matches the Network Link Conditioner settings for 3G.

connectivity=3G (780/330 Kbps 100ms RTT)

Unlike the PC based agents this setting doesn't have any influence over the actual connection settings used and they will always need to be configured separately.

Some other things to note

The Mobitest Agent uses a UIWebView rather than Safari, so any JavaScript on the page won't use the JIT and this may be an issue on Javascript heavy pages. This blog gets roughly the same number of visitors inApp on iOS i.e. UIWebView, as it does from iOS Safari so the UIWebView experience matters.

The Mobitest Agent ignores the physical orientation of the device and works in portrait only.

Pat Meenan reports that an Airport Express seems to be the most reliable base station for iOS devices. He also has a monitor reboots the Mobitest App via SSH when it stops responding.

Questions or Comments?

If you’ve got any questions or spot any mistakes feel free to leave a comment or drop me an email.

If you want to discuss private instances further or need help WebPageTest Forum for Private Instances is the place to go.