From 31cb8500ee410b723620eb4edc5301b1c96c4292 Mon Sep 17 00:00:00 2001 From: Roman Shpuntov Date: Wed, 20 Mar 2019 18:44:12 +0700 Subject: [PATCH] macOS gst-plugins-base/gl/cocoa: UI API called on a background thread: -[NSView removeFromSuperview] The problem inside gstglwindow_cocoa.m, all UI operations must be called from main UI thread. https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/568 Fixes #568 --- gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m index 996c2ea466..203204caf5 100644 --- a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m +++ b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m @@ -240,16 +240,24 @@ gst_gl_window_cocoa_open (GstGLWindow *window, GError **err) } static void -gst_gl_window_cocoa_close (GstGLWindow *window) +_close_window (gpointer * data) { - GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window); - GstGLNSWindow *internal_win_id = (__bridge GstGLNSWindow *)window_cocoa->priv->internal_win_id; + GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (data); + GstGLNSWindow *internal_win_id = + (__bridge GstGLNSWindow *) window_cocoa->priv->internal_win_id; [[internal_win_id contentView] removeFromSuperview]; - CFBridgingRelease(window_cocoa->priv->internal_win_id); + CFBridgingRelease (window_cocoa->priv->internal_win_id); window_cocoa->priv->internal_win_id = NULL; } +static void +gst_gl_window_cocoa_close (GstGLWindow * window) +{ + _invoke_on_main ((GstGLWindowCB) _close_window, gst_object_ref (window), + (GDestroyNotify) gst_object_unref); +} + static guintptr gst_gl_window_cocoa_get_window_handle (GstGLWindow *window) {