Shutdown without reference leaks

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 without reference leaks

Postby Cromon » Sat Jun 02, 2018 7:11 am

After a few years of a break with CEF I have decided to try another application with it. I have realized things have changed a little bit but looks like so far it is for the good :). I am using 3.3359.1774.gd49d25f_windows64 version in debug and am running now into some issues when CefShutdown'ing. The error I am getting is as following:
Code: Select all
[0602/140157.190:WARNING:discardable_shared_memory_manager.cc(436)] Some MojoDiscardableSharedMemoryManagerImpls are still alive. They will be leaked.
[0602/140157.194:FATAL:interface_endpoint_client.cc(170)] Check failed: (sequence_checker_).CalledOnValidSequence().


And it breaks at:
Image

So what I could already figure out is that it only happens when I create a browser, without it I seem to be handling references correctly. Some additional information: I am using windowless single process mode. And here are some bits of my code:

Code: Select all
      void WebCore::onApplicationReady() const {
         CefWindowInfo windowInfo;
         windowInfo.SetAsWindowless(mWindow->getHandle());

         CefBrowserSettings browserSettings;
         browserSettings.background_color = 0;

         CefBrowserHost::CreateBrowser(windowInfo, mWebClient, "", browserSettings, nullptr);
      }


This is called in response to CefBrowserProcessHandler::OnContextInitialized. If I uncomment the CreateBrowser everything works fine.

When the window is closed and its time to shutdown the following is called (on mWebClient):
Code: Select all
      void WebClient::shutdown() {
         if(mLocalBrowser == nullptr) {
            mWebCore->onBrowserClosed();
         } else {
            mRemoteBrowser = nullptr;
            mLocalBrowser->StopLoad();
            mLocalBrowser->GetHost()->SetFocus(false);
            mLocalBrowser->GetHost()->CloseBrowser(true);
         }
      }


mLocalBrowser is saved from OnAfterCreated from CefLifespanHandler. mRemoteBrowser is in theory taken from CefRenderProcessHandler::OnContextCreated for JS interaction later, however it is commented out and always nulltptr for now.

The following is triggered from OnBeforeClose:
Code: Select all
      void WebClient::onBrowserClosed() {
         mLocalBrowser = nullptr;
         mWebCore->onBrowserClosed();
      }


This in return causes this:
Code: Select all
      void WebCore::onBrowserClosed() const {
         CefPostTask(TID_UI, base::Bind(CefQuitMessageLoop));
      }


Which breaks the message loop and gets here:
Code: Select all
         CefRunMessageLoop();

         CefClearSchemeHandlerFactories();
         mWebClient = nullptr;
         mLocalScheme = nullptr;

         mLogger.info("Shutting down CEF");
         CefShutdown();

         mApplication = nullptr;


I am not really sure which references are still alive, because this is what I see when debugging:
- In WebClient::onBrowserClosed: WebClient has 2 references, mLocalBrowser has 1 reference when I stepp through the nullptr assignment and it gets deleted.
- After CefRunMessageLoop the mWebClient has 1 reference, the mLocalScheme has 2 references and mApplication has 2 references.

If I can provide more details please let me know!

BR
Cromon
Cromon
Techie
 
Posts: 20
Joined: Sun Dec 15, 2013 9:04 am

Re: Shutdown without reference leaks

Postby magreenblatt » Sat Jun 02, 2018 6:27 pm

Are you using single-process mode or multi-threaded message loop?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Shutdown without reference leaks

Postby Cromon » Sun Jun 03, 2018 1:01 am

I am using single process mode and non multi threaded message loop:
Code: Select all
         CefSettings settings;
         settings.windowless_rendering_enabled = TRUE;
         settings.ignore_certificate_errors = TRUE;
         settings.single_process = true;
         settings.no_sandbox = true;
         settings.remote_debugging_port = 52231;
         settings.multi_threaded_message_loop = false;


However I do run all CEF initialization as well as the message loop in a different thread than my main application.
Cromon
Techie
 
Posts: 20
Joined: Sun Dec 15, 2013 9:04 am

Re: Shutdown without reference leaks

Postby magreenblatt » Sun Jun 03, 2018 11:10 am

Single-process mode is unsupported. I suggest you use multi-process mode instead.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Shutdown without reference leaks

Postby Cromon » Sun Jun 03, 2018 1:06 pm

Ok, thats sad to hear. Maybe can you help me figure out which part is causing the issue? Is it a leaking reference or do you happen to know if that error is related to something else? Is there a way to print some information about the objects that are still alive? Something like D3Ds ReportLiveObjects?
Cromon
Techie
 
Posts: 20
Joined: Sun Dec 15, 2013 9:04 am

Re: Shutdown without reference leaks

Postby johndaintree » Wed Feb 20, 2019 11:56 am

Did you figure out what was causing this? I have a similar failure in 3.3538.
johndaintree
Newbie
 
Posts: 2
Joined: Wed Feb 20, 2019 11:24 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 69 guests