FireStation: Firefox on (an unhacked) PSP

Note: this is (for now) released under a proprietary license. You are allowed to install and use this on any number of systems, however you are not allowed to distribute it. As usual, it comes with absolutely no warranty. Should local raw require any warranty, then you are not allowed to download or use. The license thing is simply because I don’t want to see clones popping up yet. I didn’t submit it to the Mozilla Addon Directory because I don’t feel it’s ready yet and I don’t want others to do it instead. If you really do want to polish it to the point where it would be ready for mainstream use, drop me a line.

Source and installation (FireStation.xpi): Link (only tested in Firefox 4 betas so far).

Install it (and restart Firefox), then choose Tools/FireStation on the Firefox menu (make sure you don’t have any other web servers running). Finally, navigate to your PC’s IPv4 address using your PSP. You can find it by opening a command prompt and running “ipconfig” (should look similar to 192.168.2.86). Make sure that your router is configured to not expose port 80 to the outside world, since there is no authentication inside FireStation yet.

Thanks first to the good people over at the moznet #extdev channel, without whom I would never have gotten the Firefox sockets API to work properly.

OK, now on to the description to what this actually is: This Firefox Addon lets you remote control your Firefox from any PSP. It works by implementing a simple HTTP server with sockets, then feeding an it screen captures (generated with Canvas, drawWindow and toDataUrl), while sending scrolling, clicks and keystroke data back from the PSP to the PC and simulating it there.

It’s not optimized in any way, but it works surprisingly well already (for reading; it’s not exactly perfect as a video player). You can scroll using the PSP Square-button and Firefox will capture the rectangle you’re currently looking at and transmit that, instead of forcing you to fiddle around with scrollbars. There’s a location bar that you can click to enter a new location and a simplified keyboard that you can use for anything on the page, like search fields. There’s no right click, or support for multiple windows yet (they will open, but you won’t see them on the PSP).

The PSP browser (NetFront) is a user’s (and developer’s) nightmare, so the challenge here was twofold:

  1. Getting Firefox to work as a webserver
  2. Getting Netfront to show it

It may seem like getting the webserver running would be the hard part, but getting NetFront to behave is actually a good deal harder. The webserver is contained in a few easy to use classes in content/server.js. To use it, you simply throw it a configuration object and that’s that:

new HttpServer({
  "/screen":function(req){
    var res=new HttpResponse("","text/html");
    ...
    return res;
  },
  "/blank":new HttpResponse("empty","text/plain")
},80);

With Netfront, there is nothing easy or clean. Any code that is supposed to run on it will inevitably turn into one huge hack.

  1. There are no frame url setters, like myIframe.src=”http://www.google.com”. While it won’t throw an error, it simply won’t do anything
  2. No XMLHttpRequest. Not much of a surprise, but still inconvenient.
  3. Very little event support (no scroll or even a good load event).
  4. Very strange CSS/JS interaction (it doesn’t try to apply all CSS at once like normal browsers, but will update the screen between commands)
  5. Only a modal keyboard
  6. No way to create or remove any elements, other than document.write
  7. Tons of other stuff that I have forgotten about.

You overcome #1 and #2 using the legacy frames API, window.location and JS callbacks. #3 requires you to basically recheck manually from time to time and #4 simply means shuffling your CSS-applying JS code around until you get what you want. #5 is annoying because if you need to have something onscreen while the user is typing, you need to create your own and finally #6 means that you’ll be hacking around with iframes where you’d normally have a DIV, since that’s the only way to actually create new nodes.

This basically works, but it’s going to take a lot more hacking to make it pleasant to use. Clicks and Key-presses are ridiculously slow so far since the image takes up nearly all bandwidth, even when it’s transmitting the same image over and over again (detecting mozAfterPaint could fix this). Dynamic zoom and multi-tab support are really musts at some point as well.

One thought on “FireStation: Firefox on (an unhacked) PSP”

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.