How to quit the application safely?

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.

How to quit the application safely?

Postby chenon » Mon Sep 27, 2010 5:43 am

I found that the cef application occasionally crashed when main window closed by user.
It raised error message about reference count.

To confirm this problem, I add a Sleep() in function ProcessRequest in scheme_test.cpp.
Code: Select all
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
                              std::wstring& mime_type, int* response_length)
{
  bool handled = false;

#if 1 //add delay here
  Sleep(5000);
  //PostMessage(AppGetMainHwnd(), WM_DESTROY, 0, 0);
#endif

  Lock();
  ...
}

If closing the main window in the 5 seconds on sleep, the cef will raise the error information and then crash.

I get the similar error when using message WM_DESTROY instead of Sleep().
Only seen the error message in debug mode, shown as the attachment. Is it a bug?
Attachments
2010-09-27 18 26 29.png
2010-09-27 18 26 29.png (18.71 KiB) Viewed 6826 times
chenon
Newbie
 
Posts: 3
Joined: Mon Sep 27, 2010 5:21 am

Re: How to quit the application safely?

Postby magreenblatt » Mon Sep 27, 2010 8:32 am

This assert means that a reference to a CefHandler object is being kept past the call to CefShutdown(). This is not unexpected since, in your example, the protocol handler is still executing when the application window is closed. The notification is intended for informational/debugging purposes.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to quit the application safely?

Postby chenon » Mon Sep 27, 2010 12:38 pm

Thank you! So it should be OK since that we use "Release" mode for real product.

CEF is the best framework for applications with WEB UI!
chenon
Newbie
 
Posts: 3
Joined: Mon Sep 27, 2010 5:21 am

Re: How to quit the application safely?

Postby magreenblatt » Mon Sep 27, 2010 12:52 pm

So it should be OK since that we use "Release" mode for real product.

In this particular case you're fine (see http://code.google.com/p/chromiumembedd ... ail?id=113 for one potential caveat). Worst case hitting these asserts may mean your application isn't using the smart pointers correctly. For instance, if you make a change to your code and suddenly start hitting these asserts then you may have introduced a memory leak. However, since CefShutdown() is generally called when the application is exiting, potential memory leaks aren't necessarily an issue because in any case the OS will reclaim all memory when the application exits.

CEF is the best framework for applications with WEB UI!

Glad you like it :-).
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

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