Introduction
It is very well documented how the inbuilt Request.Browser
object has shortcomings in the mobile web-application world (here and here). WURFL is an open-source project which succeeds in filling the void left by these problems. There are a growing number of ASP.NET implementations of WURFL. We will be discussing three of these:
- RedCircle - An implementation that seems to have been authored by Paulo Gomes whilst working for RedCircle.
- Wurfl.Marg - An implementation found at wurfl.marg.si and discussed at groups.yahoo.com/group/wmlprogramming.
- wurflAPI (aka WURFL as a dotNetAPI) - An initiative of the WURFL Sourceforge project.
Background
WURFL is based on matching the user-agent string
as identified by the request object (on the server), with an "ambitious configuration file that contains info about all known Wireless devices on earth" (http://wurfl.sourceforge.net/backgroundinfo.php). The resulting node is parsed into a Capabilities collection which enumerates the known properties of the mobile browser. These include groups of properties (full breakdown) like:
product_info
- Human readable brand and model name and other generic info
wml_ui
- User Interface for WML browser
chtml_ui
- User Interface for Compact HTML
xhtml_ui
- User Interface for HTML/XHTML-MP browser
css
- CSS-issues
ajax
- Supported Mobile Ajax features
markup
- Supported markup languages
cache
display
image_format
bugs
wta
security
bearer
storage
object_download
drm
streaming
wap_push
mms
sms
- Binary SMS and SCKL capabilities
j2me
sound_format
- supported sound formats
flash_lite
- Macromedia/Adobe Flash Lite
transcoding
- Handle abusive transcoders
rss
- Native support for RSS feeds
pdf
- Native support for PDF documents
These properties can be queried for conditional rendering for different devices (implemented manually), or if Adaptive Control Behaviour is supported and mobile controls are used, the page is automatically rendered in different ways depending on the capabilities of the browser. A good practical example of Adaptive Control Behaviour is explained by Paulo Gomes formerly of RedCircle here.
The Tests
As some metrics were needed, objects that can be initialized in the Global.asx file were initialized in the page code-behind so that the processing could be timed. Also the code is not optimized in any way (do not use it in its current form); it has been designed solely to be audited (via time logs). The time results shown cannot be taken seriously in an absolute sense, but the patterns and relative values can be compared. The files were deployed to a Virtual PC with Windows XP Professional Version 2002 Service Pack 2 and IIS 5.1 running.
For the most part, I expect that the project will be browsed by desktop computers (for evaluation); the WURFL data file included doesn't have all of the desktop user-agents included and will use generic values. This in itself is a disparity with how the code will run in production as it adds lookup(s) to get the generic value.
The test plan was fairly simple; general comparisons were of interest but caching and the handling of data changes were important features to assess. The tests included:
- Getting a property for the current device
- Getting subsequent properties for the same device
- Getting a property for another other device
- Getting subsequent properties for the other device
- Changing the data file
The test steps were:
- user agent: current device
capability: mobile_browser
data modified: false
- user agent: current device
capability: xhtml_table_support
data modified: false
- user agent: current device
capability: ajax_support_javascript
data modified: false
- user agent: current device
capability: resolution_width
data modified: false
- user agent: NokiaN92-2
capability: mobile_browser
data modified: false
- user agent: NokiaN92-2
capability: xhtml_table_support
data modified: false
- user agent: NokiaN92-2
capability: ajax_support_javascript
data modified: false
- user agent: NokiaN92-2
capability: resolution_width
data modified: false
- user agent: iPhone
capability: mobile_browser
data modified: true
The results are as follows (in milliseconds):
My Observations
RedCircle
- Other than the very first load (test #1) it performed very well; most of the times were less than a millisecond. To achieve this, a
capabilitiesWhiteList
was added to the Web.config file.
- On a previous test-drive of the RedCircle Framework, I asserted that there was a mechanism that reloaded the data when it was changed. In these tests, this was not the case: with test #9, none of the WURFL implementations reloaded the data when the WURFL.xml file was modified.
- The API was easy to use although quite a lot of configuration is needed in the web.config file.
- Although not tested in this article, the framework has a plain vanilla Adaptive Control Behaviour implementation particularly useful if outputting WML.
WURFL.Marg
- Marg performed well across the board; test #5 result seems like an anomaly though.
- The API is a little more complex to use, but as the
Request.Browser
is assigned to, the built-in Adaptive Control Behaviour is functioning based on the WURFL device list.
- There is more tight coupling than the other implementations. Log4net must be referenced from the consuming project and there are more modifications needed in the web.config file.
wurflAPI
- This implementation performed the worst; I'm not sure whether it is being maintained anymore, even though it is a Sourceforge project.
- It does not seem to support Adaptive Control Behaviour.
Points of Interest
There did not seem to be any automatic mechanism in the frameworks for reloading objects on data file modification. Fortunately System.Web.Caching
can monitor and reload data files with very little coding.
The team that is working on Marg (Miha Valenic seems to be a senior member) also offers a more comprehensive hosted solution for adaptive rendering; dialogs of the details can be found here.
History
- 2009-01-16 - Article submitted