Exit hang - libcef.dll!base::MessagePumpForUI::WaitForWork()

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.

Exit hang - libcef.dll!base::MessagePumpForUI::WaitForWork()

Postby HarmlessDave » Wed Apr 26, 2017 2:21 pm

I'm getting a hang on exit, but only in certain cases. Unfortunately the cases involve private websites and a set of pages that would be hard to set up elsewhere.

This is CEF 3.2924.1575.g97389a9 and Windows 32-bit, with CEF's browser hosted inside a parent mainframe. settings.multi_threaded_message_loop = true and the main message loop is a stock loop in _tWinMain not a CEF object.

Normal behavior
Code: Select all
18:42:42.563 - Calling CloseAllBrowsers
18:42:42.566 - Pump messages
18:42:42.568 - ClientHandler::DoClose id=1
18:42:42.573 - ClientHandler::OnBeforeClose - browser count 0
18:42:42.642 - Destroying mainframe
18:42:42.646 - WM_DESTROY = 3016120  -- mainframe, does PostQuitMessage(0);
18:42:42.651 - Ending process, CefShutdown()
18:42:42.663 - Ending process, CefShutdown() complete
18:42:42.668 - ExitInstance
18:42:42.672 - ExitInstance complete


Hang behavior
Code: Select all
10:39:36.583 - Calling CloseAllBrowsers
10:39:36.586 - Pump messages
10:39:36.592 - ClientHandler::DoClose id=2
10:39:36.628 - ClientHandler::DoClose id=1
10:39:36.633 - ClientHandler::OnBeforeClose - browser count 0
10:39:36.728 - Destroying mainframe
10:39:36.736 - WM_DESTROY = 329490  -- mainframe, does PostQuitMessage(0);
 ** does not continue on to _tWinMain  code, does not call CefShutdown() **

    [External Code]   
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]   
>   libcef.dll!base::MessagePumpForUI::WaitForWork() Line 212   C++
    libcef.dll!base::MessagePumpForUI::DoRunLoop() Line 199   C++
    libcef.dll!base::MessagePumpWin::Run(base::MessagePump::Delegate * delegate) Line 58   C++
    libcef.dll!base::MessageLoop::RunHandler() Line 376   C++
    libcef.dll!base::RunLoop::Run() Line 36   C++
    libcef.dll!base::Thread::Run(base::RunLoop * run_loop) Line 246   C++
    libcef.dll!content::BrowserThreadImpl::FileThreadRun(base::RunLoop * run_loop) Line 228   C++
    libcef.dll!content::BrowserThreadImpl::Run(base::RunLoop * run_loop) Line 280   C++
    libcef.dll!base::Thread::ThreadMain() Line 336   C++
    libcef.dll!base::`anonymous namespace'::ThreadFunc(void * params) Line 86   C++
    [External Code]   


WaitForWork() is sitting with delay = INFINITE; and wait_flags = MWMO_INPUTAVAILABLE; at the MsgWaitForMultipleObjectsEx() call.

I'm guessing I could fix that if I could figure out how to send it a WM_QUIT to this specific handler, but normally that is not needed.

To make things harder, our code doesn't match the current CefClient sample since it was written based on CEF 2272 and only updated as needed for changed -Handler event signatures.

Any suggestions are welcome.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Exit hang - libcef.dll!base::MessagePumpForUI::WaitForWo

Postby ArtMore » Sat Apr 29, 2017 12:09 am

HarmlessDavve wrote:I have not found a fix yet. In a debug build I can see the stuck queue belongs to the Chrome_FileThread thread, but threads only have names inside Visual Studio so I can't try a hack like finding and terminating that thread.

I might need to launch a helper EXE on exit that kills the zombie CEF processes.


I'm getting this error too now Dave. Are you?
Last edited by ArtMore on Thu Sep 03, 2020 6:36 am, edited 6 times in total.
ArtMore
Newbie
 
Posts: 1
Joined: Wed Apr 26, 2017 5:05 am

Re: Exit hang - libcef.dll!base::MessagePumpForUI::WaitForWo

Postby HarmlessDave » Mon May 01, 2017 7:22 pm

I have not found a fix yet. In a debug build I can see the stuck queue belongs to the Chrome_FileThread thread, but threads only have names inside Visual Studio so I can't try a hack like finding and terminating that thread.

I might need to launch a helper EXE on exit that kills the zombie CEF processes.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Exit hang - libcef.dll!base::MessagePumpForUI::WaitForWo

Postby HarmlessDave » Tue May 02, 2017 1:13 pm

Waiting and pumping the message queue for 4 seconds each before and after CloseAllBrowsers doesn't seem to make a difference.
Code: Select all
 11:03:04.819 - ExitInstance_Part1 complete
11:03:04.819 - Calling PumpMessagesSleep
11:03:05.868 - Calling PumpMessagesSleep - 2
11:03:06.868 - Calling PumpMessagesSleep - 3
11:03:07.868 - Calling PumpMessagesSleep - 4
11:03:08.868 - Calling CloseAllBrowsers
11:03:08.868 - Calling PumpMessagesSleep - 5
11:03:08.875 - ClientHandler::DoClose id=2
11:03:08.884 - ClientHandler::DoClose id=1
11:03:08.884 - ClientHandler::OnBeforeClose - Count=0
11:03:09.915 - Calling PumpMessagesSleep - 6
11:03:10.947 - Calling PumpMessagesSleep - 7
11:03:11.963 - Calling PumpMessagesSleep - 8
11:03:12.994 - Pump messages
11:03:13.103 - Destroying mainframe
11:03:13.103 - WM_DESTROY = 918936
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Exit hang - libcef.dll!base::MessagePumpForUI::WaitForWo

Postby thomasbryant » Mon Apr 16, 2018 6:57 am

HarmlessDave wrote:I have not found a fix yet. In a debug build I can see the stuck queue belongs to the Chrome_FileThread thread, but threads only have names inside Visual Studio so I can't try a hack like found this crazy bulk and terminating that thread.

I might need to launch a helper EXE on exit that kills the zombie CEF processes.


Please let me know when you find a solution by updating here. Thank you!
thomasbryant
Newbie
 
Posts: 1
Joined: Mon Apr 16, 2018 6:51 am

Re: Exit hang - libcef.dll!base::MessagePumpForUI::WaitForWo

Postby jamesytor » Fri Jun 01, 2018 8:10 pm

ArtMore wrote:
HarmlessDavve wrote:I have not found a fix yet. In a debug build I can see the stuck queue belongs to the Chrome_FileThread thread, but threads only have names inside Visual Studio so I can't try a hack like found this crazy bulk and terminating that thread.

I might need to launch a helper EXE on exit that kills the zombie CEF processes.


I'm getting this error too now Dave. Are you?


No error now, Art.
jamesytor
Newbie
 
Posts: 1
Joined: Fri Jun 01, 2018 8:08 pm


Return to Support Forum

Who is online

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