We have integrated CEF into a Qt application. We are calling CefDoMessageLoopWork() periodically from the main Qt thread.
The issue is that when a user copy/paste content from the CEF window to the Qt window the whole UI freezes fro several seconds and nothing is pasted.
Copy/past works flawlessly when pasting to another application.
After digging into it it seems that the issues is caused by the way Qt and CEF handle the clipboard:
- Qt request XCB for clipboard content and wait
- CEF receives the XCB request and is supposed to send the content
- Qt receives the content
However, here since Qt is waiting, we do not call CefDoMessageLoopWork() and CEF cannot send the content. So everything freezes until Qt times out and stops waiting.
I was able to make it work by accessing Qt clipboard from another thread (thus insuring that CefDoMessageLoopWork() is called). However this is not a viable solution as it cannot be used for all Qt built in clipboard handling.
As we are on Linux we cannot use multi_threaded_message_loop so it seems the only solutions are:
- Reimplements all Qt clipboard handling and do the heavy work in another thread
- Move all our CEF code into another thread and call CefDoMessageLoopWork() from this thread, meaning we have to do inter thread communication between CEF and our Qt code
Both of them means a lot of work. Is there an easier solution that I missed? I would have expected the clipboard communication to happen on another thread (like the IO thread or the renderer thread).