Mozilla Firefox for Mobile: where is the error console?

As Firefox Mobile has support for WebGL, I'm tinkering with it and trying to find out what can be done.

The first thing you'll need, once you go past the rotating cube demo stage and start anything remotely complex, is accessing the error console, or at least some way to see what you're doing wrong, and probably output logging messages too.

Turns out there are two complementary methods to get this sort of information out of the phone:

1) The debugger. You can connect an instance of desktop Firefox to the Android instance, using the desktop debugger that shows under the Tools Web Developer Remote Debugger option. This basic debugger allows you to stop/pause/step through the scripts running in the mobile.

2) The error console. It can be accessed using Android's adb, as detailed in this post.

Apparently the console could be accessed from the phone in earlier versions of Firefox Mobile (version 10 or less), but it was removed lately.

Once everything is set up, you can use the classic Javascript console.* methods to output stuff from your scripts, and they will show up in the Android log. You can use ddms or just plain adb + grep:

adb logcat | grep Gecko

I haven't tried the entire family of methods, only log and warn. I found that their output is slightly different, as you can see below:

console.log('This is a log');
console.warn('This is a warning');
E/GeckoConsole(27208): This is a log
E/GeckoConsole(27208): [JavaScript Warning: "This is a warning"]```

Since both are reported as <em>Errors</em> they will show up in red in <em>ddms</em> or your favourite IDE. I was hoping for warnings to be reported as warnings, info as info, etc., with their corresponding and different colours. Yes, sometimes my error logging gets very sophisticated ;-)

Personally, <strong>I would rather have the error console integrated with the Firefox Remote Debugger</strong>--the user experience would be way nicer.

As an example, I recently reinstalled my computer, and so I didn't have the Android SDK installed, not even Java! But I had to install everything so that adb could work, and then I had to deal with the infamous udev rules so that my device would be recognised by the computer when USB debugging was enabled. And had to reboot too, since not even reloading the rules would convince the computer to recognise the phone. All this could be avoided if the debugger integrated the console. <small><em>Edit: turns out there's already work under way to accomplish this! See bug <a href="">768096</a></em></small>.

And while we are on it, two more suggestions for the Mozilla developers:
    <li>it would be <em>terrific</em> if the debugger remembered the last IP address... <small>(bug <a href="">790556</a>)</small></li>
    <li>... specially because there's just too little time to press OK in the dialog that asks if you want to allow a debugger to connect to your phone, and thus you have to re-enter the IP address again and again! <small>(bug <a href="">790553</a>)</small></li>

Minor issues apart, this is great news, and really, really exciting! Deployment speed is totally unlike developing for native Android, as you just need to reload the page and it never takes as long as uploading APKs to the phone. Plus, of course, you get to many more platforms with just ONE version (HTML).

<strong>I'm really liking the latest Firefox updates for Android</strong>, so much that I'm even considering using it as the main browser, as I'm finding it more responsive than Chrome. And, of course, has WebGL support ;-)