[SOLVED] CefShutdown() crash/breakpoint

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.

[SOLVED] CefShutdown() crash/breakpoint

Postby rpgplayerrobin » Mon Jun 27, 2016 9:30 am

Hello!

My name is Robin Norrman and I have recently started to experiment in CEF, so I am still a newbie. :D

I have experienced a crash/breakpoint on the CefShutdown() function.
I am using CEF to offscreen render, which works very well.
The output is perfect and everything else is working correctly.

When I check the code, it seems like the global browser context (and the URL request context) has more than 1 references left, and that is why the error occur.

Of course this only happens in debug, never in release, since it seems to only be a breakpoint (even thought the log says it is FATAL).

I am just wondering if this is something I should be worried about, or always use the release version instead and just disregard this debug breakpoint error?


If something really is wrong, here is my log before I get the crash/breakpoint:
Code: Select all
[0627/142048:WARNING:histogram_base.cc(131)] 2 histograms were created before reporting was enabled.
[0627/142049:WARNING:histogram_base.cc(131)] 2 histograms were created before reporting was enabled.


After I get the crash/breakpoint:
Code: Select all
[0627/142102:FATAL:browser_main.cc(184)] Check failed: 0 == CefBrowserContext::DebugObjCt (0 vs. 1)


When I continue (press continue once for each line) from the compiler after it triggered the breakpoint:
Code: Select all
[0627/142228:FATAL:browser_main.cc(198)] Check failed: 0 == CefURLRequestContext::DebugObjCt (0 vs. 1)
[0627/142241:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
[0627/142250:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
[0627/142251:FATAL:browser_context_impl.cc(51)] Check failed: all_.empty().
[0627/142251:FATAL:browser_context_impl.cc(52)] Check failed: map_.empty().
[0627/142252:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
[0627/142252:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
[0627/142252:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().
[0627/142253:FATAL:keyed_service_factory.cc(21)] Check failed: mapping_.empty().



Here is my call stack:
Code: Select all
    libcef.dll!base::debug::BreakDebugger() Line 21   C++
    libcef.dll!logging::LogMessage::~LogMessage() Line 738   C++
    libcef.dll!CefBrowserMainParts::PostMainMessageLoopRun() Line 186   C++
    libcef.dll!content::BrowserMainLoop::ShutdownThreadsAndCleanUp() Line 977   C++
    libcef.dll!content::BrowserMainRunnerImpl::Shutdown() Line 212   C++
    libcef.dll!CefMainDelegate::ShutdownBrowser() Line 661   C++
    libcef.dll!CefContext::FinalizeShutdown() Line 466   C++
    libcef.dll!CefContext::Shutdown() Line 347   C++
    libcef.dll!CefShutdown() Line 172   C++
    libcef.dll!cef_shutdown() Line 216   C++
>   osr.exe!CefShutdown() Line 204   C++
    osr.exe!CWebBrowserHandler::Clear() Line 30   C++
    osr.exe!CWebBrowserHandler::Destroy() Line 58   C++
    osr.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int iShowCmd) Line 53   C++
    osr.exe!__tmainCRTStartup() Line 528   C
    osr.exe!WinMainCRTStartup() Line 377   C



I am using SetAsWindowless and these settings:
Code: Select all
settings.no_sandbox = true;
settings.windowless_rendering_enabled = true;
settings.multi_threaded_message_loop = false;



I am also setting the 'settings.cache_path' and 'settings.log_file', which both work correctly.


Then on the OnBeforeCommandLineProcessing function, I am using these switches:
Code: Select all
command_line->AppendSwitch("enable-system-flash");
if (!command_line->HasSwitch("disable-extensions") && !command_line->HasSwitch("disable-pdf-extension"))
   command_line->AppendSwitch("disable-surfaces");
command_line->AppendSwitch("disable-gpu");
command_line->AppendSwitch("disable-gpu-compositing");
command_line->AppendSwitch("disable-accelerated-video-decode");
command_line->AppendSwitch("enable-begin-frame-scheduling");
command_line->AppendSwitch("enable-media-stream");



I am using this version of Cef (from https://cefbuilds.com/):
Windows 32bit 2016-06-20 CEF 3.2704.1431.ge7ddb8a (119MB) (only 7 days old)


I have double checked everything, and the ref count on all my pointers seem to be going down to 0 before I use CefShutdown().
It seems to only be the global context that still has an invalid ref count, for some reason... How can the global context get to a state like this? I must be doing something wrong.


Anyone have any idea what could cause this? I am lost with more than 12 hours of trying to fix this... :?
Maybe it is not something that I should fix, and just use the release version at all times?

Cheers,

Robin Norrman
Last edited by rpgplayerrobin on Mon Jun 27, 2016 10:47 pm, edited 1 time in total.
rpgplayerrobin
Newbie
 
Posts: 2
Joined: Mon Jun 27, 2016 9:15 am

Re: CefShutdown() crash/breakpoint

Postby rpgplayerrobin » Mon Jun 27, 2016 10:46 pm

Apparently there was nothing I was doing wrong... The answer was in this post:

viewtopic.php?f=6&t=13777&start=10

I did not believe that a call (or multiple) to CefDoMessageLoopWork before CefShutdown would do any difference, but apparently that solved everything for me.
I have not seen that been used in any example code so far though... Isn't this a bit wierd?

Oh well, I am happy it works now at least! :D
rpgplayerrobin
Newbie
 
Posts: 2
Joined: Mon Jun 27, 2016 9:15 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 74 guests