cef crash when closing

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.

cef crash when closing

Postby yong018wu » Tue Jan 14, 2020 9:00 pm

Hi Expert,
In cefclient sample, close browser should be better to TryClose or Close(false), then give cef second chance the close the browser. but it's not easy to do that in my complex windows project. So I simply close it with Close(true). Does that has side effect?
I have a crash that happened when message router remove the handler, I remove the handler in OnBeforeClose, here's the crash stack, do you have ever met this kind of crash, or give me some tip, if something I did wrong.



05bcf5b8 60a18ff4 1c17daa8 ffffffff 05bcf58c cefwrapper!`anonymous namespace'::CefMessageRouterBrowserSideImpl::SendQueryFailure+0x4a [d:\cef\prebuilt\cef_binary_76.1.9+g2cf916e+chromium-76.0.3809.87_windows32\libcef_dll\wrapper\cef_message_router.cc @ 436]
02 05bcf5f0 60a1b88c 000037de 00000000 1c17daa8 cefwrapper!`anonymous namespace'::CefMessageRouterBrowserSideImpl::CancelQuery+0x54 [d:\cef\prebuilt\cef_binary_76.1.9+g2cf916e+chromium-76.0.3809.87_windows32\libcef_dll\wrapper\cef_message_router.cc @ 469]
03 05bcf61c 60a1a7cd 0000000d 000037de 00000000 cefwrapper!``anonymous namespace'::CefMessageRouterBrowserSideImpl::CancelPendingFor'::`2'::Visitor::OnNextInfo+0x4c [d:\cef\prebuilt\cef_binary_76.1.9+g2cf916e+chromium-76.0.3809.87_windows32\libcef_dll\wrapper\cef_message_router.cc @ 510]
04 05bcf664 60a18f62 05bcf67c 13f9d292 00000001 cefwrapper!CefBrowserInfoMap<__int64,`anonymous namespace'::CefMessageRouterBrowserSideImpl::QueryInfo *,DefaultCefBrowserInfoMapTraits<`anonymous namespace'::CefMessageRouterBrowserSideImpl::QueryInfo *> >::FindAll+0x7d [d:\cef\prebuilt\cef_binary_76.1.9+g2cf916e+chromium-76.0.3809.87_windows32\libcef_dll\wrapper\cef_browser_info_map.h @ 122]
05 05bcf6a4 60a1c62b 00000000 32c85ca0 00000001 cefwrapper!`anonymous namespace'::CefMessageRouterBrowserSideImpl::CancelPendingFor+0x122 [d:\cef\prebuilt\cef_binary_76.1.9+g2cf916e+chromium-76.0.3809.87_windows32\libcef_dll\wrapper\cef_message_router.cc @ 530]
06 05bcf6d0 609fd637 32c85d80 13f9d2ca 05bcf74c cefwrapper!`anonymous namespace'::CefMessageRouterBrowserSideImpl::RemoveHandler+0xeb [d:\cef\prebuilt\cef_binary_76.1.9+g2cf916e+chromium-76.0.3809.87_windows32\libcef_dll\wrapper\cef_message_router.cc @ 165]
07 05bcf6fc 60a2eb91 3c4ce020 13f9d316 374ff9c8 cefwrapper!CefWrapper::ClientHandler::OnBeforeClose+0x47 [j:\jabber\products\jabber-win\src\cefwrapper\src\clienthandler.cpp @ 702]

By they way, the close mechanism is so ugly.
yong018wu
Techie
 
Posts: 17
Joined: Wed Nov 01, 2017 1:17 am

Re: cef crash when closing

Postby Czarek » Wed Jan 15, 2020 5:13 am

It's a DEBUG CHECK in message router. You should receive a process message in renderer with error code and error message, see: https://github.com/chromiumembedded/cef ... er.cc#L440

Test with latest CEF v79.
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: cef crash when closing

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

I was doing OSR and I ended up doing this to close the system, idk if it is the right way, but it differs drastically from the demos:
In this code there is only one browser but I imagine it could work with more.
Code: Select all
    void CloseAllBrowsers(bool force_close) {


        mBrowser->GetHost()->TryCloseBrowser();
       
        while (!mBrowser->HasOneRef()) {
            CefDoMessageLoopWork();
        }

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

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

        CEF_REQUIRE_UI_THREAD();
    }

nickak2003
Techie
 
Posts: 43
Joined: Fri Apr 10, 2015 6:53 pm

Re: cef crash when closing

Postby Czarek » Fri Jan 17, 2020 2:15 pm

You're having an issue with message router. Read documentation in cef_message_router.h and if that's not enough to understand what you're doing wrong see also code comments in cef_message_router.cc. If you're sending an inter-process message during browser closing then it might fail if for example the renderer process doesn't exist anymore.
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


Return to Support Forum

Who is online

Users browsing this forum: Majestic-12 [Bot] and 26 guests