GNOME Bugzilla – Bug 745633
glimagesink: X11: Race where it creates an external window even if the XID was set
Last modified: 2015-03-11 18:57:23 UTC
Created attachment 298569 [details] GST_DEBUG=*gl*:7 debug logs In pitivi we do the following: Set XID and then pause the pipeline. Usually the sink get embedded properly but in some cases I observe the following: T0: the XiD is set, gst_glimage_sink_set_window_handle is called, new_window_xid is set T1: Caps negotiation happens -> We create the context -> The GL thread is started T2(glthread): The XWindow is created as part of the creation of the GL thread (in what is called context->choose_format). At that point the XID is not actually set on the GstGLX11Window. T1: gst_gl_window_set_window_handle is called, still in the process of creating the negotitation in the _ensure_gl_setup function. T1: In gst_gl_window_x11_set_window_handle we see that the GL mainloop is not running yet (as T2 it is between the call to ->choose_format vmethod and gst_gl_window_run). In that method there is a comment stating: /* The loop may not exist yet because it's created in GstGLWindow::open * which is only called when going from READY to PAUSED state. * If no loop then the parent is directly set in CreateWindow */ but in our case the loop is not running yet but we already have the XWindow created with an internal XID. So we end up never setting the proper Xid to the XWindow and thuse we get an external window poping up.
commit bc7a7259f357b0065dd94e0668b5a895d83fa53a Author: Matthew Waters <matthew@centricular.com> Date: Fri Mar 6 15:31:18 2015 +1100 gl/window: create the main loop/context on init/finalize Avoids races setting the window handle from the main thread. https://bugzilla.gnome.org/show_bug.cgi?id=745633
I just tested that and since that patch I am getting the following deadlocks: When starting: (gdb) t a a bt
+ Trace 234832
Thread 1 (Thread 0x7fb442fed700 (LWP 28234))
And if I remove the calls to expose, I get the following when tearing down the pipeline I am getting the stack I attach here (getting an error from bz because my message is too long...) You can easily reproduce using my gtktimeline branch from https://github.com/thiblahute/pitivi/commits/gtktimeline and running: ./tests/validate-tests/runtests -f -l stdout -d Given you have gst-validate setup.
Created attachment 299117 [details] stacktrace on tear down
commit 49b00e44edcf91acfdfd019579b0d3664aa7d959 Author: Matthew Waters <matthew@centricular.com> Date: Wed Mar 11 18:49:22 2015 +0000 gl/x11: don't XGetWindowAttributes every XEvent fixes a deadlock in xcb where the X window may not exist. https://bugzilla.gnome.org/show_bug.cgi?id=745633