Hi,
I'm on Windows embedding CEF3 into an MFC application. I'm trying to understand what happens with the setting 'multi_threaded_message_loop' is set to true. We've been using CEF for a while like this without problems - until now.
When the user hits F1 in a CEF window, we want to display a dialog showing help. This is where problems start. For a regular MFC window there are no problems, the dialog displays and everything works as expected. When the user hits F1 from an CEF window (in this case embedded in an MFC framewnd), the dialog displays fine, but I can no longer interact with it; the application just hangs and nothing responds.
The call stacks are slightly different.
For the MFC window, the response to the F1 key occurs during the PumpMessage phase:
... large call stack ...
mfc140d.dll!AfxInternalPumpMessage() Line 181 C++ Symbols loaded.
mfc140d.dll!CWinThread::PumpMessage() Line 900 C++ Symbols loaded.
mfc140d.dll!CWinThread::Run() Line 629 C++ Symbols loaded.
mfc140d.dll!CWinApp::Run() Line 787 C++ Symbols loaded.
mfc140d.dll!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 47 C++ Symbols loaded.
MyApp.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 26 C++ Symbols loaded.
For the CEF embedded window, it gets trapped in the PeekMessage phase:
... large call stack ...
ntdll.dll!_KiUserCallbackDispatcher@12() Unknown Symbols loaded.
user32.dll!PeekMessageA() Unknown Symbols loaded.
mfc140d.dll!CWinThread::Run() Line 617 C++ Symbols loaded.
mfc140d.dll!CWinApp::Run() Line 787 C++ Symbols loaded.
mfc140d.dll!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 47 C++ Symbols loaded.
MyApp.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 26 C++ Symbols loaded.
So my question is does anyone know why? If I set 'multi_threaded_message_loop' to false and add implement CefDoMessageLoopWork in PumpMessage, then it works the same as the regular MFC application, but setting this flag to false is not recommended and I certainly see performance issues in doing so (for example, redrawing during a resize no longer works). I'm curious as to why PeekMessage should result in my window receiving the F1 key directly.
If anyone could shed any light on this, greatly appreciated.
Regards
Nick