Welcome to web app programming. What’s happening is that on your local machine there is, for all practical purposes, zero latency between the browser and the application. You can do amazing things wish no latency issues. I once had a working D&D Mapping helper for Dungeon Masters that used drag and drop on a web page. That is until I put it on the web server and then it practically ground to a halt. The end result is that it was a very hard lesson to learn (thankfully it was a ‘for fun’ project). Drag and Drop in a Web Edition application really doesn’t work due to this latency (not even sure why the events are even there).
Latency is an issue all web apps have to deal with and since Xojo apps do nearly all of their processing on the server this can be of particular concern. Short of putting the apps on my web server there wasn’t a lot I could do to test this until I found out about The Network Link Conditioner for Mac OS X.
The Network Link Conditioner is available through Xcode and allows you to simulate network conditions on your Mac as if you didn’t have the super speedy connection you really have. It’s quite instructional to do this. You can simulate speeds from Edge, DSL, 3G, Wifi, and Cable Modem with varying degrees of lossy conditions in the wireless options.
To get The Network Link Condition open up Xcode and select the Xcode -> Open Developer Tool -> More Developer Tools and log into your Apple Developer Account and in the Downloads area search for Hardware IO Tools for Xcode. This package includes a number of things, including the Network Link Conditioner preferences pane. Download the disk image and mount it. Simply double click on the Network Link Conditioner prefPane file and the Finder will install it in your System Preferences panel.
Then it’s simply a matter of starting it and selecting the network type you want to test against. This tool is very cool and I highly recommend it if you are developing for Xojo web applications. What it will show you is how slow your app is over these types of network connections and will most likely show you where you need to do some optimizations. Perhaps you need to preload some things on your first page so they’re slower later on.
In one of our current projects we were loading a number of WebContainers dynamically. This made sense since we felt we didn’t want to load everything when the user logged in and only load the container when they selected it. This was great but this made the initial selection of the user slow as the server had to create the objects and then push them down to the browser. The perception was that the app was very slow.
The solution was to load the pre-load containers when the user first logs in. It takes longer at first, but when the user makes a selection the app has to only issue visible commands to the browser which is very fast.
A word of warning is in order. Remember to turn Network Link Conditioner off! It’s easy to forget that it’s on. If you forget, though, your entire machine will seem slow if you’re doing anything over the network or internet!
What other tools and tips have you found for helping you debug your web applications?