Is OnRenderProcessTerminated called only on the UI thread?

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.

Is OnRenderProcessTerminated called only on the UI thread?

Postby winapiwrapper » Thu Mar 29, 2018 8:52 am

Hello everyone!

Is OnRenderProcessTerminated guaranteed to be called on the UI thread? (TID_UI)
Can I safely call the CefBrowser::GetHost and CefBrowserHost::CloseBrowser methods from it?
I'd like to close the browser when the render process crashes (browser->GetHost()->CloseBrowser(true);)
winapiwrapper
Techie
 
Posts: 35
Joined: Sat Feb 24, 2018 10:27 am

Re: Is OnRenderProcessTerminated called only on the UI threa

Postby ndesktop » Thu Mar 29, 2018 9:50 am

cefclient implementation assumes the UI thread (cef\tests\cefclient\browser\client_handler.cc):
Code: Select all
void ClientHandler::OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
                                              TerminationStatus status) {
  CEF_REQUIRE_UI_THREAD();

  message_router_->OnRenderProcessTerminated(browser);
...


Other than that, this comes from WebContentsObserver::RenderProcessGone. I don't know the details, but you can assume this can be called for various reasons, UI, IO, DB, FILE etc.
So I won't assume the UI thread. But you can do the
Code: Select all
if(current thread != UI) {
  CefPostTask TID_UI .. args
  return;
}
...

trick.
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am

Re: Is OnRenderProcessTerminated called only on the UI threa

Postby magreenblatt » Thu Mar 29, 2018 11:03 am

It will be called on the UI thread as stated in the documentation.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Is OnRenderProcessTerminated called only on the UI threa

Postby winapiwrapper » Fri Apr 27, 2018 9:12 am

Thank you for your replies, I'm sorry for the late reply.
winapiwrapper
Techie
 
Posts: 35
Joined: Sat Feb 24, 2018 10:27 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 23 guests