My browser client implementation of onBeforeClose() called m

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.

My browser client implementation of onBeforeClose() called m

Postby callum » Mon Sep 28, 2015 5:44 pm

My (console) app is not exiting cleanly and I think it's because my implementation of onBeforeClose() for the browser client is being called twice even though I only even create one browser.

The app initializes, calls CefRunMessageLoop(); loads a page then tries to exit when the page is loaded.

The code looks like this:
Code: Select all
void browser_client::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
    CEF_REQUIRE_UI_THREAD();
    std::cout << "browser=" << browser << std::endl;
    CefQuitMessageLoop();
    mParent->onRequestShutdown();
}


where mParent->onRequestShutdown() calls back into the client which then calls CefShutdown();

Why is onBeforeClose() being called more than once and is this the right shutdown methodology?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: My browser client implementation of onBeforeClose() call

Postby amaitland » Mon Sep 28, 2015 11:29 pm

Is `CefShutdown` called on the same thread that `CefInitialize` was called? That's a common cause of problems.

apidocs3/projects/%28default%29/%28_globals%29.html#CefShutdown%28%29

Usually I'd call `CefShutdown` after the message look exits.

https://bitbucket.org/chromiumembedded/ ... _win.cc-75
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: My browser client implementation of onBeforeClose() call

Postby callum » Tue Sep 29, 2015 12:27 pm

I believe they are but I'll check and look at those links.

Is it expected that the onBeforeClose is called twice with different values for the the 'browser' parameter? That suggests that 2 browsers have been created but I only explicitly create one as far as I can tell.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: My browser client implementation of onBeforeClose() call

Postby amaitland » Tue Sep 29, 2015 5:42 pm

callum wrote:Is it expected that the onBeforeClose is called twice with different values for the the 'browser' parameter?


What url are you loading? Have you compared the two, are the identifiers different? Checked the url of the main frame to see if they're different?
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: My browser client implementation of onBeforeClose() call

Postby callum » Tue Sep 29, 2015 8:10 pm

Using http://news.google.com as my test.

Getting ID and URL with:


Code: Select all
int id = browser.get()->GetIdentifier();
std::string url = std::string(browser.get()->GetMainFrame()->GetURL());


Both URLs and IDs are the same, both times onBeforeClose() is called.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 82 guests