Crash occurring during CefShutdown

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.

Crash occurring during CefShutdown

Postby ldamis » Wed Jul 29, 2020 9:02 am

Hi everybody.

Version: CEF 73.1.11+ge6986dc+chromium-73.0.3683.75
OS: Windows 10 64bit

In my solution I have a CEF browser embedded in another Win32 application: so, multi_threaded_message_loop = true and window created like that
Code: Select all
hWnd = CreateWindow(L"MyAppWindow", L"MyApp", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, x, y, width, height, _hWndParent, NULL, _hInstance, NULL);
...
CefWindowInfo info;
info.SetAsChild(hWnd, rect);
...
CefBrowserHost::CreateBrowser(info, _cef_handler.get(), url, browser_settings, NULL);


The implementation is derived from cefsimple.

I give the possibility to close the embedded browser by calling window.close(); from javascript.

I think I managed well the closing routine (I use this solution in the last 3/4 years), but now I have a situation that cause a crash.
Running a webapp wich use more than one frame (maybe it is not the cause) and after working a little bit, when closing it occurs a crash in this function of window_tree_host.cc
Code: Select all
ui::EventDispatchDetails WindowTreeHost::DispatchKeyEventPostIME(
    ui::KeyEvent* event,
    base::OnceCallback<void(bool)> ack_callback) {
  // If dispatch to IME is already disabled we shouldn't reach here.
  DCHECK(!dispatcher_->should_skip_ime());
  dispatcher_->set_skip_ime(true);
  // We should bypass event rewriters here as they've been tried before.
  ui::EventDispatchDetails dispatch_details =
      event_sink()->OnEventFromSource(event);
  if (!dispatch_details.dispatcher_destroyed)
    dispatcher_->set_skip_ime(false);
  CallDispatchKeyEventPostIMEAck(event, std::move(ack_callback));
  return dispatch_details;
}

in the specific DCHECK.

In the running javascript, the window.close is mapped on a particular keyevent.

I call CefBrowserHost::CloseBrowser(), I manage DoClose(), then I call CefShutdown and manage OnBeforeClose() where I free my reference on CefBrowser.
During OnBeforeClose() I can se 2 active frames for the browser: sometimes I can see 2 call of CefRenderProcessHandler::OnContextReleased() and someteimes I see only a single call.
Everytime two OnContextReleased() occurs, the crash happens.
Before crashing, it also appens that a GPU process starts and immediately ends.
I do not know if things are related, but it is the only evidences I've found between the two situations (the crash and the correct close).

I hope I've give all information needed.
Can anyone help me finding what I do wrong?
ldamis
Techie
 
Posts: 33
Joined: Fri Jan 19, 2018 3:36 am

Re: Crash occurring during CefShutdown

Postby magreenblatt » Wed Jul 29, 2020 9:56 am

Does adding the --disable-site-isolation-trials command-line flag help to avoid the crash? Does it crash if you use a Release build of libcef?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Crash occurring during CefShutdown

Postby ldamis » Wed Jul 29, 2020 10:23 am

Thank you for answer.

magreenblatt wrote:Does adding the --disable-site-isolation-trials command-line flag help to avoid the crash? Does it crash if you use a Release build of libcef?


Crash happens with Debug and Release build and adding that particular flag does not avoid malfunction.
In function mentioned above (ui::EventDispatchDetails WindowTreeHost::DispatchKeyEventPostIME), error occurs in
Code: Select all
dispatcher_->set_skip_ime(true);

The dispatcher is empty.
ldamis
Techie
 
Posts: 33
Joined: Fri Jan 19, 2018 3:36 am

Re: Crash occurring during CefShutdown

Postby magreenblatt » Wed Jul 29, 2020 10:47 am

What is the full symbolized call stack for the crash?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Crash occurring during CefShutdown

Postby ldamis » Thu Jul 30, 2020 1:58 am

Release and Debug call stack

Code: Select all
    libcef.dll!aura::WindowTreeHost::DispatchKeyEventPostIME(ui::KeyEvent * event, base::OnceCallback<void (bool)> ack_callback) Line 271   C++
    libcef.dll!ui::InputMethodBase::DispatchKeyEventPostIME(ui::KeyEvent * event, base::OnceCallback<void (bool)> ack_callback) Line 168   C++
    libcef.dll!ui::InputMethodWinBase::ProcessUnhandledKeyEvent(ui::KeyEvent * event, const std::vector<tagMSG,std::allocator<tagMSG> > * char_msgs) Line 504   C++
    libcef.dll!ui::InputMethodWinBase::DispatchKeyEvent(ui::KeyEvent * event) Line 260   C++
    libcef.dll!aura::WindowEventDispatcher::PreDispatchKeyEvent(ui::KeyEvent * event) Line 1109   C++
    libcef.dll!aura::WindowEventDispatcher::PreDispatchEvent(ui::EventTarget * target, ui::Event * event) Line 618   C++
    libcef.dll!ui::EventDispatcherDelegate::DispatchEvent(ui::EventTarget * target, ui::Event * event) Line 55   C++
    libcef.dll!ui::EventProcessor::OnEventFromSource(ui::Event * event) Line 21   C++
    libcef.dll!ui::EventSource::DeliverEventToSink(ui::Event * event) Line 50   C++
    libcef.dll!ui::EventSource::SendEventToSinkFromRewriter(ui::Event * event, const ui::EventRewriter * rewriter) Line 93   C++
    libcef.dll!ui::EventSource::SendEventToSink(ui::Event * event) Line 43   C++
    libcef.dll!views::DesktopWindowTreeHostWin::HandleKeyEvent(ui::KeyEvent * event) Line 923   C++
    libcef.dll!views::HWNDMessageHandler::OnKeyEvent(unsigned int message, unsigned int w_param, long l_param) Line 1835   C++
    libcef.dll!views::HWNDMessageHandler::_ProcessWindowMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, long & lResult, unsigned long dwMsgMapID) Line 0   C++
    libcef.dll!views::HWNDMessageHandler::OnWndProc(unsigned int message, unsigned int w_param, long l_param) Line 978   C++
    libcef.dll!gfx::WindowImpl::WndProc(HWND__ * hwnd, unsigned int message, unsigned int w_param, long l_param) Line 303   C++
    libcef.dll!base::win::WrappedWindowProc<&gfx::WindowImpl::WndProc>(HWND__ * hwnd, unsigned int message, unsigned int wparam, long lparam) Line 79   C++
    [External Code]   
    [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]   
    libcef.dll!base::MessagePumpForUI::ProcessMessageHelper(const tagMSG & msg) Line 381   C++


Code: Select all
    libcef.dll!aura::WindowTreeHost::DispatchKeyEventPostIME(ui::KeyEvent * event, base::OnceCallback<void (bool)> ack_callback) Line 270   C++
    libcef.dll!ui::InputMethodBase::DispatchKeyEventPostIME(ui::KeyEvent * event, base::OnceCallback<void (bool)> ack_callback) Line 168   C++
    libcef.dll!ui::InputMethodWinBase::ProcessUnhandledKeyEvent(ui::KeyEvent * event, const std::vector<tagMSG,std::allocator<tagMSG> > * char_msgs) Line 504   C++
    libcef.dll!ui::InputMethodWinBase::DispatchKeyEvent(ui::KeyEvent * event) Line 260   C++
    libcef.dll!aura::WindowEventDispatcher::PreDispatchKeyEvent(ui::KeyEvent * event) Line 1109   C++
    libcef.dll!aura::WindowEventDispatcher::PreDispatchEvent(ui::EventTarget * target, ui::Event * event) Line 618   C++
    libcef.dll!ui::EventDispatcherDelegate::DispatchEvent(ui::EventTarget * target, ui::Event * event) Line 55   C++
    libcef.dll!ui::EventProcessor::OnEventFromSource(ui::Event * event) Line 21   C++
    libcef.dll!ui::EventSource::DeliverEventToSink(ui::Event * event) Line 50   C++
    libcef.dll!ui::EventSource::SendEventToSinkFromRewriter(ui::Event * event, const ui::EventRewriter * rewriter) Line 93   C++
    libcef.dll!ui::EventSource::SendEventToSink(ui::Event * event) Line 43   C++
    libcef.dll!views::DesktopWindowTreeHostWin::HandleKeyEvent(ui::KeyEvent * event) Line 923   C++
    libcef.dll!views::HWNDMessageHandler::OnKeyEvent(unsigned int message, unsigned int w_param, long l_param) Line 1835   C++
    libcef.dll!views::HWNDMessageHandler::_ProcessWindowMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, long & lResult, unsigned long dwMsgMapID) Line 0   C++
    libcef.dll!views::HWNDMessageHandler::OnWndProc(unsigned int message, unsigned int w_param, long l_param) Line 978   C++
    libcef.dll!gfx::WindowImpl::WndProc(HWND__ * hwnd, unsigned int message, unsigned int w_param, long l_param) Line 303   C++
    libcef.dll!base::win::WrappedWindowProc<&gfx::WindowImpl::WndProc>(HWND__ * hwnd, unsigned int message, unsigned int wparam, long lparam) Line 79   C++
    [External Code]   
    [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]   
    libcef.dll!free(void * ptr) Line 57   C++
ldamis
Techie
 
Posts: 33
Joined: Fri Jan 19, 2018 3:36 am

Re: Crash occurring during CefShutdown

Postby ldamis » Mon Aug 03, 2020 4:41 am

Any suggestions? :?:
ldamis
Techie
 
Posts: 33
Joined: Fri Jan 19, 2018 3:36 am

Re: Crash occurring during CefShutdown

Postby Czarek » Mon Aug 03, 2020 4:47 am

Have you tried latest CEF version?
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Crash occurring during CefShutdown

Postby ldamis » Mon Aug 03, 2020 6:07 am

Czarek wrote:Have you tried latest CEF version?


Not yet, but I think it's time to try it...
ldamis
Techie
 
Posts: 33
Joined: Fri Jan 19, 2018 3:36 am

Re: Crash occurring during CefShutdown

Postby shdj111 » Tue Feb 22, 2022 10:56 pm

Have you solved it?
shdj111
Newbie
 
Posts: 7
Joined: Thu Aug 13, 2020 2:58 am


Return to Support Forum

Who is online

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