Clipboard freezes on Linux

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.

Clipboard freezes on Linux

Postby Benjamin » Mon Nov 04, 2019 6:34 am

I have freezing issues on Linux when using the clipboard.

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).
Last edited by Benjamin on Mon Nov 04, 2019 2:12 pm, edited 1 time in total.
Benjamin
Techie
 
Posts: 10
Joined: Mon Nov 04, 2019 6:05 am

Re: Clipboard freezes on Linux

Postby magreenblatt » Mon Nov 04, 2019 10:50 am

The multi_threaded_message_loop option is supported on Linux as of issue #2512. I have not tested it with Qt so you may run into other issues.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Clipboard freezes on Linux

Postby Benjamin » Tue Nov 05, 2019 4:40 am

I just tested, and it fails because the CEF/Chrome GLib message pump is interfering with Qt event loop and Qt core functions are called from the browser thread which Qt does not like.

At this point the only solution seems to implements kind of what "multi_threaded_message_loop" does, but manually using QThread, OnScheduleMessagePumpWork() and CefDoMessageLoopWork()
Benjamin
Techie
 
Posts: 10
Joined: Mon Nov 04, 2019 6:05 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 49 guests