Page 1 of 1

AssertNotShutdown in multithreaded app

PostPosted: Tue Sep 17, 2019 1:14 pm
by hunterlaux
I recently upgraded to 76.0.3809.132 and it seems like there was an overhaul of the shutdown_checker since the last time I upgraded.

After CefShutdown is called the I hit the following assert on the UI thread.

shutdown_checker::AssertNotShutdown() Line 54 C++
`anonymous namespace'::life_span_handler_on_before_close(_cef_life_span_handler_t * self, _cef_browser_t * browser) Line 198 C++
CefJSDialogHandlerCToCpp::OnDialogClosed(scoped_refptr<CefBrowser> browser) Line 135 C++
CefBrowserHostImpl::DestroyBrowser() Line 1508 C++
CefBrowserInfoManager::DestroyAllBrowsers() Line 332 C++
CefContext::FinishShutdownOnUIThread(base::WaitableEvent * uithread_shutdown_event) Line 609 C++

Am I suppose to be doing some additional cleanup before CefShutdown?

Re: AssertNotShutdown in multithreaded app

PostPosted: Wed Sep 18, 2019 1:55 am
by Czarek
You should release CEF objects before shutdown.

Re: AssertNotShutdown in multithreaded app

PostPosted: Wed Sep 18, 2019 4:06 pm
by hunterlaux
You should release CEF objects before shutdown.

I don't think that is it.

It seems like CefJSDialogHandlerCToCpp::OnDialogClosed is replacing CefLifeSpanHandler::OnBeforeClose in the wrapper.... Strange.

Re: AssertNotShutdown in multithreaded app

PostPosted: Thu Sep 19, 2019 2:41 am
by magreenblatt
Did you update your project include paths and rebuild libcef_dll_wrapper to match the new CEF version?

Re: AssertNotShutdown in multithreaded app

PostPosted: Mon Sep 23, 2019 5:36 am
by rjxray
I'm having a similar issue after updating from 3.3626.1891 to cef_binary_75.1.16+g16a67c4+chromium-75.0.3770.100_windows64.
I see the same replacement of OnBeforeClose by OnDialogClosed in the wrapper.
Capture.JPG
Capture.JPG (51.52 KiB) Viewed 5659 times


I've cleaned and rebuilt my app and that makes no difference.
I'm directly referencing the includes from my cef.sln build and copying the dll's from there as a Post-Build event

Checking with the the debugger OnBeforeClose() is never called after after I call browser->GetHost()->CloseBrowser(true) during my host window close event handling.

However if I call browser->GetHost()->CloseBrowser(true) during normal execution then OnBeforeClose() is called as expected.

A week or two ago I also tried cef_binary_73.1.13+g6e3c989+chromium-73.0.3683.75_windows64 and had the same issue.
It definitely does not happen with 3.3626.1891

Re: AssertNotShutdown in multithreaded app

PostPosted: Mon Sep 23, 2019 7:29 am
by rjxray
I think the reference to CefJSDialogHandler is a red herring.
I have been using a release version of libcef.dll with a debug build of my app as per viewtopic.php?f=6&t=16617&p=41200#p41200
On reverting to the debug version of libcef.dll I do see OnBeforeClose in the vfptr.

However I still have the issue of OnBeforeClose() not being called after after I call browser->GetHost()->CloseBrowser(true) during my host window close event handling.
and the application crashes when CefShutDown is called

CallStack.JPG
CallStack.JPG (42.56 KiB) Viewed 5651 times

Re: AssertNotShutdown in multithreaded app

PostPosted: Wed Nov 27, 2019 4:47 am
by rjxray
I finally figured out the issue and how to solve it.
I am not using CefRunMessageLoop() and am instead calling CefDoMessageLoopWork() on a regular basis.

So I also need to call CefDoMessageLoopWork() in my exit function to allow the browser to close properly

EG
Code: Select all
   bool closed = false;
   while (!closed) {
      closed = browser->GetHost()->TryCloseBrowser();
      CefDoMessageLoopWork();
   }

works for me, after a few iterations OnBeforeClose() is called and then TryCloseBrowser() returns true and then CefShutdown() is happy