in a PC game I have ingame browser used for news, virtual currency shop and social networks. It's built with quite fresh update of Chromium Embedded Framework. The problem is when I open a browser window (website is working fine there) and then close, for certain websites CEF sub-process doesn't finish. I also may continue hearing audio, if it was Youtube video, for example. I use offscreen rendering, other native windows are not created, only subprocesses. To close the browser window I remove all references to CefBrowser and call:
m_browser->GetHost()->CloseBrowser(true);
I also tried other ways to close/destroy/finalize that render subprocess, such as loading 'about:blank' before closing, but that was no help: process stayed awake, audio continued playing. Important note: it happens only on certain websites, which I suppose use some feature, that others don't. When I tried to disable JavaScript in CEF settings, the bug disappeared, but I need JS.
Thank you!
CEF runtime configuration: multi-process, single threaded message loop, with subprocess path, windowless rendering, no sandbox.
PC configuration: OS Windows 8, VS 2010, Chromium Embedded Framework version 3.3071, build 1649, C++ language.
You should check your implementation of onbeforeunload.
CEF GeneralUsage writes about CefBrowserHost::CloseBrowser: The parent window then needs to call CloseBrowser(false) and wait for a second OS close event to indicate that the browser has allowed the close. The second OS close event will not be sent if the close is canceled by a JavaScript ‘onbeforeunload’ event handler or by the DoClose() callback.
And if you still want to just kill the sub-process , I would suggest you use the browser IPC message and exit at the app. At your game run
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create(KILL_subprocess);
m_browser->SendProcessMessage(PID_RENDERER, msg);
and at the subprocess implement “OnProcessMessageReceived”:
if (msg->GetName() == KILL_subprocess)
{
delete this;
std::exit(EXIT_FAILURE);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With