gtk4: Asynchronously flush frames from GDK

There is no need to wait until the frames are flushed as the textures
will be kept alive until GDK is finished with them, and doing so can
cause deadlocks.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/287

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1052>
This commit is contained in:
Sebastian Dröge 2023-01-19 13:53:21 +02:00
parent b161f56a5c
commit 03df4f253c

View file

@ -236,8 +236,10 @@ impl ElementImpl for PaintableSink {
let _ = self.info.lock().unwrap().take();
let _ = self.pending_frame.lock().unwrap().take();
// Flush frames from the GDK paintable but don't wait
// for this to finish as this can other deadlock.
let self_ = self.to_owned();
utils::invoke_on_main_thread(move || {
glib::MainContext::default().invoke(move || {
let paintable = self_.paintable.lock().unwrap();
if let Some(paintable) = &*paintable {
paintable.get_ref().handle_flush_frames();