CefLifeSpanHandler::DoClose not triggering OnBeforeClose

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.

CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby smessica » Tue Apr 05, 2016 8:22 am

I have a case, where :
- The browser is parented to an application-provided top-level OS window
- Process A creates the parent window
- Process B calls CefBrowserHost::CreateBrowser.
- When process A crash/killed ( not a regular exit ):
--- DoClose() is called, which triggers CloseBrowser(true)

However, OnBeforeClose() is never called.

How to force/guarantee a proper close of the browser object?

Thanks!
smessica
Techie
 
Posts: 13
Joined: Tue Jul 02, 2013 3:09 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby smessica » Wed Apr 13, 2016 3:11 am

Hi Marshall,

I would really appreciate some pointers on this issue.

Thanks!
Shay.
smessica
Techie
 
Posts: 13
Joined: Tue Jul 02, 2013 3:09 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby magreenblatt » Wed Apr 13, 2016 12:37 pm

Don't call CloseBrowser from DoClose(). See header file comments on DoClose().
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby smessica » Thu Apr 14, 2016 7:01 am

Thanks Marshall.

The root problem here is that the application ( another process ) that provided the parent window got killed.
This caused the OS to release all the HWND tree. So, "CefBrowserWindow" HWND and its children are not longer available.
This means that the mechanism of WM_CLOSE/WM_DESTROY is not available.

So, DoClose is getting called - but I do not see a way to tell CEF to release this object.
Is there a way at this point to reparent the browser to a NULL window?
Can you suggest of some way to trigger the CefBrowser destruction in this unfortunate situation?
smessica
Techie
 
Posts: 13
Joined: Tue Jul 02, 2013 3:09 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby magreenblatt » Thu Apr 14, 2016 7:31 am

You don't need to explicitly trigger browser destruction. The browser should be destroyed and OnBeforeClose() should be called when the browser window receives the WM_DESTROY message via window hierarchy tear-down. Or are you saying the browser window will not receive a WM_DESTROY message in your use case?
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby smessica » Thu Apr 14, 2016 1:40 pm

yes, that is the problem. When the separate process is killed abruptly, the OS clears the HWNDs without triggering any action.
And we can not post a WM_DESTROY message as the window is already invalid.
We detect the IPC channel drop and issue a CloseBrowser, which triggers the DoClose.
smessica
Techie
 
Posts: 13
Joined: Tue Jul 02, 2013 3:09 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby magreenblatt » Thu Apr 14, 2016 1:53 pm

smessica wrote:yes, that is the problem. When the separate process is killed abruptly, the OS clears the HWNDs without triggering any action.
And we can not post a WM_DESTROY message as the window is already invalid.
We detect the IPC channel drop and issue a CloseBrowser, which triggers the DoClose.

Are you calling CloseBrowser(true) when the channel is dropped? If not, why?
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby smessica » Thu Apr 14, 2016 1:56 pm

I do
smessica
Techie
 
Posts: 13
Joined: Tue Jul 02, 2013 3:09 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby magreenblatt » Thu Apr 14, 2016 2:21 pm

The lack of a WM_DESTROY message is an untested state. There's likely a bug resulting from that.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: CefLifeSpanHandler::DoClose not triggering OnBeforeClose

Postby smessica » Mon Apr 18, 2016 6:01 am

Looking via Spy++, I see that the only messages those windows get are WM_NCDESTROY ( in particular no WM_DESTROY ).
So, it seem that some fallback cleanup is needed on that event.
Or, to have the CloseBrowser(true) to perform the actual work in case, the window is no longer valid.
smessica
Techie
 
Posts: 13
Joined: Tue Jul 02, 2013 3:09 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 30 guests