CEF integration into a game as an embedded browser

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

CEF integration into a game as an embedded browser

Postby DmitriyShevchik » Thu Aug 06, 2015 7:58 am

CEF is being integrated by me in a game application.
There are several crucible items to be covered for the final product and must be addressed.

1) The app is memory usage critical. It must support Windows (including XP) and low-level machines with 2GB RAM.
According the Issue 421 CEF can't be unloaded.
https://code.google.com/p/chromiumembed ... ail?id=421
We're looking into isolating CEF into a separate process which will use IPC/shared memory for transferring input and texture data.
Have you had any experience with it?
What do you think the most optimal way to implement this?
Is it possible to get rid of extra copying of texture buffer content?

2) Off-screen rendering.
Hardware offscreen render support topic viewtopic.php?f=8&t=11635
Any plans on getting this officially in the upstream?

3) IME.
How it's compatible with CEF off-screen rendering and fullscreen mode of the game app?
What would be the proper integration if we can't use Windows IME panels?

Thanks,
Dmitriy
DmitriyShevchik
Newbie
 
Posts: 6
Joined: Thu Aug 06, 2015 2:25 am

Re: CEF integration into a game as an embedded browser

Postby magreenblatt » Thu Aug 06, 2015 9:02 am

DmitriyShevchik wrote:1) The app is memory usage critical. It must support Windows (including XP) and low-level machines with 2GB RAM.
According the Issue 421 CEF can't be unloaded.
https://code.google.com/p/chromiumembed ... ail?id=421
We're looking into isolating CEF into a separate process which will use IPC/shared memory for transferring input and texture data.
Have you had any experience with it?
What do you think the most optimal way to implement this?
Is it possible to get rid of extra copying of texture buffer content?

Since off-screen rendering is currently software-only you can use shared memory to transfer the bitmap to your separate process with minimal copies.

DmitriyShevchik wrote:2) Off-screen rendering.
Hardware offscreen render support topic http://www.magpcss.org/ceforum/viewtopi ... =8&t=11635
Any plans on getting this officially in the upstream?

The implementation you reference is no longer valid. There are plans to support direct off-screen hardware rendering, however I doubt that would work in combination with your separate process design unless you have the ability to share textures between processes.

DmitriyShevchik wrote:3) IME.
How it's compatible with CEF off-screen rendering and fullscreen mode of the game app?
What would be the proper integration if we can't use Windows IME panels?y

See https://bitbucket.org/chromiumembedded/cef/issues/1217 which has a proposed implementation.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: CEF integration into a game as an embedded browser

Postby DmitriyShevchik » Tue Aug 11, 2015 4:59 pm

Thanks for the answers, magreenblatt.

It would be awesome if we could share HW-accelerated texture data between processes somehow in the future.
Anyway, back to realty.

I've implemented CEF execution in a separate process.
In CefRenderHandler::OnPaint() the provided buffer is copied to another buffer which is actually a shared memory region. Then this data is grabbed in a main application process and is copied to a texture.
I would like to reduce amount of copies. At the moment I'm wondering how we can copy GL data directly in shared memory.
Is there an easy way to hook content::GLHelper::CopyTextureToImpl::ReadbackDone() and copy GL content to a shared memory region which is provided by a CEF user?
The problem is not critical though.
DmitriyShevchik
Newbie
 
Posts: 6
Joined: Thu Aug 06, 2015 2:25 am

Re: CEF integration into a game as an embedded browser

Postby magreenblatt » Tue Aug 11, 2015 5:20 pm

For best performance you should run with GPU disabled: `--disable-gpu --disable-gpu-compositing --enable-begin-frame-scheduling` (you'll loose WebGL support but gain increased FPS and reduced CPU usage). Chromium will then render directly to the SoftwareOutputDevice implemented in libcef/browser/software_output_device_osr.[h|cc]. You can perform further CEF hacking from there to reduce additional copies.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 81 guests