HowTo: offscreen web-rendering with cef

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Sun Oct 06, 2013 12:09 pm

Hey guys

Screeny:
Image

Feature video:
[youtube]MVvHmxHpf-Y[/youtube]
http://markus-lanner.com/cef/ogre_demo/ ... _ois.mpeg4

Video of HowTo results:
[youtube]wVZmdM_APis[/youtube]
http://markus-lanner.com/cef/ogre_demo/ ... re3d.mpeg4

In the last two days I successfully implemented offscreen web-rendering with cef3 https://code.google.com/p/chromiumembedded/
With cef3 you can render any website to a texture, with all the rich features and advantages of the chromium engine.

Because of the lack of a nice simple example for offscreen-rendering, I created one.
https://github.com/qwertzui11/cef_osr
To compile the demo you need Ogre3d_1.9 http://ogre3d.org/download and the latest cef3 build http://cefbuilds.com/
link libOgreMain.so/OgreMain.dll, libcef.so/libcef.dll and libcef_dll_wrapper.a/libcef_dll_wrapper.lib

The demo launches the chrome experiment "monster" http://chromeexperiments.com/detail/monster/

Have fun
Markus
Last edited by qwertzui11 on Mon Feb 23, 2015 7:56 pm, edited 3 times in total.
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by Klaim » Sun Oct 06, 2013 2:52 pm

Nice work! How does it compare with Awesomium and Berkelium?
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Mon Oct 07, 2013 11:21 am

Klaim wrote:How does it compare with Awesomium and Berkelium?
- Awesomium uses chrome in the background too, a nice license, has support and I'm sure some nice easy-to-use features. cef is easy to use, with nice features too and open source. I've got no performance-comparision. All the web/plugin-work happens in a different process, so it doesn't really influence your main-process. I guess the performance is about the same. cef/Awesomium are just (render/input)-wrapper for chromium.
- berkelium: The actual version is still WIP https://github.com/berkelium/berkelium and the stable version https://github.com/sirikata/berkelium uses an outdated chrome version.

I really love how easy it is to integrate cef3. It takes only a few lines and runs nicely, as shown in the main.cpp in my first post.

Another video got added to my first post, which shows how offscreen rendering may be used.

Have fun
Markus
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by Klaim » Mon Oct 07, 2013 1:28 pm

qwertzui11 wrote: - Awesomium uses chrome in the background too, a nice license, has support and I'm sure some nice easy-to-use features. cef is easy to use, with nice features too and open source. I've got no performance-comparision. All the web/plugin-work happens in a different process, so it doesn't really influence your main-process. I guess the performance is about the same. cef/Awesomium are just (render/input)-wrapper for chromium.
Then license and open-source are the main differences I guess. Awesomium provides two versions, one is a lot of dlls, the other is 2dlls which are the same but packed using upx.
Awesomium will soon provide 64bit support on Windows (which is the only feature I'm waiting before switching to 64bit-only for my game).
Does Cef compiles in 64bit on Windows too?
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Mon Oct 07, 2013 2:13 pm

Klaim wrote:Does Cef compiles in 64bit on Windows too?
http://cefbuilds.com/
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by Klaim » Tue Oct 08, 2013 12:51 am

qwertzui11 wrote:
Klaim wrote:Does Cef compiles in 64bit on Windows too?
http://cefbuilds.com/
I only see a white page. The sources is pure xml, so I can see the info, thanks, but you might have a problem with your website...
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Tue Oct 08, 2013 8:00 am

It's not my site, it's hosted and maintained by the Web Engine Team at Adobe - they provide daily builds for all platforms in debug and release mode. Website works for me with Firefox 24 and Chromium 28.
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by Klaim » Tue Oct 08, 2013 6:45 pm

I'm using Chrome and only see white page which source is pure xml.
0 x

User avatar
Zonder
Ogre Magi
Posts: 1129
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 20

Re: HowTo: offscreen web-rendering with cef

Post by Zonder » Wed Oct 09, 2013 8:00 am

Klaim wrote:I'm using Chrome and only see white page which source is pure xml.
It must be loading the transforms fr the page for some reason. Anyway on the page it says there is a 64bit experimental build
0 x
There are 10 types of people in the world: Those who understand binary, and those who don't...

paulby
Gnoblar
Posts: 1
Joined: Thu Apr 17, 2014 12:43 am

Re: HowTo: offscreen web-rendering with cef

Post by paulby » Thu Apr 17, 2014 5:58 pm

Thanks for this great example. I'm just getting up to speed with cef3 and ogre. I got the example running under ogre 1.8.1, but it fails under 1.9. The quad is black, did something change in texture pipeline between 1.8.1 and 1.9 ?
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Fri Apr 18, 2014 12:52 am

The lightning changed.
Setting ambient light to Ogre::ColourValue::White
http://www.ogre3d.org/docs/api/1.9/clas ... 1f6a930ca2
should to the trick or simply add a directional light by
http://www.ogre3d.org/docs/api/1.9/clas ... 4b0d49c32e

Have fun
Markus
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Mon Feb 23, 2015 7:55 pm

- fixed sample for the newest cef version and ogre 1.9.
- created a github repo and set up a cmake build.
https://github.com/qwertzui11/cef_osr

Have fun
Markus
0 x

hydexon
Gremlin
Posts: 163
Joined: Sun Apr 14, 2013 8:51 pm

Re: HowTo: offscreen web-rendering with cef

Post by hydexon » Sat Mar 07, 2015 11:23 pm

Thats will be very useful for my projects!, but will be nice to use CEF to render HUD on OGRE (Specifically in OGRE 2.x, due to the new compositor system & architecture), will be A LOT more useful...

Also will be good the original example ported to the new version since they don't allow RTT's anymore and you're needed to use the new compositor system.

Just a suggestion...
0 x

User avatar
pergy
Gnoblar
Posts: 6
Joined: Tue Mar 31, 2015 2:35 pm

Re: HowTo: offscreen web-rendering with cef

Post by pergy » Fri Jul 24, 2015 8:59 am

hydexon wrote: Also will be good the original example ported to the new version since they don't allow RTT's anymore and you're needed to use the new compositor system.
The same code works in 2.1 if you create the texture in new manner!
In this thread you find the way, how to create and use manual texture in HLMS datablock:
http://www.ogre3d.org/forums/viewtopic.php?f=25&t=83727
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Fri Jul 24, 2015 9:06 am

thx
0 x

scottyp
Gnoblar
Posts: 24
Joined: Sat Jul 05, 2014 3:21 am

Re: HowTo: offscreen web-rendering with cef

Post by scottyp » Wed Sep 02, 2015 11:38 am

This looks awesome. Question: Does it work with older versions of Ogre? like 1.7?
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Wed Sep 02, 2015 1:08 pm

i dont see why not
0 x

bartekordek
Gnoblar
Posts: 3
Joined: Sun Oct 25, 2015 7:47 pm

Re: HowTo: offscreen web-rendering with cef

Post by bartekordek » Wed Nov 18, 2015 9:49 am

Unfortunately, your example crashes on CefDestroy().
I cannot look into cef code, because i cannot compile source package.
Do you know what may be the problem here?

Call stack:
> libcef.dll!base::debug::BreakDebugger() Line 21 C++
libcef.dll!logging::LogMessage::~LogMessage() Line 604 C++
libcef.dll!CefBrowserMainParts::PostMainMessageLoopRun() Line 189 C++
libcef.dll!content::BrowserMainLoop::ShutdownThreadsAndCleanUp() Line 946 C++
libcef.dll!content::BrowserMainRunnerImpl::Shutdown() Line 293 C++
libcef.dll!CefMainDelegate::ShutdownBrowser() Line 659 C++
libcef.dll!CefContext::FinalizeShutdown() Line 437 C++
libcef.dll!CefContext::Shutdown() Line 323 C++
libcef.dll!CefShutdown() Line 149 C++
libcef.dll!cef_shutdown() Line 191 C++
osr.exe!CefShutdown() Line 179 C++
osr.exe!main(int argc, char * * argv) Line 216 C++
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Wed Nov 18, 2015 9:58 am

may u post the ogre and cef logs?
0 x

bartekordek
Gnoblar
Posts: 3
Joined: Sun Oct 25, 2015 7:47 pm

Re: HowTo: offscreen web-rendering with cef

Post by bartekordek » Thu Nov 19, 2015 1:01 pm

Of course, i uploaded them as attachements.
Attachments
debug.log
(145.46 KiB) Downloaded 187 times
Ogre.log
(16.7 KiB) Downloaded 168 times
0 x

rpgplayerrobin
Greenskin
Posts: 148
Joined: Wed Mar 18, 2009 3:03 am
x 15

Re: HowTo: offscreen web-rendering with cef

Post by rpgplayerrobin » Wed Jun 22, 2016 7:47 pm

Nice job with this project!

I also encountered the same crash, but I managed to fix it by putting this code before CefShutdown:

Code: Select all

browser->GetHost()->CloseBrowser(true); // If it is not closed, the CefShutdown function crashes
CefDoMessageLoopWork(); // Someone said that it can sometimes crash without using 3 of these for some reason
CefDoMessageLoopWork();
CefDoMessageLoopWork();
browser = nullptr;
browserClient = nullptr;
0 x

chengjinhu
Gnoblar
Posts: 1
Joined: Thu Aug 23, 2018 8:45 am

Re: HowTo: offscreen web-rendering with cef

Post by chengjinhu » Thu Aug 23, 2018 9:03 am

Nice! But, How do you handle mouse and keyboard events?
Can you share the example(http://markus-lanner.com/cef/ogre_demo/ ... _ois.mpeg4)?

Thx.
0 x

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Thu Aug 23, 2018 3:07 pm

0 x

User avatar
EricB
Gnome
Posts: 314
Joined: Fri Apr 09, 2010 5:28 am
Location: Florida
x 103
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by EricB » Sat Dec 22, 2018 5:28 am

Hey Markus, It's great to see you still supporting your work.

I am curious if you ever got around to porting this to OS X as you said you would look into in the CEF thread. I am having to replace Berkelium with CEF due to Apple canning 32bit support, and I have ran into an issue of OnPaint never being called in your sample. I have made the helper.app and I believe everything is set up as needed per CEF's recommendations. GetViewRect and GetRenderHandler are called just fine as well, so the overrides seem to be working. Just no OnPaint. I've tried both the latest with sandbox v2 and 3359 with the older sandbox... I'm on Ogre 1.10.12, using GLFW for window creation.

I'm quite befuddled. I would appreciate any help, the cefclient example is quite... overly verbose... :)
0 x
Image

qwertzui11
Halfling
Posts: 80
Joined: Wed May 14, 2008 10:44 am
Location: EU
x 1
Contact:

Re: HowTo: offscreen web-rendering with cef

Post by qwertzui11 » Mon Dec 24, 2018 5:43 pm

I got all sources and after some hours I succeeded in compiling it for mac. Both APIs (Ogre3d and cef) seem to have changed, including the cmake part :)
I'm now trying to make the application work again.
1 x

Post Reply