Run a Chrome Window Within jME3 (Berkelium Integration)

@normen, @pspeed, and I were talking about this a week or so back and a few days ago I started thinking again how cool it would be. So here it is, a Berkelium window running within jME3. Mouse coordinates finally line up properly within the texture, which was my personal goal before putting a post on the forum about it :wink:



Performance with one window is quite nice, I can get between 2600 and 3200 frames a second. Working on this did bring up some speed questions about the AWTLoader, however as using that without concurrency gave ~50 fps while my own small implementation achieved ~120 (but alas flipping the Y-axis of the image became a huge pain so I gave in and used the AWTLoader)



Iā€™m planning on keeping up development with this, including some sort of mechanism for calling delegate methods in Java from HTML widgets (effectively making it an extremely simple UI system that allows GUIā€™s with HTML/CSS and JavaScriptā€¦ should be pretty cool!)



Unfortunately its Windows only right now but Iā€™m working on building Linux and Mac natives of the Berkelium-Java wrapper.



Berkellium-JME3



Berkelium JNI Binding



http://vimeo.com/29864803



http://www.youtube.com/watch?v=Qr8aabsBitI





The screen recorder kind of killed performance :frowning:

1 Like

You madman! Thatā€™s pretty cool Skye.

Long grind session in a game? Just pop open an in-game browser while you wait :slight_smile:

cool, will it allow to view youtube videos?

and can it run javascript ?

cool, will it allow to view youtube videos?
and can it run javascript ?


Yes, it'll do JavaScript, it uses Chrome to render. As for YouTube, it would have to be one that they've already converted to work within HTML5. In theory, Vimeo should work as well
It [Berkelium] takes advantage of Chromium's multiprocess rendering to isolate browsers from each other and can render to any buffer in memory. The user of the library can inject input and javascript code into web pages to control them, as well as listen for events generated by the page such as navigation events, load sequence events and paint events. Berkelium provides a small API for embedding a fully functional browser into any application.


Edit: taken from here.

hi thereā€¦



iā€™m glad that i do not have to implement it myself after my awesomium port. I have some question though:


  1. does it support transparent page backgrounds (html and body)?


  2. can I inject my Java objects in the api so my javascripts can call them like any other builtin objects (window, navigator, etc)?


  3. is there a way to add plugins to the brekelium instance (flash, etc)?
1. does it support transparent page backgrounds (html and body)?


This was next on my list of things to do, right after your number 2 item :) I honestly figured that the Awesomium demo video was using a color keying system similar to a green screen, I didn't even know HTML supported transparency!

2. can I inject my Java objects in the api so my javascripts can call them like any other builtin objects (window, navigator, etc)?


I haven't tried it yet, but I'd say this method stub looks very promising:

[java]public void onJavascriptCallback(Window win, String url, String funcName);[/java]

3. is there a way to add plugins to the brekelium instance (flash, etc)?


There is "limited" support, Flash being the best supported. My guess though is that you'd need to 'install' the plugin before compiling the native wrapper. I'm still working on getting the supplied build script working for the JNI binding though :(

wow great :slight_smile:


  1. yes, you can set the body background to transparent and it should not be displayed in berkelium only the contents (like i did with awesomium: http://novyon.net/gameui/screenshots/PPXClient1.png itā€™s a fullscreen page, with a div in the center)


  2. i guess itā€™s not the same. In awesomium I can do the following:

    a. create a javascript object by declaring it with a name

    b. adding java callback methods to this object



    like:



    [java]

    public void addObjectCallback(String name, Object object) {

    this.webView.createObject(name);

    for (Method m : callback.getClass().getMethods()) {

    this.webView.setObjectCallback(name, m.getName());

    }

    }



    addObjectCallback(ā€œjmeā€, new JmeSystem()); // where JmeSystem is my own class with one method: exit();



    // then I can make a simple javascript call:

    jme.exit(); // and it will call your method on a given java object

    [/java]


  3. hmmā€¦ I had problems with their build script, thatā€™s why I sticked mainly with awesomium, and built my own wrapper based on someoneā€™s previous attempt.

wowā€¦a neat way to use this would be for testing.

testing and reporting issues in the google issue tracker live!!!

ok it just save an alt+tabā€¦but thatā€™s pretty damn cool!!!

I would thumb you up if it was workingā€¦ :stuck_out_tongue:

testing and reporting issues in the google issue tracker live!!!


That would be very, very cool. I'm having some trouble getting Google's login fields to pick up my mouse though. I don't know why, but it seems to be happening mostly on Google's pages ::confused::

I'm also having a weird issue where the mouse seems to update more consistently when its being moved down. You wouldn't think it, but moving the mouse is made extremely difficult by this!

I would thumb you up if it was working....


I should've waited!!!!!

3. hmm.. I had problems with their build script, thatā€™s why I sticked mainly with awesomium, and built my own wrapper based on someoneā€™s previous attempt.


A number of properties in the build script weren't being set. Now I can't get ANT to pick up my JAVA_HOME :(

Good work dude. Also, thank you for teach us how to find the thread ā€œGetting jMonkeyEngine SDK into Ubuntu Apps repositoryā€ ;D.

Also, thank you for teach us how to find the thread ā€œGetting jMonkeyEngine SDK into Ubuntu Apps repositoryā€ ;D.


Hint, hint, hint ;) I was really annoyed that I couldn't get the YouTube video on the Ubuntu website to play, it worked 3 or 4 times in a row and then magically started misbehaving when I was ready to record!

Just an update:



I emailed the developer of the Java wrapper over the weekend and got a response from him this morning. They were actually hoping to have this in jME eventually, so some great news there!



@anthyon JavaScript calls and callbacks indeed work, so its a matter of me using the API correctly.



Building on OS X

I modified the build script to run on OS X, but ran into problems linking my 64-bit native library to the, only available, 32-bit Berkelium build. I was working on doing a 64-bit Berkelium build but ran into problems building Chromium under 10.7 Lion. That said, I was able to successfully build a 32-bit version of the library Berkelium-Java wrapper, but without an active 32-bit JVM for OS X its tough to test :frowning:



Has anyone worked with the forthcoming OpenJDK release at all? My hope is that theyā€™ll be doing both 32 and 64-bit builds

hi,



my brother and me are the developers of Berkelium Java.



Berkelium supports Java ā†’ JavaScript and JavaScript ā†’ Java calls. Also youtube and transparent page backgrounds are working.



I currently have only little time but will help as best i can :slight_smile:



regards

dennis

1 Like

Hi Dennis, thanks for jumping in :slight_smile:

http://code.google.com/p/berkelium-java/source/browse/trunk/src/main/java/org/berkelium/java/examples/awt2/Awt2Example.java this is an example of two web pages rendered one over the other. (http://www.youtube.com/ and http://jensbeimsurfen.de/ping-pong/) the second page has a transparent background.



Here you can see a video:

AWT2 - berkelium-java (resize handler is not implemented in this example)



The two pages are rendererd into an AWT Image/Window, but rendering to a texture will be as easy.

Hi.



I hope Iā€™m not breaking any ā€œDonā€™t bump old threadsā€ rule by posting here.



This is really fantastic. Iā€™ve was looking for a good way to get a webkit renderer into my game. Iā€™ve only got the TestIntegration code running yet so donā€™t know if it will cover what I want but Itā€™s a great start.



Iā€™m planing on using it for my ui. (Iā€™m a web-dev by day so it seems logical)

So no random browsing but specific specialized pages.



What worries me most is interaction lag. I.e time from click until reaction for instance. But Iā€™ll just have to do some tests and see how it feels.



Might report back with some progress later.



Since itā€™s been a while since this thread has been active. Is there a reason for the lack of activity. Did it turn out unusable or just a shifted focus?



Thanks

Hi there,



Yes, I was also planning on using it as an easy method of UI design for developers who arenā€™t willing (or capable) to work with Java and Nifty (or some other OpenGL toolkit)



As is, there is one major caveat out of the box: that Iā€™ve been unable to get this working for anything but Win32. Attempting to build for other operating systems required building Chromium (which at the time was having a heck of a time compiling on OS X Lion, I donā€™t know if the situation has improved since then).



That said, weā€™ve personally moved on to integration with the NetBeans Platform (and using standard Java Swing components) with some light NiftyGUI use for in-scene controls and prompts. Iā€™d still love to see this project be a usable item in jME3 but its cross-platform issues would need to be addressed before anything.



If someone has the time to get a consistent Chromium build process going for the big three platforms Iā€™d love to pick this up again :slight_smile:



P.S: Just did some quick Googling around and the information doesnā€™t seem to have changed much from a few months ago. My guess is you still need to trick GYP into thinking youā€™re on 10.6

Played around with it now.



http://i.imgur.com/wXDiY.png



It works OKā€™ish. Fast animation are a bit choppy though.



http://i.imgur.com/GofVz.jpg



If anyone else are going to look at this I can just mention that I changed it to send mouse position updates every frame, if they changed, instead of listening to mouse events. This made hover effects and that sort of thing much more responsive.



Lack of support for Mac is a issue, mostly from a principle point of view, but still I probably will go another way for any "main" projects. But it's a cool tool to have for tech demo stuff and that sort of thing.

I think this was a case of: When I couldn't have it, it seemed awesome. Not when I can have it... I'm not so sure anymore.

I'll need to sleep on this and see what I think in the morning.

Do you want to paste a patch here? I can change the code on GitHub or give you committer rights on it.