I spent the past day or so hacking together a managed wrapper for Sirikata’s Berkelium library. Berkelium allows you to easily embed a WebKit-based browser into games and other applications. It’s based on Chrome and it’s really easy to get up and running in a C++ application. Unfortunately, if you’re using C# or VB.net, you’re out of luck – no way to link directly against a C++ .lib file in those languages. The addition of my managed wrapper – BerkeliumSharp – means that you can use the library in managed applications, and integrate it with Windows Forms, XNA, or even WPF.
I’ve released the source under the BSD license (just like Berkelium) and included two simple examples (one for Windows Forms, one for XNA). It’s not a Chrome competitor but it’s surprisingly easy to get a lot of complicated things working – you can watch Hulu videos if you have Flash installed, and Flash games like Dino Run work in the Windows Forms example since it implements keyboard input.
You can download pre-built demos to test it out, or grab the source code over at Google Code.
Have fun!
P.S. If you try out the examples, be aware that content that opens pop-up windows doesn’t seem to work. I think this is a bug in Berkelium.
Edit: Figured out how to build Chromium and Berkelium myself and fixed the bug. Open source is awesome!




#1 by benjoTLV on February 23, 2010 - 4:39 am
Quote
Hi, thanks for this. It seems very promising. I was using for now Chris Cavanagh WPF browser based on Awesomium/Chromium, but I experienced some performance issues related to the lack of multi-process capabilities so this one should actually solve my problems (and it is on BSD!!)
Still, after downloading your demo, I cannot run it… I get an unhandled exception when running BerkeliumSharp.exe (cannot load file or assembly BerkeliumSharp…) and I get a crash at start up when running BerkeliumXNATest.exe.
Any idea? anything I am doing wrong?
Thanks
#2 by Kael on February 23, 2010 - 4:41 am
Quote
Did you unzip all the files into a folder and run the test executables from there? If you don’t do that, it won’t be able to find all the assemblies and libraries.
The XNA test won’t run if you don’t have XNA Game Studio 3.1 installed, also.
I’ve updated the examples to fix some bugs so you might want to try downloading a fresh copy of the ZIP.
#3 by benjoTLV on February 23, 2010 - 5:04 am
Quote
Redownloading the package solved my problem!
Thanks
#4 by CMay on February 23, 2010 - 7:06 am
Quote
Was looking for a wrapper the other day with no luck and was just about to start work on my own when I ran into this. Posted just 2 days ago, good timing.
Your demo app works fine here, though it’s a bit sluggish at larger window sizes. Then again, it is just a demo, so slowing it down with system.drawing.graphics.drawimage is no big deal.
Thanks.
#5 by Charley on March 8, 2010 - 12:06 pm
Quote
Has anyone played with this in WPF yet? Making something like Chris Cavanagh’s chromium web browser? http://chriscavanagh.wordpress.com/2009/08/25/wpf-chromium-webbrowser-source-code/
I’ve just started playing with it, but I haven’t had any luck building this. It seems to want the entire chromium source code.
#6 by Kael on March 8, 2010 - 12:57 pm
Quote
building berkelium does require a chromium build, yes.
I recommend using the binaries from the demos zip to get started. The techniques used by the winforms demo should apply to wpf.
#7 by Charley on March 8, 2010 - 2:20 pm
Quote
Kael,
Thanks for the quick reply.
The binaries in the demos zip are older than the BerkeliumTest code from the trunk and out of date, right? I tried to just run BerkeliumTest in debug in the IDE linking to the compiled binaries, but there were a lot of unrecognized methods. (AdjustZoom for instance).
Any chance of updating the binaries so I can use them with the source code of BerkeliumTest?
#8 by Kael on March 8, 2010 - 9:03 pm
Quote
Sorry about that. I’ve updated the demos ZIP with current binaries, and I also fixed an issue with the XNA test’s source code.
#9 by CMay on April 6, 2010 - 9:46 am
Quote
I noticed you improved some of the painting/bitmap reallocation code and thought I’d mention that to take it one step further you could set ControlStyles.OptimizedDoubleBuffer (.net 2.0) on WebKitFrame for a fairly large improvement.
Also, I think it’s interesting that you’re bundling the mess of depended files inside the DLL for neatness, but I have a feeling it might be undesirable for a number of scenarios and especially when wider distribution comes into the picture. Maybe eventually it could be worth pushing it all into a subdirectory of the host application?
#10 by Kael on April 6, 2010 - 11:21 am
Quote
CMay: Thanks for the tip, I’ll try it out. I experimented before with using DIBsections or SetDIBits directly but couldn’t get it working – something to do with how GDI interacts with WoW64, I suspect. Hopefully the optimized double buffer flag will be a perf win (in my profiles, GDI+ DrawImage is the bottleneck).
As far as the dependencies go, you could definitely bundle them into a subdirectory instead. The reason I went for the embedded resource approach is that it behaves correctly in the presence of tools that copy your assemblies around, like Visual Studio. If the dependencies are stray files they don’t get copied, so for example WebKitFrame would then break the Visual Studio Forms Designer (by failing to load due to missing dependencies). This also removes the need to add all the dependencies into your solution file to get them copied to the output directory.
#11 by Tom on April 7, 2010 - 7:13 am
Quote
Thanks for releasing this – it looks like it might be just what I need! Has anyone managed to get this working in WPF yet? I’ve been playing around with the BerkeliumTest demo but haven’t had any luck trying to get it to work in WPF.
#12 by Steven Lee on May 5, 2010 - 11:32 pm
Quote
It is really a good project, but I met some problem
1. how to setup proxy
2. failed to login gmail and yahoo.
#13 by Kael on May 6, 2010 - 12:03 am
Quote
Since it’s using Chromium’s network stack, I expect it will obey Internet Explorer’s proxy configuration on Windows, since that’s Chrome’s default behavior.
#14 by Steven Lee on May 9, 2010 - 8:11 pm
Quote
Type your comment here
yes, I forgot the proxy setting problem, but I have another problem, I can login gmail and yahoo.
#15 by ashkan on September 6, 2010 - 8:08 pm
Quote
thank you for creating a wrapper for this great tool. i want to use it in unity (www.unity3d.com) engine. i don’t know how to get source code from google code and downloads are binaries. how can i get the required libraries to start development. i downloaded the berkelium itself.
#16 by Ali on September 10, 2010 - 12:35 am
Quote
Any possibility of this working on Win Phone 7? I know it has XNA support and a webkit browser could make an absolute fortune from corporate customers on that app store…
#17 by Kevin on September 30, 2010 - 9:05 pm
Quote
Type your comment here
I’m interested in replacing the default web browser control in WPF with a webkit browser and this project looks very promising
How can I use the binaries from the demos zip to get started? Trying to reference BerkeliumSharp.dll causes an exception. I’ve also tried to get the source compiled but as you said I need a chromium build. If possible I would like to avoid building chromium until I validate that this works in WPF the way I am hoping.
Any feedback is greatly appreciated.
#18 by Kael on October 1, 2010 - 12:03 am
Quote
What’s the exception you get when referencing BerkeliumSharp.dll? It *should* just work out of the box, but perhaps there’s a dependency I missed.
#19 by Kevin on October 1, 2010 - 10:06 am
Quote
Type your comment here
I *was* getting a stack overflow exception, but I’ve re-downloaded the binaries and am able to add the reference now. Wish I would of tried that last night as I ended up spending several hours getting a chromium build going
#20 by Koichi Senada on October 20, 2010 - 1:13 am
Quote
Hello, Kael.
What version of Chromium is required to build BerkeliumSharp successfully?
How to get rid of dropdown combo boxes related crashes?
#21 by Kael on October 20, 2010 - 9:47 am
Quote
Crashes related to dropdown combo boxes probably mean you’re not handling widgets correctly. The windows forms example does this.
It builds against whatever version of chromium berkelium trunk was using at the time – I think 29571. Berkelium trunk is on a new version now.
#22 by Koichi Senada on November 26, 2010 - 7:21 am
Quote
Hello, Kael.
Thank you for the reply.
Would you please share your vision on the steps required for a working WPF demo application based on BerkeliumSharp here?
#23 by Renaud AVENAS on December 1, 2010 - 8:14 am
Quote
Hello,
I try to use the BerkeliumSharp dll in a WPF project. But it seems that the Paint event don’t work. Indeed, WPF don’t use the win form render loop. And I can’t build the BerkeliumSharp project (some .h was not found). Can you tell me if you want to do a new version off the dll for WPF?
#24 by Tom on December 3, 2010 - 8:44 am
Quote
I’m also interested in getting this working in wpf but don’t really know where to start. Any advice?
Cheers
#25 by Leam on January 18, 2011 - 8:50 am
Quote
I am very interested in this, as I could really use it for a project I am working on in my spare time, but I cant seem to get the source, is there a newer link for the source?
#26 by Mike on April 26, 2011 - 11:06 am
Quote
Great work! Any way you could provide a dead simple WPF example. I’ve been struggling with access errors. This project has given me a reason to ditch Awesomium which is far from awesome especially with it’s ridiculous license of $5000!
#27 by Therese on June 12, 2011 - 3:46 pm
Quote
Is this possible for mobile use? Cause there are mobile phones with XNA. I wanna play cool games with it. Thanks.
Therese