Shutdown errors

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.

Shutdown errors

Postby BobM » Wed May 11, 2016 4:32 pm

Hi, Could someone enlighten me as to what causes these FATAL errors when my application closes. I am just getting CEF going in my app so this is early days for me.
Thanks
Bob

    f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\winmdi.cpp(872) : AppMsg - Warning: GetWindowMenuPopup failed!
    The thread 0x56fc has exited with code 0 (0x0).
    The thread 0x8aa0 has exited with code 0 (0x0).
    The thread 0x93ac has exited with code 0 (0x0).
    The thread 0x4ee0 has exited with code 0 (0x0).
    [0512/072612:FATAL:browser_main.cc(187)] Check failed: 0 == CefBrowserContext::DebugObjCt (0 vs. 1)
    nbW.exe has triggered a breakpoint.

    The thread 0x5fc has exited with code 0 (0x0).
    The thread 0x2238 has exited with code 0 (0x0).
    The thread 0x2b40 has exited with code 0 (0x0).
    The thread 0x4a88 has exited with code 0 (0x0).
    The thread 0xa390 has exited with code 0 (0x0).
    The thread 0x634 has exited with code 0 (0x0).
    The thread 0x1724 has exited with code 0 (0x0).
    The thread 0x34b0 has exited with code 0 (0x0).
    The thread 0x3188 has exited with code 0 (0x0).
    [0512/072615:FATAL:browser_main.cc(201)] Check failed: 0 == CefURLRequestContext::DebugObjCt (0 vs. 1)
    nbW.exe has triggered a breakpoint.

    The thread 0x862c has exited with code 0 (0x0).
    The thread 0x17f8 has exited with code 0 (0x0).
    The thread 0x56b0 has exited with code 0 (0x0).
    [0512/072616:FATAL:keyed_service_factory.cc(19)] Check failed: mapping_.empty().
    nbW.exe has triggered a breakpoint.

    [0512/072617:FATAL:keyed_service_factory.cc(19)] Check failed: mapping_.empty().
    nbW.exe has triggered a breakpoint.

    Exception thrown at 0x7576DAD8 (KernelBase.dll) in nbW.exe: 0x0000071A: The remote procedure call was canceled, or if a call time-out was specified, the call timed out.
    [0512/072619:FATAL:browser_context_impl.cc(48)] Check failed: all_.empty().
    nbW.exe has triggered a breakpoint.

    [0512/072620:FATAL:keyed_service_factory.cc(19)] Check failed: mapping_.empty().
    nbW.exe has triggered a breakpoint.

    [0512/072622:FATAL:keyed_service_factory.cc(19)] Check failed: mapping_.empty().
    nbW.exe has triggered a breakpoint.

    [0512/072623:FATAL:keyed_service_factory.cc(19)] Check failed: mapping_.empty().
    nbW.exe has triggered a breakpoint.

    [0512/072625:FATAL:keyed_service_factory.cc(19)] Check failed: mapping_.empty().
    nbW.exe has triggered a breakpoint.
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm

Re: Shutdown errors

Postby magreenblatt » Wed May 11, 2016 6:33 pm

What OS and CEF version? How are you integrating it into your application?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Shutdown errors

Postby BobM » Wed May 11, 2016 6:54 pm

Windows 10 and CEF cef_binary_3.2556.1368.g535c4fb_windows32. I'm using a sub-process executable.
Thanks.
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm

Re: Shutdown errors

Postby magreenblatt » Thu May 12, 2016 8:08 am

It looks like you're using MFC. How are you running the CEF message loop? Where are you calling CefInitialize and CefShutdown? What other values are you configuring via CefSettings?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Shutdown errors

Postby BobM » Thu May 19, 2016 5:43 pm

Yes, MFC. I'm using cef in a sub-process. In the main application process I call cef message loop in PumpMessage...

Code: Select all
BOOL
TMyApp::PumpMessage()
{
  // do CEF message loop
  if( m_bCEFInitialized )
     CefDoMessageLoopWork();

  return TNBApplication::PumpMessage();
}


I initialize cef in InitInstance...

Code: Select all
CefMainArgs main_args(GetModuleHandle(NULL));

  // Parse command-line arguments.
  CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
  command_line->InitFromString(::GetCommandLineW());
  ClientApp::ProcessType process_type = ClientApp::GetProcessType(command_line);
  if (process_type == ClientApp::BrowserProcess)
    m_CEFClientApp = new ClientAppBrowser();
  else
  {
    AfxMessageBox(_T("CEF ClientApp type check failed!"), MB_OK | MB_ICONERROR);
    return FALSE;
  }

  // Populate this structure to customize CEF behavior.
  CefSettings settings;
  CefString(&settings.log_file).FromASCII("E:\\a\nbcef.log");
  settings.no_sandbox = true;

  // Specify the path for the sub-process executable.
  CStringA cefAppPath;
  GetPartsFromPathA(CAFROMT(prog_net_path), cefAppPath, GFN_DRIVE | GFN_DIR);
  AppendPathA(cefAppPath, "NBCEF.EXE");
  CefString(&settings.browser_subprocess_path).FromASCII(cefAppPath.GetString());
  // Initialize CEF in the main process.
  m_bCEFInitialized = CefInitialize(main_args, settings, m_CEFClientApp.get(), NULL);


and cleanup in ExitInstance....

Code: Select all
int
TMyApp::ExitInstance ()
{
  // Shut down CEF.
  if (m_bCEFInitialized)
    CefShutdown();

  return TNBApplication::ExitInstance();
}


I think is probably caused by MDI child self deleting from within cef message handler. I will have a close look at the message processing.
Thanks
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm

Re: Shutdown errors

Postby BobM » Mon May 23, 2016 7:41 pm

Hi, I'm still trying to work out why I get an exception during my program shutdown.
Is summary, My application is written in MFC and has multiple tabs for browsers. I am using a separate sub-process for cef.
If I close the browser tabs before closing the app then I don't have a problem. But If I close the app before closing the browser tabs then I get an exception in cef and the output shows this...

[0524/103348:FATAL:browser_main.cc(189)] Check failed: 0 == CefBrowserContext::DebugObjCt (0 vs. 1)

So I see that the CefBrowserContext objects should be 0 at CefBrowserMainParts::PostDestroyThreads.

I suspect I have a problem in object lifetime (CWnd or cef). Does the above message give any clue?
Thanks
Bob
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm

Re: Shutdown errors

Postby amaitland » Mon May 23, 2016 8:30 pm

You need to close the browsers (and wait for them to close) before calling `CefShutdown`. Are you just calling `CefShutdown`?

`CefLifeSpanHandler::DoClose` doco is worth reading.

apidocs3/projects/%28default%29/CefLifeSpanHandler.html#DoClose%28CefRefPtr%3CCefBrowser%3E%29
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: Shutdown errors

Postby BobM » Wed May 25, 2016 5:59 pm

Thanks!

I have now implemented the process as described in DoClose doco etc. I am definitely processing DoClose correctly (returning true and re-sending WM_CLOSE to the window etc) That appears to be all working fine.

Then in my CWinApp::ExitInstance override I call CefShutdown. I've added some reference counting to my ClientHandler objects and they are definitely being processed correctly in OnBrowserClosed by detaching delegate and setting browser and client handler instances to NULL. If the application is closing I post another WM_CLOSE to the main frame. And I am definitely waiting for all browsers to pass through OnBrowserClosed.

This all appears to be working correctly, except that when CefShutdown is called I still tet the FATAL check below - UNLESS I add in some additional message pumping at the end of the main frame OnClose method. So it seems that even after all browsers are closed correctly CEF requires some additional message pumping to finish cleanup.

So the question is - how much? I find if I don't pump for long enough then I will get the error. Is there a way to query CEF to find out if it has finished cleaning up while pumping messages - i.e. to know if it is now safe to call CefShutdown?

Thanks
Bob
BobM
Mentor
 
Posts: 72
Joined: Wed May 11, 2016 4:28 pm

Re: Shutdown errors

Postby magreenblatt » Wed May 25, 2016 6:41 pm

Having to call CefDoMessageLoopWork multiple times during shutdown is a known problem. Calling it approx 10 times seems to work.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Shutdown errors

Postby Czarek » Thu May 26, 2016 12:08 am

magreenblatt wrote:Having to call CefDoMessageLoopWork multiple times during shutdown is a known problem. Calling it approx 10 times seems to work.

Is there an issue tracking this problem? I've searched on bitbucket, but no luck.

EDIT: found this topic (viewtopic.php?f=6&t=13994#p30093) with a reference to Issue 1805 (resolved).
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 43 guests