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 793224 - gl: context persistence issue
gl: context persistence issue
Status: RESOLVED DUPLICATE of bug 757933
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-02-06 17:06 UTC by Philippe Normand
Modified: 2018-02-09 08:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
bzip2 log file (904.58 KB, application/x-bzip)
2018-02-07 09:25 UTC, Philippe Normand
Details

Description Philippe Normand 2018-02-06 17:06:29 UTC
I have an issue where my custom playbin video sink (glupload ! glcolorconvert ! appsink) loses its context when the video chain is removed from playsink while the whole pipeline goes to READY.

So rendering works fine on first run, the app handles the need-context message fine. On second run the gl elements try a context query, that fails. Then they try to post a need-context message but they have no bus associated yet, so that fails. Then a new display is created from gst_gl_ensure_element_data() and it's for the wrong platform (egl vs wayland).

But even with all those failures, somehow rendering works if the pipeline goes to PLAYING again.

On third run rendering fails.

As a workaround I can manually set the context on the video sink before going to PAUSED on second and following runs but shouldn't the gl context be automatically reused from the persistent element context?
Comment 1 Matthew Waters (ystreet00) 2018-02-07 03:07:19 UTC
(In reply to Philippe Normand from comment #0)
> I have an issue where my custom playbin video sink (glupload !
> glcolorconvert ! appsink) loses its context when the video chain is removed
> from playsink while the whole pipeline goes to READY.
> 
> So rendering works fine on first run, the app handles the need-context
> message fine. On second run the gl elements try a context query, that fails.
> Then they try to post a need-context message but they have no bus associated
> yet, so that fails. Then a new display is created from
> gst_gl_ensure_element_data() and it's for the wrong platform (egl vs
> wayland).

wayland only works with egl. Do you mean glx vs egl or x11 vs wayland ?

There's also an issue of terminology. When you say GL context, do you mean the GStreamer GL context created internally or an application provided GL context (they are not the same thing).

I think the key thing here is that 'there is not bus associated yet' which sounds problematic.  Is the lack of a bus a playsink/playbin or an application issue.

> But even with all those failures, somehow rendering works if the pipeline
> goes to PLAYING again.

'somehow'?

> On third run rendering fails.

How exactly?

> As a workaround I can manually set the context on the video sink before
> going to PAUSED on second and following runs but shouldn't the gl context be
> automatically reused from the persistent element context?

The GL context is not a persistent resource so will be destroyed and recreated on pipeline shutdown/restart which is also true if playsink sets the video sink to NULL.  GstContext's are also removed from elements when set they are set to NULL (or READY). I can't remember which.

I think in order to debug this in any sort of capacity, some logs are needed. e.g. GST_DEBUG=3,gl*:7,*CONTEXT*:7
Comment 2 Philippe Normand 2018-02-07 09:25:25 UTC
(In reply to Matthew Waters (ystreet00) from comment #1)
> (In reply to Philippe Normand from comment #0)
> > I have an issue where my custom playbin video sink (glupload !
> > glcolorconvert ! appsink) loses its context when the video chain is removed
> > from playsink while the whole pipeline goes to READY.
> > 
> > So rendering works fine on first run, the app handles the need-context
> > message fine. On second run the gl elements try a context query, that fails.
> > Then they try to post a need-context message but they have no bus associated
> > yet, so that fails. Then a new display is created from
> > gst_gl_ensure_element_data() and it's for the wrong platform (egl vs
> > wayland).
> 
> wayland only works with egl. Do you mean glx vs egl or x11 vs wayland ?
> 

The latter

> There's also an issue of terminology. When you say GL context, do you mean
> the GStreamer GL context created internally or an application provided GL
> context (they are not the same thing).
> 

The application provided GL context

> I think the key thing here is that 'there is not bus associated yet' which
> sounds problematic.  Is the lack of a bus a playsink/playbin or an
> application issue.
> 

I don't think it's an application issue ;) Upon EOS I sent the playbin state to READY and to PLAYING again.

> > But even with all those failures, somehow rendering works if the pipeline
> > goes to PLAYING again.
> 
> 'somehow'?
> 

It's strange because the GL app context remains valid for two runs and not more, I don't have an explanation for this yet.

> > On third run rendering fails.
> 
> How exactly?
> 

I can see a scrambled frame for half a second and then the rendering area goes black although the pipeline runs until EOS.

> > As a workaround I can manually set the context on the video sink before
> > going to PAUSED on second and following runs but shouldn't the gl context be
> > automatically reused from the persistent element context?
> 
> The GL context is not a persistent resource so will be destroyed and
> recreated on pipeline shutdown/restart which is also true if playsink sets
> the video sink to NULL. 

Ok so the GL app context should be requested again at restart then?

> GstContext's are also removed from elements when
> set they are set to NULL (or READY). I can't remember which.
> 

Non-persitent GstContexts are removed when the element goes to NULL.

> I think in order to debug this in any sort of capacity, some logs are
> needed. e.g. GST_DEBUG=3,gl*:7,*CONTEXT*:7

Ok I'm attaching a log file, the video played is 6 seconds long and 3 playback attempts are made.
Comment 3 Philippe Normand 2018-02-07 09:25:55 UTC
Created attachment 367978 [details]
bzip2 log file
Comment 4 Philippe Normand 2018-02-07 17:23:07 UTC
With va-api enabled the second run has scrambled rendering, I can upload a screencast if needed.
Comment 5 Matthew Waters (ystreet00) 2018-02-09 01:36:37 UTC
This sounds like a dupe of bug 757933
Comment 6 Philippe Normand 2018-02-09 08:59:34 UTC

*** This bug has been marked as a duplicate of bug 757933 ***