LOLWUT? Canvas Benchmarking on C5Bench and Xperia X10

Recently, I started looking at Canvas on Android, and I came across the C5 Canvas Benchmarking test. I tested it on both the Motorola Milestone that I recently bought, and the Sony Ericsson Xperia X10, and it was pretty surprising. Now, it should be noted that the Motorola Milestone has a TI OMAP3430 processor, and is capable of speeds up to 600 MHz. However, the Xperia X10 has a Qualcomm Snapdragon processor, and has a clockspeed of 1.02 GHz. Now, people have been speculating whether this clock speed will make a difference, and I think that when you look at the results, it clearly does.

Now, I don’t think that performance is quite there yet, but you may see more advanced uses of Canvas on mobile web applications in the future.

console.log on Android WebView

I recently bought a new phone, the Motorola Milestone from Telus. The Milestone currently features Android 2.0.1, and is the first Canadian phone that actually features Android 2. So, while confirming fixes on the device, I noticed in LogCat that my WebCore wasn’t logging error messages. For those of you who don’t know, on Android 1.x, you could debug your javascript by using adb logcat and grepping for the WebCore errors. This frustrated me, since this wasn’t listed in the API changes. I then decided to sift through the WebView source code, and I found addMessageToConsole.

The method addMessageToConsole is a method that currently exists on the WebChromeClient that can be overriden with your own custom error message. Now, according to the Google Documentation, this is not a public method to be used until Android 2.1. However, I just tested it on my Motorola Milestone, and the method actually works. I’ve included this fix to PhoneGap and you should now be able to go back to debugging your Javascript directly on the device, as opposed to the other methods of using a different browser.

BTW: The code to add it is as follows:


public final class EclairClient extends WebChromeClient
{
private String TAG = "WebErrorLog";
// This is a test of console.log, because we don't have this in Android 2.01
public void addMessageToConsole(String message, int lineNumber, String sourceID)
{
Log.d(TAG, sourceID + ": Line " + Integer.toString(lineNumber) + " : " + message);
}
}

For backwards compatibility with Android 1.6, it’s a good idea to have this class extend a pre-existing WebChromeClient, and to dynamically chose the client you instantiate so you can actually get your application working.