Freitag, 4. März 2011

Caciocavallo goes Web

Currently I am working on a small university project to "port" AWT/Swing to html5/canvas ... basically its more or less like VNC, except that browsers are far more clumsy to work with. (its only a scriptable document viewer after all).
The project is based on Caciocavallo, which already saved me a lot of work - all you need to provide is more or less a framebuffer and Caciocavallo takes care of the rest.

Although for now only rendering works (only for a single app) and input-event support is non-existent, the screenshot already looks quite nice :


Kommentare:

Emilian Bold hat gesagt…

Wow, this is excellent! Ever since I've heard of Caciocavallo I've though that a browser canvas would be the next logical step.

Any chance this code becomes open-source? I would really like to give it a try (instead of using applets, which are basically deprecated).

Some input support would be nice though, but I guess one could grab those via Javascript.

Linuxhippy hat gesagt…

Glad you like the idea too :)

I'll open up the source for sure, however for now its still very proof-of-concept, so stand by for a month or so.
I already have some basic (and quite broken) input support working, shouldn't take very long get it to a useful state.

There are however a few downsides to that approach:

- AWT is designed to run a single "instance", so a lot of static fields are used.
That could be solved by loading each instance/session through seperate classloaders, however native libraries are only allowed to by loaded by one classloader (and are not useable by other loaders). I am not quite sure howto solve this one.

- Modifications to the JVM are required. A few assumtions made in OpenJDK break when using Cacio, hopefully the Cacio guys can create patches for OpenJDK that solve that.

- A small native library is required for dirty region tracking. So if you cursor blinks, only modified areas are sent down to the client.

I'll keep you updated ;)

Solerman hat gesagt…

AWT may be designed to be run singlestance, but for sure can run many instances of itself it seems. See the AppContext stuff, then they I look how the Applets implementation does it (its quiet hackish it looks, but can be done)

Linuxhippy hat gesagt…

Solerman: I still haven't fully understood the concept of AppContext but yes, it seems to go in the right direction :)

The prototype already supports multiple parallel sessions using multiple screens :)
One problem left is only one screen gets focus - so for now its possible to steal the focus from another session to yours.

Solerman hat gesagt…

The problems with the AppContext stuff is that its a mess, its proprietary implementation and you can only hack around Thread with your own ThreadGroup to spawn new instances of it. Really, I wish it would be reimplemented (the current sun implementation keeps holding frames in memory with around 13M of wasted memory every time and there is hardly a way to get rid of it from application side)

Endre Stølsvik hat gesagt…

This is simply awesome! I hope you keep up the good work!