After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 764148 - gtkglsink doesn't fail to create on incompatible hardware
gtkglsink doesn't fail to create on incompatible hardware
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
unspecified
Other Linux
: Normal normal
: 1.8.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-03-24 14:40 UTC by Russel Winder
Modified: 2016-03-25 09:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Russel Winder 2016-03-24 14:40:51 UTC
In Me TV, there is code to try and create a gtkglsink, but to use a gtksink if it fails. On a Lenovo X1 Carbon, it all works fine. It also works fine on a Dell Precision T5400 with an NVIDIA GT610 card (using NVIDIA driver uses gtkglsink, with Nouveau there is a special escape so the gtksink is used). 

https://github.com/Me-TV/Me-TV

On a Lenovo X201 or T500 things do not work. A gtkglsink gets created then on use, the following occurs. The bug here is, for me, that the gtkglsink should never have been created on this platform that cannot support the level of OpenGL that is expected.

** (me-tv:18824): DEBUG: Application initialized.
(me-tv:18824): Gtk-DEBUG: Connecting to session manager
** (me-tv:18824): DEBUG: Session idle inhibited.
** (me-tv:18824): DEBUG: Frontend appeared adapter0, frontend0.
** (me-tv:18824): DEBUG: FrontendWindow constructed
** (me-tv:18824): DEBUG: GStreamerEngine being constructed.
** (me-tv:18824): DEBUG: Delivering a gtkglsink.
** (me-tv:18824): DEBUG: GStreamerEngine constructed.
** (me-tv:18824): DEBUG: GStreamer set volume: 0.200000
** (me-tv:18824): DEBUG: FrontendWindow construction completed: adapter0, frontend0, engine gstreamer
** (me-tv:18824): DEBUG: Created a FrontendWindow for adapter0, frontend0
** (me-tv:18824): DEBUG: Shown FrontendWindow for adapter0, frontend0
** (me-tv:18824): DEBUG: GStreamerEngine set mrl to dvb://BBC R5L
0:00:00.113946937 18824      0x2676260 WARN                 playbin gstplaybin2.c:1652:gst_playbin_uri_is_valid:<playbin0> uri 'dvb://BBC R5L' not valid, character #9
** (me-tv:18824): DEBUG: GStreamerEngine set playing.
0:00:00.114141307 18824      0x2676260 ERROR         gtkgstglwidget gtkgstglwidget.c:430:_get_gl_context:<GtkGstGLWidget@0x2c52330> Error creating GdkGLContext : Unable to create a GL context
**
ERROR:gtkgstglwidget.c:432:_get_gl_context: code should not be reached
Aborted (core dumped)
Comment 1 Sebastian Dröge (slomo) 2016-03-24 18:22:36 UTC
It should error out cleanly, ideally in NULL->READY already. So that the application can check for that and switch to an alternative.
Comment 2 Russel Winder 2016-03-25 05:54:37 UTC
I had assumed that:

GstElement * element = gst_element_factory_make("gtkglsink", nullptr);

would return NULL if the platform was inconsistent with GStreamer requirements. It seems that non-NULL is returned if there is any OpenGL capability even if it is not consistent with requirements.
Comment 3 Matthew Waters (ystreet00) 2016-03-25 06:10:07 UTC
Correct, creating the element doesn't attempt to create a GL context (in either Gtk or GStreamer) until the NULL->READY transition.
Comment 4 Russel Winder 2016-03-25 06:53:53 UTC
Given the GStreamer architecture, that makes sense. (Sorry I had to be hit over the head with this point twice before it sank in.)

That leads to the questions:

Is it possible to query the platform and GStreamer to see if the OpenGL version the former provides and the latter requires are harmonious prior to making the choice of whether to create a gtkglsink or a gtksink?

If a gtkglsink element has been created, is there a message on the bus prior to instantiating the GL context?

Is it feasible to replace the gtkglsink with a gtksink and continue if the GL context creation fails?
Comment 5 Matthew Waters (ystreet00) 2016-03-25 06:54:56 UTC
commit cfbe7d1399f73345ce430739d4f2cfa82824ef53
Author: Matthew Waters <matthew@centricular.com>
Date:   Fri Mar 25 17:49:14 2016 +1100

    gtk/gl: don't assert when gdk doesn't provide a GL context
    
    Allows the application to check whether gtkglsink is supported by setting
    the element to READY.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764148

and 1.8 719270aaa40e91b877acf1cd9c6e2941c86be07c
Comment 6 Matthew Waters (ystreet00) 2016-03-25 06:59:55 UTC
(In reply to Russel Winder from comment #4)
> Given the GStreamer architecture, that makes sense. (Sorry I had to be hit
> over the head with this point twice before it sank in.)
> 
> That leads to the questions:
> 
> Is it possible to query the platform and GStreamer to see if the OpenGL
> version the former provides and the latter requires are harmonious prior to
> making the choice of whether to create a gtkglsink or a gtksink?

Unfortunately, not really without creating your own GtkGLArea and GstGLContext (like gtkglsink).

> If a gtkglsink element has been created, is there a message on the bus prior
> to instantiating the GL context?

No.

> Is it feasible to replace the gtkglsink with a gtksink and continue if the
> GL context creation fails?

Generally what you do is create gtkglsink (or any element) and set it to READY for some basic sanity checking that it's supported before adding it to the pipeline.  If any of that fails you fall back to something else like gtksink or autovideosink or ...

The mechanism described above is precisely how playsink and autovideosink select their video sinks so it's standard practice.
Comment 7 Russel Winder 2016-03-25 07:40:09 UTC
Just because it has always been done like that, doesn't mean that is the way it should be done!

I had been following Sebastian's GstPlayer code for gtkglsink and gtksink creation, maybe I should raid more of that codebase :-)
Comment 8 Sebastian Dröge (slomo) 2016-03-25 08:27:06 UTC
The GstPlayer GTK application does not check for this yet, it assumes that GTK's GL support always works if it is compiled in currently.
Comment 9 Russel Winder 2016-03-25 09:03:59 UTC
I think I'll just put in a manual command line "hack" for Me TV to work around this for now. Seems easier. :-)

Good to see Debian already upgraded GStreamer to 1.8.