GNOME Bugzilla – Bug 752379
gl: deadlock when destroying GstGLContext from within a windows event callback
Last modified: 2016-09-29 13:29:43 UTC
I'm writing an application on windows, it uses glimagesink inside a WinForm. That window has a stop button, when clicked I set pipeline to NULL state. Doing that means that from within a window event callback, the GstGLContext is finalized and blocks until the glcontext thread returns. This leads to DestroyWindow() call to destroy the internal window on which glimagesink is drawing video frames. That DestroyWindow() call never returns, because the thread handling window event is still blocked in gst_gl_context_finalize(). To workaround this issue, I had to spawn a new thread in the callback of the stop button, and set pipeline to NULL in that thread instead. I don't know what would be a proper fix.
There isn't really much one can do in this situation. While all our function/thread handling is entirely reentrant that doesn't mean that the winsys specific code is especially when dealing with operations requiring a round trip through the window's message loop. This will also result in different behaviour when the extra GL thread is moved out of glwindow/glcontext.
I quickly checked the d3dvideosink code and it seems the window there creates its own thread to handle messages. I'm wondering if it's suffering from the same bug or not, will test. It seems pretty obvious for a stop button to set pipeline to NULL, that's the most common use-case, so we should try harder to make it work. Everybody is going to fall in that trap otherwise, IMO. Note that I'm far from a win32 expert, so it's possible my analysis of the problem is wrong. All I know is that my app (sadly proprietary, I'll try to make simple test case) hang in DestroyWindow when I set pipeline to NULL in the mouse click callback.
This may be fixed by bug 766533.
It's a dup indeed, the other bug has a workaround that got merged. I'm still unsure it's the proper fix though... *** This bug has been marked as a duplicate of bug 766533 ***