Introducing JITB

My talk at FITC San Francisco is over and I want to share some of the anouncements from today with you. At the end of my talk I was showing JITB.

What you see in the YouTube video I posted a while ago is a Java program executing a SWF. For FITC I added some more code and an OpenGL based Display List renderer. In other words: I wrote a Flash Player.

However I should rephrase that statement and say I am attempting to build a Flash Player. The current state is available in the sf2010-sprint clone of Apparat. I will merge the changes into the main Apparat branch when I am back home in Germany.

JITB is currently able to translate a subset of ActionScript code at runtime into Java bytecode and runs nearly at the same speed as native Java. This is a really huge improvement compared to standard ActionScript performance. A lot of smart people worked on the JVM and made it really fast. Apparat will allow you to leverage all this hard work in the future. I am also shooting for Java interoperability at some level so that you can call Java classes from within ActionScript. Hopefully you will be able to use JITB on your desktop machine, on a server or on an Android phone. Basically everywhere Java runs.

There are still a lot of things missing. The whole Flash API needs to be implemented. And the Display List rendering needs a proper OpenGL implementation. However I thought this might be some cool stuff to share with you in its early stages.
My hope is that more people start contributing to the project. Maybe some OpenGL guru wants to take care of the Display List rendering or someone else likes to help implement the Flash API in Java.

I also showed a Raytracer by Nico Zimmermann during my presentation and promised to put the URL on my blog so here it is. His company is called Britzpetermann and the address is http://www.britzpetermann.com/.

Update: Please do not think that this implementation is 30x faster than the Flash Player developed by Adobe. One(!) microbenchmark is never a number you should count on. I would like to make clear that I never said this.

52 Comments

  1. Posted Aug 19, 2010 at 4:18 am | Permalink

    that’s holy fucking cool!!

    however from my openGL experience, GPU is not always fast at rendering graphics than CPU. Flash takes good advantages of such things i.e the anti-aliasing. Also flash has filters that have been compiled into the player, running this off java would make it slow.

    my 2 cents.

    Keep up the awesomeness.

  2. Posted Aug 19, 2010 at 4:22 am | Permalink

    Wow, this is really cool! I can’t wait to see how the project develops…

  3. Rezmason
    Posted Aug 19, 2010 at 5:26 am | Permalink

    It’s things like this that make me glad I have your-head-exploded insurance.

  4. Posted Aug 19, 2010 at 5:49 am | Permalink

    Badass!

    However, rendering SWF shapes with OpenGL is going to be a challenge. OpenGL just don’t natively render Beziers, so you have to either approximate curves with line segments, or use wicked tricks like http://www.mdk.org.pl/2007/10/27/curvy-blues – and then there are strokes.. But you knew that already :)

    I was experimenting with just that lately, only that my target is OpenGL ES on iOS.

  5. Posted Aug 19, 2010 at 5:53 am | Permalink

    Now this is getting very interesting :) Keep up the great progress!!!

  6. Posted Aug 19, 2010 at 7:40 am | Permalink

    OpenGL is bad for a lot of reasons under certain circumstances. For instance you will have a hard time keeping up with a software rasterizer when it comes to something like BitmapData. Sending textures to the graphics card at realtime has always the memory bandwidth costs.

    The filters are not a big problem since you can use shaders for most/all of them. Same for stuff like scaling, color transform etc. However my main interest is fast ActionScript execution at the moment.

  7. Posted Aug 19, 2010 at 8:44 am | Permalink

    This is really cool Joa. Seems to me you aren’t all that far from something like Scaleform (which desperately needs to be more optimized for the gpu).

    Hats off to you sir : )

  8. Valentin
    Posted Aug 19, 2010 at 9:37 am | Permalink

    That’s cool. What are you going to do with this thing? Someone mentioned Scaleform which still uses AS2 if I’m not mistaken.

  9. Philippe
    Posted Aug 19, 2010 at 9:57 am | Permalink

    Really amazing – especially the possible Android target.

    For the rendering, I think it would be perfectly fine (and maybe better) to have something different than Flash’s displaylist model.

  10. Posted Aug 19, 2010 at 10:04 am | Permalink

    Sounds uber (to keep it in your native tongue)! Continue to amaze us please :-)

  11. Posted Aug 19, 2010 at 12:52 pm | Permalink

    we like :o)

  12. Posted Aug 19, 2010 at 1:36 pm | Permalink

    Thats is… incredible.

    This project is really something I wanna be part of! If there is any thing I can do.. just let me know! :)

    Did you tried to run that on smartphones supporting java?

  13. Frazzle
    Posted Aug 19, 2010 at 3:28 pm | Permalink

    Dude, you’ll need a catchier name for it if you want it to really take off – I mean, how am I supposed to say JITB?!?!?

  14. Jeffrey Gilbert
    Posted Aug 19, 2010 at 5:11 pm | Permalink

    Sweet. A replacement to the flash player for mac would be a godsend. With the garbage collection cycles as random and harsh as they are, flash content is almost unplayable and has been since its inception to the platform.

  15. Posted Aug 19, 2010 at 5:12 pm | Permalink

    Neat!

    How about “Vultan” for a more pronounceable name – because it gives support to Flash on different worlds (i.e. the JVM).

    (see http://www.imdb.com/title/tt0080745/ if you don’t get the reference).

  16. Posted Aug 19, 2010 at 5:15 pm | Permalink

    Frazzle: Just like you would say “jit” as in JIT (Just in time compiler) and “b” as in “B”.

    jpauclair: I did not do it yet. In fact I hoped to find some framework that would abstract the OpenGL for me so that I could use the same code for Android however I sticked with LWJGL for now. Anyways I output standard Java bytecode and since it is all done at compile time you can emit *.class files and even create a JAR if you want. I might be able to have an Android demo ready for FOTB.

    Philippe: There has to be some support to render existing SWF files. So that is why the current display list should be supported.

  17. Posted Aug 19, 2010 at 8:46 pm | Permalink

    Awesome work Joa, as usual :) I can’t wait to see what this becomes!

  18. Posted Aug 19, 2010 at 9:04 pm | Permalink

    This is sweet!

    Can the java bytecode be converted to Dalvik bytecode? (If I understand it correctly, the Android compiler does Java -> Java bytecode -> Dalvik bytecode – so theoretically, you could do AS3 -> [AVM2 ->] Java bytecode -> Dalvik bytecode).

    This is exciting stuff!

  19. Posted Aug 19, 2010 at 11:22 pm | Permalink

    Wow, very impressive works man, I did not know 1 man could ever recreate an flashplayer on its own.
    Btw is it legal to create your own flashplayer? I think this is an very interesting project. Which APIs from the flashplayer do you have currently buildin? Does it support bitmapdata objects with unlimited sizes?

  20. Posted Aug 20, 2010 at 12:07 am | Permalink

    Kevin Newman: Exactly. That is the whole idea.

    Mark: I think it is legal since all the specs are open and available. However not all specs are there, e.g. which algorithm is used by BitmapData#perlinNoise or BitmapData#noise for instance.

    I did not put a limit on BitmapData size. The only limit is the memory of the running JVM which you can finetune of course to meet your needs.

  21. joe A
    Posted Aug 20, 2010 at 2:35 am | Permalink

    OMG i want to hump you

  22. Ash
    Posted Aug 20, 2010 at 3:10 am | Permalink

    Thanks for pushing the envelope as always!

  23. Posted Aug 20, 2010 at 3:26 am | Permalink

    Well, “jitb” could be an acronym for “jack in the box”, which I rather like the sound of. :D

    This looks awesome! I’m amazed daily by the things open source is doing with “closed” platforms.

  24. Daniel
    Posted Aug 20, 2010 at 4:01 am | Permalink

    I’d look into the infrastructure libs used by JavaFX. It has support for playing flash video files, a accelerated Opengl based display list system, and other parts that may be useful.

  25. ATIF
    Posted Aug 20, 2010 at 4:28 am | Permalink

    this is amazing . Can we send and receive byteArray to java from flash and vice versa and how big it can be

  26. Posted Aug 20, 2010 at 9:25 am | Permalink

    Beyond amazing.

  27. Dd
    Posted Aug 20, 2010 at 9:38 am | Permalink

    I do not believe your numbers.

  28. Posted Aug 20, 2010 at 10:00 am | Permalink

    It would be super-puper-mega-great if this demo cause some Java-based headless player! Because Adobe themselves never produce it :(

    Thank you for good job!

  29. Posted Aug 20, 2010 at 10:21 am | Permalink

    hi joa,

    you said you’d like to have a framework that abstracts the OpenGL for you. I’ve written a low level game development library which might just do what you are searching. It emulates OpenGL ES 1.0/1.1/2.0 on the desktop via Jogl 1.1 (but i might switch to the new one soon) and uses the standard OpenGL ES bindings on Android directly. The lib is crossplatform and applications written with it work on Android, Windows, Linux and Mac (and as applets of course). Apart from the OpenGL ES stuff it features a couple of other nice things which might come in handy. I won’t spam the name here as that would be inapropriate. Get in contact with me if you want, i’d be very interested in working with you on that!

    Ciao,
    Mario

  30. Posted Aug 20, 2010 at 11:00 am | Permalink

    Amazing! More amazing work Joa!

  31. Sergey
    Posted Aug 20, 2010 at 11:00 am | Permalink

    Amazing!

    I lurked through the source code repo and I see you write it in Scala. I learn Scala and I would like to try myself in a real project. The JITB seems very interesting and useful one. The main obstacle for me is my absence of knowledge about ActionScript. I you think I still have some chances to be useful there please contact me.

  32. Posted Aug 20, 2010 at 12:48 pm | Permalink

    How does this compare to lightspark?

    I guess at the least you should share test suites and benchmarks. Then compete against each other to build the best implementation.

  33. Marcelo M.
    Posted Aug 20, 2010 at 3:34 pm | Permalink

    I think it should be called Fernando Alonso. Because it’s faster than Flash.

  34. Posted Aug 20, 2010 at 3:45 pm | Permalink

    I may be interested in helping out here. Drop me a line.

  35. Posted Aug 20, 2010 at 5:32 pm | Permalink

    Constantiner: This is one of the reasons I started this project. JITB was only a headless player until a couple of days ago.

    Dd: I never said 30x faster and everyone would know immediately that this is not true. I think I should not have posted the numbers about a one little microbenchmark.

    badlogic: Expect an e-mail soon :) Sounds exactly like what I have been looking for. Thank you!

    Sergey: Scala is fantastic. But ActionScript is not important to know since the progress is that a SWF file with ActionScript is translated to a three-address IL at runtime which is then optimized and transformed to Java bytecode.

    Stu: I do not know how this compares to lightspark.

    Cas: Thank you I will.

  36. joe
    Posted Aug 20, 2010 at 5:38 pm | Permalink

    As someone of Jitanese descent, I find your use of the racial slur “Jit” insulting and demeaning.

    :P

    Nice work!!!

  37. Freddy Nice
    Posted Aug 20, 2010 at 6:30 pm | Permalink

    Hey just popped in for a gander , This is cool men! Show these fools you can do it with smoothed hi-res images. Post an example we’re all curious. GO!

  38. Me
    Posted Aug 20, 2010 at 6:49 pm | Permalink

    I propose pronouncing JITB as “Jitterbug.”

  39. Me
    Posted Aug 20, 2010 at 6:51 pm | Permalink

    http://en.wikipedia.org/wiki/Jitterbug

  40. Timon
    Posted Aug 20, 2010 at 7:18 pm | Permalink

    Joa,

    Could you provide the benchmark file so we can test the performance with Lightspark?

    Your project looks very promising, congratulations!

  41. Posted Aug 20, 2010 at 8:55 pm | Permalink

    Hey Joa,

    Sorry about all the fuss, I did say ‘up to’ in the reddit title! Blame Iain Lobb, his twitter post is what first brought it to my attention, and he hypes it up even more ;)

    http://twitter.com/iainlobb/status/21556013375

    I’ll buy you a beer at FOTB to say sorry

    Tom-

  42. Ollie
    Posted Aug 20, 2010 at 9:03 pm | Permalink

    Epic jwin!

    “Update: Please do not think that this implementation is 30x faster than the Flash Player…”

    Yeah but, come on buddy, we all know it will be!

  43. Mighty Impressed
    Posted Aug 21, 2010 at 12:46 am | Permalink

    Awesome work – can’t wait to see how this progresses :) Keep it up!

  44. Jonathan
    Posted Aug 22, 2010 at 1:07 pm | Permalink

    JITB: Java In The Box?
    (instead of jack in the box OR Just in Time b.)

    That ‘s a catchy name!

  45. Rando
    Posted Aug 24, 2010 at 3:32 am | Permalink

    Yo dawg, I herd you like VMs so I put a VM in your VM so you can interpret while you interpret.

  46. Raffaele
    Posted Aug 24, 2010 at 10:00 am | Permalink

    JVM it’s already the best luck of Ruby/RoR (JRuby seems to be far better than the original implementation) may it become a good change for AS3/Flash/Flex/AIR to gain market penetration?

  47. Posted Sep 28, 2010 at 7:13 pm | Permalink

    Joa, damn…you blew me away in your presentation!
    JitB is a saviour!!!

    I think i can honestly say, you are my hero ;)
    Now i can switch back to doing as3.0 again instead of doing only Java for the lack of power in flashplayer. wohoe!

    And might i say… glsl shaders…. very VERY nice job!
    \o

  48. Posted May 22, 2011 at 12:30 pm | Permalink

    Yes, really. So happens. Let’s discuss this question. russiangirls

  49. Posted May 26, 2011 at 12:46 am | Permalink

    Hey there are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and create my own. Do you need any coding knowledge to make your own blog? Any help would be greatly appreciated!

  50. Posted Oct 26, 2011 at 7:03 am | Permalink

    The problem here is not that the claim of a 30x performance increase was fallaciously generalized based on one particular piece of code as compared with Adobe’s player, but that anyone familiar with Flash would find this claim to seem quite plausible.

    If someone claimed that they made a compiler that, say, generated code that was 30x faster than what Microsoft’s compiler or gcc could do, no one would believe it for a minute.

  51. Posted Oct 28, 2011 at 2:34 pm | Permalink

    You actually make it all appear easy, but I can’t help but feeling overwhelmed when tackling this topic. Keep them comming. Hell, maybe I’ll learn a thing or two!

  52. Posted Sep 17, 2012 at 3:45 pm | Permalink

    Needed to compose you a little bit of remark to finally thank you so much again over the splendid techniques you’ve contributed at this time. It was certainly shockingly open-handed with people like you giving without restraint precisely what many individuals could have marketed as an e-book to help make some dough for themselves, most importantly considering that you could have tried it in case you wanted. These suggestions also acted to be a easy way to realize that many people have the identical eagerness really like mine to learn great deal more on the subject of this condition. I know there are thousands of more fun instances in the future for people who looked over your website.

15 Trackbacks

  1. [...] This post was mentioned on Twitter by Miguel de Icaza, Joa Ebert, mrchrisallen, Josh "G" McDonald, Mark Mandel and others. Mark Mandel said: RT @campbell: Subset of as3 now running in Java Virtual Machine http://bit.ly/c99ah4 Joa Ebert just made server side actionscript fast! [...]

  2. [...] Joa Ebert正在开发一个基于Java的Flash播放器实现JITB:JITB能在运行时将ActionScript代码子集翻译到Java字节码,运行的速度与原生Java一样快。在ActionScript标准性能测试中,一个Flash实例用JITB只需30ms,而Flash Player需要10000ms。他希望能在任何Java环境里,无论是桌面、服务器还是Android手机上,运行JITB。JITB目前还有很多事情要做,如实现Flash API,选择合适的OpenGL实现等。 [...]

  3. [...] кoнфeрeнции FITC в Caн Фрaнциcкo был прeдcтaвлeн прoигрывaтeль JITB для фaйлoв Adobe Flash, нaпиcaнный нa языкe Scala [...]

  4. [...] updates on this topic.Powered by WP Greet Box WordPress PluginMBCook writes “Joa Ebert has started working on a new program called JITB. Announced in a talk at FITC San Fran, it’s a Flash player written to use the Java JVM to run [...]

  5. [...] wel veel werk gebeuren voordat het programma, dat JITB is gedoopt, klaar is voor dagelijks gebruik, blogt Joa Ebert, de ontwikkelaar van de software. Zo moet de Flash API nog in de software worden [...]

  6. [...] a look at another interesting flash player implementation by Joa Ebert using Java with OpenGL rendering support. It is at an early stage but has the right idea in hardware rendering to OpenGL which is [...]

  7. [...] de FITC conferencie in San Francisco liet hij de JITB player zien. Deze in Java geschreven speler zet Actionscript code om naar om naar Java bytecode en draait [...]

  8. [...] Origine de l’article : http://blog.joa-ebert.com/2010/08/19/introducing-jitb/ [...]

  9. [...] Joa Eber ujawnił na swoim blogu, że pracuje nad własną implementacją odtwarzacza Flash, który w niektórych [...]

  10. By FOTB… day 2 | MadeByPi® Blog on Oct 1, 2010 at 7:24 pm

    [...] – a great tool for testing, improving and squeezing the most out of Flash. That was followed by JITB – an experimental Flash player running on the Java virtual machine. The results were impressive, [...]

  11. By Developer's Blog » Flash on the Beach Review on Oct 7, 2010 at 10:34 am

    [...] that to the best quality he could came up with (the missing features are now part of the Flex SDK). JITB was really shuddering for me : I remember that the first Flash Players were Java based (before [...]

  12. [...] One of the things I swear by every year, is that you haven’t experienced Flash on the Beach if you didn’t catch Joa Ebert’s session, especially since he started to work on his Apparat suite. Needless to say, I was very honoured when he asked me to contribute some Pixel Bender shaders to show his new JITB player running on the GPU. For those not aware of JITB, it’s essentially a lean & mean Java-based Flash player, with all the niceties the Java runtime provides. Read more about it here. [...]

  13. [...] that to the best quality he could came up with (the missing features are now part of the Flex SDK). JITB was really shuddering for me : I remember that the first Flash Players were Java based (before [...]

  14. [...] de FITC conferencie in San Francisco liet hij de JITB player zien. Deze in Java geschreven speler zet Actionscript code om naar Java bytecode en draait bijna op [...]

  15. By Java flashplayer | Molluscmania on May 22, 2012 at 2:02 am

    [...] Introducing JITB – blog.joa-ebert.com – Blog of Joa EbertPublished on Aug 19, 2010 in as3, experiments, Flash and personal. 54 Comments Tags: actionscript, apparat, fitc, flashplayer, java, jitb, opengl, san francisco. [...]