Crash on CefShutdown on Mac ( CEF 3.1750.1805)

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.

Crash on CefShutdown on Mac ( CEF 3.1750.1805)

Postby Fallen » Mon Oct 13, 2014 9:29 am

My app crashes on exit, on CefShutdown() to be exact, here's how my application is run (also running in single_process = false):

Code: Select all
dispatch_queue_t serviceCalls = dispatch_queue_create("Service Calls", nil);
dispatch_async(serviceCalls, ^{

   while (self->m_allowShutdown == NO)
   {
      dispatch_async(dispatch_get_main_queue(), ^{
         self->m_coreProxy->serviceCalls();
         
         if (m_cefInitialized)
            CefDoMessageLoopWork();
      });
                  
      Poco::Thread::sleep(100);
   }
});


Code: Select all
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
   if (m_shutDownNow == NO)
   {
      if (m_cefHandler.get() && !m_cefHandler->isClosing())
         m_cefHandler->closeAllBrowsers(true);
      
      CefShutdown();
      
      self->m_allowShutdown = YES;
      
      dispatch_queue_t shutdownThread = dispatch_queue_create("Shutdown", nil);
      dispatch_async(shutdownThread, ^{
         while (m_coreShutdowned == NO)
            Poco::Thread::sleep(10);
         
         m_shutDownNow = YES;
         [[NSApplication sharedApplication] terminate:self];
      });
      
      return NSTerminateCancel;
   }
   else
   {
      return NSTerminateNow;
   }
}


Here's the stack trace:
Screen Shot 2014-10-13 at 16.28.34.png
Screen Shot 2014-10-13 at 16.28.34.png (388.78 KiB) Viewed 3515 times
Fallen
Techie
 
Posts: 39
Joined: Wed Jan 29, 2014 11:38 am

Re: Crash on CefShutdown on Mac ( CEF 3.1750.1805)

Postby magreenblatt » Mon Oct 13, 2014 4:45 pm

You are not handling shutdown correctly. See https://code.google.com/p/chromiumembed ... _mac.mm#40.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Crash on CefShutdown on Mac ( CEF 3.1750.1805)

Postby Fallen » Tue Oct 21, 2014 11:01 am

magreenblatt wrote:You are not handling shutdown correctly. See https://code.google.com/p/chromiumembed ... _mac.mm#40.


This example isn't good for me, I don't want to run a blocking run loop for CEF. Besides
- (void)createApplication:(id)object
uses deprecated methods for loading nibs. I have a window configured in my nib with a NSView and I want to attach CEF to it. I need to run NSApplicationMain(argc, argv);.
This method is called inside appplicationDidFinishLaunching:

Code: Select all
- (void)initializeCef:(CmdlineOptions)options
{
   std::vector<std::string> arguments = options.createArgumentsList();
   std::vector<std::string>::const_iterator it;
   NSUInteger argc = arguments.size();
   char *argv[argc];
   for (it = arguments.cbegin(); it != arguments.cend(); it++)
   {
      NSUInteger index = it - arguments.begin();
      argv[index] = const_cast<char *>((*it).c_str());
   }
   
   CefMainArgs main_args(argc, argv);
   m_cefApp = new GCefClientApp();
   
   CefSettings settings;
   
#ifndef PRODUCTION_ENVIRONMENT
   settings.ignore_certificate_errors = true;
   settings.remote_debugging_port = 12345;
#endif
   
   if (m_cefCmdLine == "disable")
      settings.log_severity = LOGSEVERITY_DISABLE;
   if (m_cefCmdLine == "info")
      settings.log_severity = LOGSEVERITY_INFO;
   if (m_cefCmdLine == "warning")
      settings.log_severity = LOGSEVERITY_WARNING;
   if (m_cefCmdLine == "error")
      settings.log_severity = LOGSEVERITY_ERROR;
   if (m_cefCmdLine == "error-report")
      settings.log_severity = LOGSEVERITY_ERROR_REPORT;
   
   std::string cefLogFile = Utilities::AppendPath(ApplicationEnvironment::GetLogsPath(), "cef.log");
   CefString(&settings.log_file) = CefString(cefLogFile);
   
   std::string webcachePath = Utilities::AppendPath(ApplicationEnvironment::GetWebcachePath(), "common");
   CefString(&settings.cache_path) = webcachePath;
   
   CefExecuteProcess(main_args, m_cefApp.get(), nullptr);
   
   m_cefInitialized = CefInitialize(main_args, settings, m_cefApp.get(), nullptr);
   CefCookieManager::GetGlobalManager()->SetStoragePath(CefString(), false); //store all cookies in memory only.
   
   m_cefHandler = new GCefClientHandler();
   m_cefApp->setCefClientHandler(m_cefHandler);
   
   NSView *view = [[self window] contentView];
   
   CefWindowInfo info;
   info.SetAsChild(view, view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
   
   CefBrowserSettings browserSettings;
   browserSettings.webgl = STATE_ENABLED;
   browserSettings.universal_access_from_file_urls = STATE_ENABLED;
   
#ifndef PRODUCTION_ENVIRONMENT
   browserSettings.javascript_open_windows = STATE_ENABLED;
#endif
   
   CefBrowserHost::CreateBrowserSync(info, static_cast<CefRefPtr<CefClient>>(m_cefHandler), "", browserSettings, nullptr);
}
Fallen
Techie
 
Posts: 39
Joined: Wed Jan 29, 2014 11:38 am


Return to Support Forum

Who is online

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