StreamReader refcount is crashing shutdown.

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.

StreamReader refcount is crashing shutdown.

Postby Da1TruEcho » Wed Mar 22, 2017 1:50 pm

I'm using CEF 2883 in a multi process setup inside of a Windows MFC application. When am I suppose to release references to CefRefPtr<CefStreamReader>?

I created a custom scheme handler to load an html page from memory. I have a member object that holds the stream reader returned by CefStreamReader::CreateForData. I'm setting this member object to null in CefLifeSpanHandler's OnBeforeClose. I'm still receiving the following log message from inside of CefShutdown.

[0322/143529:FATAL:libcef_dll_wrapper.cc(313)] Check failed: base::AtomicRefCountIsZero(&CefStreamReaderCToCpp::DebugObjCt).
Da1TruEcho
Techie
 
Posts: 14
Joined: Sun Mar 05, 2017 9:42 pm

Re: StreamReader refcount is crashing shutdown.

Postby magreenblatt » Wed Mar 22, 2017 2:15 pm

What else has a reference to the CefStreamReader object?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: StreamReader refcount is crashing shutdown.

Postby Da1TruEcho » Wed Mar 22, 2017 2:22 pm

Only that one member object inside of my handler class.
Da1TruEcho
Techie
 
Posts: 14
Joined: Sun Mar 05, 2017 9:42 pm

Re: StreamReader refcount is crashing shutdown.

Postby Da1TruEcho » Wed Mar 22, 2017 2:28 pm

class Handler : public CefClient,
public CefDisplayHandler,
public CefLifeSpanHandler,
public CefLoadHandler,
public CefResourceHandler,
public CefContextMenuHandler,
public CefJSDialogHandler,
public CefDownloadHandler,
public CefRequestHandler
{

public:
//handler implentation code

private:
CefRefPtr<CefStreamReader> m_pStream;

};


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

bool Handler::ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback)
{
//This function loads the html file into memory
CreateResponseFromResource(theApp.m_hInstance, MAKEINTRESOURCE(IDT_HTMLFILE), &html_content);

m_pStream = CefStreamReader::CreateForData(static_cast<void*>(html_content.GetMemLocation()), html_content.GetSize());
m_streamMimeType = CefString(_T("text/html"));


callback->Continue();

return true;
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

bool Handler::ReadResponse(void * data_out, int bytes_to_read, int & bytes_read, CefRefPtr<CefCallback> callback)
{
if (!m_pStream)
return false;

DWORD address = DWORD(data_out);
CString output;

bytes_read = m_pStream->Read(data_out, 1, bytes_to_read);
return (bytes_read > 0);
}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void Handler::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
CEF_REQUIRE_UI_THREAD();
m_pStream = NULL;
}
Da1TruEcho
Techie
 
Posts: 14
Joined: Sun Mar 05, 2017 9:42 pm

Re: StreamReader refcount is crashing shutdown.

Postby Da1TruEcho » Wed Mar 22, 2017 2:49 pm

I discovered my problem. I was calling CreateForData 6 times but only releasing 4 of the references.
Da1TruEcho
Techie
 
Posts: 14
Joined: Sun Mar 05, 2017 9:42 pm


Return to Support Forum

Who is online

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