Trying to fix broken ( for > 4 years) cocoa implementation of glimagesink on macOS

the macOS glimagesink implementation is broken in that when it is not given a video window context (so it creates one itself), the window does not close when the EOS is sent and the pipeline GST_STATE is set to NULL. Furthermore, the black empty gl window that remains unclosed causes a segfault if it is closed by clicking its close button.

  • This error has been around unfixed for at least 4 years. Other people gave up, and used workarounds (unfortunately osxvideosink has a similar problem). I think it is time to fix this, and will put some effort into it, but would like some guidance.

Here are some of the the older reports

The issue can’t be demonstrated with gst-launch-1.0 because that de-initializes gstreamer when eos arrives, but I will eventually write a small demo, with a main_loop and bus messages, that remains open after eos, and then reopen as a Issue. EDIT: the earliest of the above reports has a demo:

https://gitlab.freedesktop.org/-/project/1352/uploads/ff39d4c1209ad7e130a5940cdbd50848/main.c

For our use case, it’s not practical to supply a window handle rather than let glimagesink create one itself because the macOS version of our app is a build of something that builds on linux/windows/*BSD/macOS and can use all the different gstreamer videosinks, so relies on automatic window creation, and destruction, without closing the app before creating a new window.

Right now the initial exploration is comparing GST_DEBUG=5 output differences of glimagesink between linux (working correctly) and macOS versions, and adding lots of printf statements in things like

  • question for experts ( maybe @ystreet00 ): where exactly is the last place in GStreamer where the window-closing command gets (should get) sent to the macOS window manager if everything had been properly unreffed/destroyed ? (including the context) is it in:
    gst_gl_context_cocoa_destroy_context (GstGLContext *context) ?

If this issue is something not being fully unref’d I could add refcount checks, but I am guessing it is a context left behind. somewhere? I’m assuming this is something fixable in gstreamer code?

This issue is best discussed on gitlab in any of the relevant issues you have mentioned.

These are all a single unresolved issue, and date from before the monorepo. So I presume it needs a new issue opened citing them. Unfortunately, nothing useful came from these earlier postings (at least for macOS cocoa, I see that there were fixes on other platforms).
Maybe some guidance on where to look for the bug might result this time.

Issues can be moved to the monorepo if needed. (Have done so now.)

If they’re the same issue we can mark one as a dup of the other and continue discussion in whichever issue has the most useful info.