Problem with OnBeforeClose not being called on Linux

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.

Problem with OnBeforeClose not being called on Linux

Postby calkins » Thu Aug 11, 2022 4:14 pm

I am currently working through a way to properly close and shut down my CEF process. My project is largely based of Cefsimple with some key differences. After we start up the process, we will reparent a new browser to a window running in a different process.

I have found two issues with my project that I can't place from my debugging.

The first is that when we close the parent window CEF will not automatically call closeBrowser on the child CEF window, it instead reparents it to the root window. The second problem is that when I manually call browser->getHost->closeBrowser(false) the CEF thread will correctly call DoClose() but not OnBeforeClose(). This makes it so that CefShutdown prints this error:
Code: Select all
Check failed: !IsCefShutdown(). Object reference incorrectly held at CefShutdown

1.Top level window is created in another process
2. Cefsimple is launched and cefsimple window is reparented to be child of window created in step 1
3. Top level window is closed. I observed that cefsimple window is still alive but has root window as parent
4. When entire application is shutdown, I call closeBrowser(false) on cefsimple window and DoClose() is called but not OnBeforeClose()
5. At shutdown I see error

My initial guess is that the problem is that I am not handling the linux delete_event directly but I do not see any reference to that code either in the Cefsimple project. Any help would be appreciated in figuring out why OnBeforeClose() is not being called.
Last edited by calkins on Thu Aug 11, 2022 4:57 pm, edited 1 time in total.
calkins
Techie
 
Posts: 10
Joined: Thu Aug 11, 2022 3:26 pm

Re: Problem with OnBeforeClose not being called on Linux

Postby magreenblatt » Thu Aug 11, 2022 4:43 pm

I suggest you look at the cefclient sample app instead as it uses a client-created parent window.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Problem with OnBeforeClose not being called on Linux

Postby calkins » Wed Aug 17, 2022 4:29 pm

Do you have any guidance on removing the parent for the browser? We got it to the point where while our application is running, we can remove the browser properly with closeBrowser. When the application is shutdown, the gdk windows are reparented or removed causing CEF not to call OnBeforeClose properly. We think that if we can remove the parent then call closeBrowser it should work correctly. We tested this by creating the browsers without a parent and everything would shutdown correctly when the application closed.

Here is our stacktrace for when CEF crashes.

Code: Select all
#0  0x00007fd043941395 in logging::LogMessage::~LogMessage() () from libcef.so
#1  0x00007fd04394164e in logging::LogMessage::~LogMessage() () from libcef.so
#2  0x00007fd03eea6c03 in shutdown_checker::AssertNotShutdown() () from libcef.so
#3  0x00007fd03eee843a in CefLifeSpanHandlerCToCpp::OnBeforeClose(scoped_refptr<CefBrowser>) () from libcef.so
#4  0x00007fd0437c450a in CefBrowserHostBase::OnBeforeClose() () from libcef.so
#5  0x00007fd0437a6d77 in AlloyBrowserHostImpl::DestroyBrowser() () from libcef.so
#6  0x00007fd0437ccb2f in CefBrowserInfoManager::DestroyAllBrowsers() () from libcef.so
#7  0x00007fd0437d7e0a in CefContext::ShutdownOnUIThread() () from libcef.so
#8  0x00007fd043805fe6 in CefMainRunner::FinishShutdownOnUIThread(base::OnceCallback<void ()>, base::WaitableEvent*) () from libcef.so
#9  0x00007fd043805edd in CefMainRunner::Shutdown(base::OnceCallback<void ()>, base::OnceCallback<void ()>) () from libcef.so
#10 0x00007fd0437d750a in CefContext::Shutdown() () from libcef.so
#11 0x00007fd0437d72f1 in CefShutdown() () from libcef.so
#12 0x000056501e697f39 in main (llItemSaIS1_EE12_M_check_lenEmPKc=<optimized out>,
calkins
Techie
 
Posts: 10
Joined: Thu Aug 11, 2022 3:26 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 47 guests