I went on with the development and integration of our c++/MFC application and stumbled upon a side effect which is verylikely determined by my ignorance about the whole CEF framework.
The application opens a browser on a local file HTML file, which needs to execute javascript. In order to achieve communication between JS and the MFC application I decided to take the path of the MessageRouter.
Everything works fine, communication between JS and C++ works fine, and everything is being performed as expected.
The "side effect", is that when I called CefShutdown, I end up failing the following DCHECK:
[0517/113444.995:FATAL:libcef_dll_wrapper.cc(242)] Check failed: base::AtomicRefCountIsZero(&CefBrowserCToCpp::DebugObjCt).
I spent lots of time on this post about the failed DCHECK: http://magpcss.org/ceforum/viewtopic.php?f=6&t=13556, and I made sure that everything as being executed at shutdown as suggested there.
I spent lots of time in trying to understand which/where/when I was copying around my CefRefPtr<CefBrowser> handle, but couldnt find it. Then yesterday I tried to locate the 'offending' part of code, whether it was some Handler method, or the html code, or the JS code or the communication between JS and MFC. The I finally identified where the 'offending' line of code was... It is the return value of the OnQuery callback implemented in my class inheriting from CefMessageRouterBrowserSide. Below there is the trimmed down implementation that allowed me to pinpoint the issue.
- Code: Select all
class MessageHandler : public CefMessageRouterBrowserSide::Handler {
public:
explicit MessageHandler(const CefString& startup_url)
: startup_url_(startup_url) {}
// Called due to cefQuery execution in message_router.html.
bool OnQuery(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int64,
const CefString& request,
bool,
CefRefPtr<Callback> callback) OVERRIDE
{
return true;
}
}
If I return true, then I have a leftover instance of CefBrowser... if I return false, then everything is being cleaned up appropriately and CefShutdown completes without issues.
I am very well aware that there are still too many things I dont have complete understanding of, so I would really appreciate if someone could help me in understanding a little bit more about this 'scenario'.
I am pretty sure that I did something wrong somewhere, or that we are missing some parts somewhere else, or both -.-
We are using Visual Studio 2017 15.7.0, and now we are integrating version 3.3359.1772
If you need further information, I will provide them
Thanks in advance