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 735844 - basetextoverlay/pango: overlay negotiation fails when it should not
basetextoverlay/pango: overlay negotiation fails when it should not
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.4.1
Other All
: Normal normal
: 1.4.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 736177 736748 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-09-01 20:39 UTC by Arnaud Vrac
Modified: 2014-09-18 16:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Log of events in basetextoverlay and the sink that supports overlay (5.29 KB, text/plain)
2014-09-01 20:39 UTC, Arnaud Vrac
  Details
pango: just forward the seek event to sink pads like other events (2.65 KB, patch)
2014-09-02 09:05 UTC, Arnaud Vrac
reviewed Details | Review
basetextoverlay: just forward the seek event to sink pads like other events (2.66 KB, patch)
2014-09-04 13:50 UTC, Arnaud Vrac
committed Details | Review
basetextoverlay: schedule reconfigure on source pad when negotiation fails (1.81 KB, patch)
2014-09-04 13:51 UTC, Arnaud Vrac
committed Details | Review
basetextoverlay: do not ask for a bufferpool when checking for composition meta (893 bytes, patch)
2014-09-04 13:51 UTC, Arnaud Vrac
committed Details | Review
forward video frame when mapping fails instead of dropping it (1.39 KB, patch)
2014-09-04 13:53 UTC, Arnaud Vrac
rejected Details | Review
basetextoverlay: get framerate from previously parsed video info (1.67 KB, patch)
2014-09-04 13:55 UTC, Arnaud Vrac
committed Details | Review
basetextoverlay: Do not fail the negotiation if query fails (1.93 KB, patch)
2014-09-05 16:53 UTC, Thiago Sousa Santos
none Details | Review
basetextoverlay: Do not fail the negotiation if query fails (1.89 KB, patch)
2014-09-09 02:15 UTC, Thiago Sousa Santos
reviewed Details | Review
basetextoverlay: Do not fail the negotiation if query fails (2.55 KB, patch)
2014-09-16 17:54 UTC, Thiago Sousa Santos
committed Details | Review

Description Arnaud Vrac 2014-09-01 20:39:39 UTC
Created attachment 285084 [details]
Log of events in basetextoverlay and the sink that supports overlay

I'm hitting an issue which was not happening in gstreamer 1.2, where the overlay composition negotiation fails. In my pipeline blending subtitles over video frames is not supported, as it is waaay to slow for my system to do that. So in all cases I _must_ be using an overlay. I've updated my sink code to handle overlay negotiation with proper caps features (namely, memory:SystemMemory and meta:GstVideoOverlayComposition).

The issue is that sometimes overlay negotiation fails while seeking. I've attached a log of the relevant events between the textoverlay element and my sink.

The overlay negotiation features is working (in the log: Downstream accepts the overlay meta: 1), but then caps setting fails because the pad is flushing, so the ALLOCATION query is not done. This results in the overlay being disabled. The caps are then never being re-negotiated.

I'm not sure what regressed compared to gstreamer 1.2, it could be either the textoverlay code or a deeper issue related to events and pads.
Comment 1 Thiago Sousa Santos 2014-09-02 02:45:01 UTC
What is the outcome of this?

The downstream and the source pad will be flushing and the negotiation will be re-done before another buffer is pushed as upstream is still going to handle the seek after overlay has handled it.

What is the bug that you are seeing exactly? Does it renegotiate after the seek completes?
Comment 2 Sebastian Dröge (slomo) 2014-09-02 06:36:43 UTC
It does not renegotiate as there's nothing that would make it renegotiate. We will have to check manually after sending the ALLOCATION query if it failed because the pad was flushing (which still is racy as only downstream might be flushing but our srcpad not yet).

There were similar fixes necessary in the video/audio base classes. Best would be to find a generic solution for this, but that would likely require GstFlowReturns for events and queries... which is 2.0 stuff.
Comment 3 Arnaud Vrac 2014-09-02 09:00:17 UTC
@thiagoss: caps setting failed as shown in the log, but renegotiation never happens for some reason.

@slomo: I've also hit the case where caps settings works but then the ALLOCATION query fails. As you said, it cannot work since no renegotation is done. Note that I only hit this case when applying the next attached patch.
Comment 4 Arnaud Vrac 2014-09-02 09:05:16 UTC
Created attachment 285121 [details] [review]
pango: just forward the seek event to sink pads like other events

Remove seek event special handling and just forward the seek event to sink pads, like other events. Flushing is already sent on the source pad when seeking so I don't think this code is necessary. Anybody remembers why this is needed ?
Comment 5 Sebastian Dröge (slomo) 2014-09-02 09:36:52 UTC
Comment on attachment 285121 [details] [review]
pango: just forward the seek event to sink pads like other events

Makes sense to me, no idea what this code was supposed to do. Probably similar changes needed in other subtitle renderers.
Comment 6 Sebastian Dröge (slomo) 2014-09-02 09:38:05 UTC
(In reply to comment #3)

> @slomo: I've also hit the case where caps settings works but then the
> ALLOCATION query fails. As you said, it cannot work since no renegotation is
> done. Note that I only hit this case when applying the next attached patch.

Yes, that's what the video/audio base classes catch both :) I think for fixing this properly we really need GstFlowReturns for events and queries.
Comment 7 Arnaud Vrac 2014-09-02 09:42:30 UTC
@slomo: would that also fix the case where caps setting fails and no renegotation happens ?
Comment 8 Sebastian Dröge (slomo) 2014-09-02 09:45:27 UTC
You would then get GST_FLOW_FLUSHING from the CAPS event and could handle that accordingly
Comment 9 Tim-Philipp Müller 2014-09-02 09:50:18 UTC
But the flush-start event goes through basetextoverlay before it goes downstream of textoverlay, so just set a bool if fully/successfully negotiated, and if not successfully negotiated, try again after a flush-stop ?
Comment 10 Sebastian Dröge (slomo) 2014-09-04 07:50:11 UTC
That should work in this case, yes, but doesn't fix it for the common case.
Comment 11 Arnaud Vrac 2014-09-04 13:50:10 UTC
Created attachment 285375 [details] [review]
basetextoverlay: just forward the seek event to sink pads like other events

Just changes the title of the patch
Comment 12 Arnaud Vrac 2014-09-04 13:51:08 UTC
Created attachment 285376 [details] [review]
basetextoverlay: schedule reconfigure on source pad when negotiation fails

When negotiation fails while flushing, just set the reconfigure flag on the source pad so that negotiation is retried on the next video buffer.
Comment 13 Arnaud Vrac 2014-09-04 13:51:52 UTC
Created attachment 285377 [details] [review]
basetextoverlay: do not ask for a bufferpool when checking for composition meta

We do not need a bufferpool so do not ask for one
Comment 14 Arnaud Vrac 2014-09-04 13:53:53 UTC
Created attachment 285378 [details] [review]
forward video frame when mapping fails instead of dropping it

With this patch at least video is shown when overlay cannot be used and the video frames cannot be mapped.
Comment 15 Arnaud Vrac 2014-09-04 13:55:20 UTC
Created attachment 285379 [details] [review]
basetextoverlay: get framerate from previously parsed video info
Comment 16 Arnaud Vrac 2014-09-04 13:57:08 UTC
The last 3 patches are losely related to this issue, but they do not harm. I think all the patches can be backported to 1.4, in addition to a65b307349 to avoid a conflict.
Comment 17 Sebastian Dröge (slomo) 2014-09-05 08:09:49 UTC
commit f47c2442fe7e3c0235b4c9afd72359627a2df416
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Thu Jan 31 13:49:00 2013 +0100

    basetextoverlay: get framerate from previously parsed video info

commit 267a8c24af4f02ba6f3075bd589d3c5d1dc826e9
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Thu Jan 31 13:47:35 2013 +0100

    basetextoverlay: do not ask for a bufferpool when checking for composition meta

commit 76ce11299411b412702d3fab34b7f152dc211156
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Thu Sep 4 15:06:31 2014 +0200

    basetextoverlay: schedule reconfigure on source pad when negotiation fails
    
    The source pad might be flushing while negotiating, resulting in
    set_caps or the ALLOCATION query failing. In this case set the
    reconfigure flag on the source pad so that negotiation is retried on the
    next buffer.

commit ef5823cc9b0b825a8ca96eab02712d31db57a41d
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Thu Jan 31 15:38:18 2013 +0100

    basetextoverlay: just forward the seek event to sink pads like other events
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735844
Comment 18 Sebastian Dröge (slomo) 2014-09-05 08:10:56 UTC
Comment on attachment 285378 [details] [review]
forward video frame when mapping fails instead of dropping it

This one looks wrong. What are you trying to fix here?

If mapping a frame failed and we can't use the overlay meta, then we'll have to fail. Otherwise textoverlay will silently not do what it is expected to do.
Comment 19 Thiago Sousa Santos 2014-09-05 16:53:14 UTC
Created attachment 285509 [details] [review]
basetextoverlay: Do not fail the negotiation if query fails

One of these fixes introduced a regression when the allocation query isn't
supported. This patch seems to make it work again, but I didn't test the
original racy issue. So please test this and confirm it is still fixed.

The allocation query failure doesn't mean that the negotiation
has failed as the element can allocate buffers itself.

Instead, only fail if the pads are flushing and the allocation
query failed.

https://bugzilla.gnome.org/show_bug.cgi?id=727255
Comment 20 Thiago Sousa Santos 2014-09-05 16:54:18 UTC
The bug number at the end of the commend was wrong, I'll try to remember to remove it before pushing :)
Comment 21 Arnaud Vrac 2014-09-08 08:29:37 UTC
The patch seems wrong, since you do not handle the case where set_caps fails. In this case the caps must be reconfigured too.
Comment 22 Thiago Sousa Santos 2014-09-09 02:15:53 UTC
Created attachment 285697 [details] [review]
basetextoverlay: Do not fail the negotiation if query fails

Update to also set renegotiation when setting caps fail
Comment 23 Thiago Sousa Santos 2014-09-09 19:59:55 UTC
*** Bug 736177 has been marked as a duplicate of this bug. ***
Comment 24 Thiago Sousa Santos 2014-09-11 20:16:49 UTC
Does this new patch help?
Comment 25 Sebastian Dröge (slomo) 2014-09-12 13:24:26 UTC
Comment on attachment 285697 [details] [review]
basetextoverlay: Do not fail the negotiation if query fails

This doesn't catch the case where the allocation query fails because of flushing downstream, right?
Comment 26 Thiago Sousa Santos 2014-09-12 13:36:16 UTC
@@ -780,7 +781,7 @@ gst_base_text_overlay_negotiate (GstBaseTextOverlay * overlay, GstCaps * caps)
     if (!gst_pad_peer_query (overlay->srcpad, query)) {
       /* no problem, we use the query defaults */
       GST_DEBUG_OBJECT (overlay, "ALLOCATION query failed");
-      ret = FALSE;
+      allocation_ret = FALSE;
     }
 
     if (caps_has_meta && gst_query_find_allocation_meta (query,
@@ -792,9 +793,10 @@ gst_base_text_overlay_negotiate (GstBaseTextOverlay * overlay, GstCaps * caps)
 
   overlay->attach_compo_to_buffer = attach;
 
-  if (!ret && overlay->video_flushing) {
+  if ((!ret || !allocation_ret) && overlay->video_flushing) {
     GST_DEBUG_OBJECT (overlay, "negotiation failed, schedule reconfigure");
     gst_pad_mark_reconfigure (overlay->srcpad);
+    ret = FALSE;


It sets allocation_ret to false and then if it failed and video is flushing it will mark for reconfigure and fail the setcaps. Or am I missing something here?
Comment 27 Sebastian Dröge (slomo) 2014-09-12 13:39:53 UTC
Downstream might be flushing already but textoverlay didn't receive the flush event yet
Comment 28 Thiago Sousa Santos 2014-09-12 13:48:56 UTC
Is there a way detect this and still allow elements that accept the meta but fail the allocation query (fakesink)?
Comment 29 Sebastian Dröge (slomo) 2014-09-12 13:53:17 UTC
Well, flow returns for events and queries :)
Comment 30 Thiago Sousa Santos 2014-09-12 15:23:33 UTC
Maybe something else that could be done for 1.x? :)

When it fails the allocation, it should fallback and try to renegotiate the caps without the meta, and then, that will fail. Can't we mark the pad as pending a reconfigure at this moment and return the set caps failure upstream? Or is this also going to cause an issue anyway?
Comment 31 Sebastian Dröge (slomo) 2014-09-16 07:25:33 UTC
Maybe that's the best we can do in 1.x, yes. Can you prepare a patch?
Comment 32 Sebastian Dröge (slomo) 2014-09-16 14:32:53 UTC
*** Bug 736748 has been marked as a duplicate of this bug. ***
Comment 33 Thiago Sousa Santos 2014-09-16 17:54:51 UTC
Created attachment 286319 [details] [review]
basetextoverlay: Do not fail the negotiation if query fails

Updated patch. Arnaud, could you try this one, please?
Comment 34 Thiago Sousa Santos 2014-09-18 16:29:16 UTC
Please reopen if it still fails for you.

master:
commit 3ecb8bea22182bd79e34ede48cb16c78c40a8118
Author: Thiago Santos <thiagoss@osg.samsung.com>
Date:   Fri Sep 5 13:49:46 2014 -0300

    basetextoverlay: Do not fail the negotiation if query fails
    
    The allocation query failure doesn't mean that the negotiation
    has failed as the element can allocate buffers itself.
    
    Instead, only fail if the pads are flushing and the allocation
    query failed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735844


1.4:
commit d6ec4cec8acffaac7c2d417ee67bd111d6f15523
Author: Thiago Santos <thiagoss@osg.samsung.com>
Date:   Fri Sep 5 13:49:46 2014 -0300

    basetextoverlay: Do not fail the negotiation if query fails
    
    The allocation query failure doesn't mean that the negotiation
    has failed as the element can allocate buffers itself.
    
    Instead, only fail if the pads are flushing and the allocation
    query failed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735844

commit 56775ad5bd52fc1ad48bbaf8cac86b17733f6bd6
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Thu Jan 31 13:49:00 2013 +0100

    basetextoverlay: get framerate from previously parsed video info

commit 8e0b8981190a34cdeb1b7ef7ce3882c948ea9c3b
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Thu Jan 31 13:47:35 2013 +0100

    basetextoverlay: do not ask for a bufferpool when checking for composition meta

commit a5acd930a2af49a2f606163e3033ea7b945a79f0
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Thu Sep 4 15:06:31 2014 +0200

    basetextoverlay: schedule reconfigure on source pad when negotiation fails
    
    The source pad might be flushing while negotiating, resulting in
    set_caps or the ALLOCATION query failing. In this case set the
    reconfigure flag on the source pad so that negotiation is retried on the
    next buffer.