OSR shutting down, correct? what is the issue?

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.

OSR shutting down, correct? what is the issue?

Postby nickak2003 » Fri Jan 17, 2020 1:48 pm

So I set up an OSR browser. When I go try and shut the browser down so i can call CefShutdown, I was getting dangling reference errors which had to do with a reference held somewhere in the cef system that it was planning to release ( some sort of multi threaded effect maybe).
To resolve the issue I came up with the following, but am wondering if it is correct, or what exactly the problem was:
Code: Select all
   // Request that all existing browser windows close.
    void CloseAllBrowsers(bool force_close) {
        //there is a single browser right now - if i call CloseBrowser(true) instead, we get a crash later - an internal process is ongoing
        mBrowser->GetHost()->TryCloseBrowser();
       
        while (!mBrowser->HasOneRef()) {   //wait for the internal process to finish
            CefDoMessageLoopWork();
        }

        mBrowser = NULL;                           //destroy browser

        //from here we proceed to CefShutdown
    }

   void OnAfterCreated(CefRefPtr<CefBrowser> browser) override {
        CEF_REQUIRE_UI_THREAD();

        mBrowser = browser;
    }
    bool DoClose(CefRefPtr<CefBrowser> browser) {
        CEF_REQUIRE_UI_THREAD();

        return false;
    }
    virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override {

        CEF_REQUIRE_UI_THREAD();
    }


Am I doing something wrong, or is this correct?
nickak2003
Techie
 
Posts: 43
Joined: Fri Apr 10, 2015 6:53 pm

Re: OSR shutting down, correct? what is the issue?

Postby Czarek » Fri Jan 17, 2020 3:18 pm

If you provide code that works fine and don't provide code that didn't work, then how are we supposed to know what was wrong? :)

You have to free CEF references before shutting down. In DEBUG mode you can check stack trace when DEBUG CHECK is hit to know what object is causing issues.
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

Re: OSR shutting down, correct? what is the issue?

Postby nickak2003 » Sat Jan 18, 2020 11:51 am

if you could redirect to here please, viewtopic.php?f=6&t=17330
nickak2003
Techie
 
Posts: 43
Joined: Fri Apr 10, 2015 6:53 pm


Return to Support Forum

Who is online

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