crashed when call CefShutdown in MFC based app

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.

crashed when call CefShutdown in MFC based app

Postby jasonswordt2 » Wed Jan 04, 2017 8:52 pm

I got a example using cef with mfc like this https://www.codeproject.com/Articles/1105945/Embedding-a-Chromium-browser-in-an-MFC-application

,but same error always happen when i call CefShutdown, like this http://magpcss.org/ceforum/viewtopic.php?f=6&t=14154;

and call CefDoMessageLoopWork before CefShutdown doen't help.

I use this project in both CEF cef_binary_3.2785.1474.g4a88e67_windows32 and cef_binary_3.2623.1401.gb90a3be_windows32, both crashed when i call CefShutdown.

[0104/152539:FATAL:browser_main.cc(189)] Check failed: 0 == CefBrowserContext::DebugObjCt (0 vs. 1)
[0104/152547:FATAL:browser_main.cc(203)] Check failed: 0 == CefURLRequestContext::DebugObjCt (0 vs. 1)
[0104/153332:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
0x7681C54F (KernelBase.dll) (cefmfcdemo.exe )first exception: 0x0000071A: The remote procedure call was canceled, or if a call time-out was specified, the call timed out。
[0104/153332:FATAL:browser_context_impl.cc(51)] Check failed: all_.empty().
[0104/153333:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
[0104/153333:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
[0104/153334:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
[0104/153334:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().


I do this in MFC SDI and MFC Dialog Based app, I call CefDoMessageLoopWork in CWinApp::PumpMessage() -> destory browser window -> close main window -> CefShutdown, it crashed.

but in WIN32 app,when I use CefRunMessageLoop -> CefQuitMessageLoop() -> CefShutdown(), it seems works fine.

can anyone solve this?
jasonswordt2
Techie
 
Posts: 13
Joined: Wed Jan 04, 2017 8:18 pm

Re: crashed when call CefShutdown in MFC based app

Postby amaitland » Thu Jan 05, 2017 7:53 pm

Make sure your using a Release build of CEF
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1291
Joined: Wed Jan 14, 2015 2:35 am

Re: crashed when call CefShutdown in MFC based app

Postby ScottV » Fri Jan 06, 2017 10:26 am

Here's how I shut down CEF in MFC using with PumpMessage.

In ExitInstance:

// stop message loop
m_bCEFInitialized = FALSE;
m_cefApp = NULL;
CefDoMessageLoopWork();
try {
CefShutdown();
}
catch (...){
ASSERT(FALSE);
}


In PumpMessage:

// do CEF message loop
if (m_bCEFInitialized) {
CefDoMessageLoopWork();
}

Example:
https://bitbucket.org/TSS_DEV/cef-mfc

--Scott
ScottV
Techie
 
Posts: 27
Joined: Thu Mar 27, 2014 1:22 pm

Re: crashed when call CefShutdown in MFC based app

Postby jasonswordt2 » Sat Jan 07, 2017 1:49 am

Code: Select all
 
CefSettings settings;
   settings.no_sandbox = true;
   settings.multi_threaded_message_loop = false;
   settings.single_process = true;

   void* sandbox_info = NULL;
   
   CefInitialize(mainargs, settings, NULL, sandbox_info);


I finally got this, I use settings.single_process = true; for debug.

I realized this is the only difference between my MFC app and my WIN32 app,and that is the question.

maybe new version of the CEF no longer support this feature properly? or is there any additional things that I should do to avoid this?
jasonswordt2
Techie
 
Posts: 13
Joined: Wed Jan 04, 2017 8:18 pm

Re: crashed when call CefShutdown in MFC based app

Postby amaitland » Sat Jan 07, 2017 3:39 am

Single process mode is unsupported, don't use it.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1291
Joined: Wed Jan 14, 2015 2:35 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 44 guests