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 684981 - Pipeline hangs on PREROLLING negotiating caps
Pipeline hangs on PREROLLING negotiating caps
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.0.0
Other Linux
: Normal normal
: 1.0.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 685057
 
 
Reported: 2012-09-27 17:18 UTC by Andre Moreira Magalhaes
Modified: 2012-09-29 13:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do not hang on caps intersect when the caps have duplicated entries (441 bytes, patch)
2012-09-27 17:23 UTC, Andre Moreira Magalhaes
reviewed Details | Review

Description Andre Moreira Magalhaes 2012-09-27 17:18:17 UTC
Trying "gst-launch-1.0 videotestsrc ! identity ! valve ! gamma ! videoconvert ! videobalance ! videoconvert ! autovideosink" on gstreamer 1.0 (release) will make the pipeline hang on PREROLLING for a _long_ time, till the caps negotiation finally finishes.
Comment 1 Andre Moreira Magalhaes 2012-09-27 17:23:40 UTC
Created attachment 225274 [details] [review]
Do not hang on caps intersect when the caps have duplicated entries

After some investigation, the issue happens when caps with duplicated entries are intersected. gst_caps_intersect_full will be called from gst_base_transform and will hang on gst_structure_intersect, resulting in a caps with many duplicated lists inside lists entries.

This happened cause the gamma element set it caps tempĺate to     GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
            "ARGB, BGRA, ABGR, RGBA, ABGR, RGBA, Y444, "
            "xRGB, RGBx, xBGR, BGRx, RGB, BGR, Y42B, NV12, "
            "NV21, YUY2, UYVY, YVYU, I420, YV12, IYUV, Y41B }"))
where RGBA and ABGR are duplicated entries. 

After caps negotiation finally finishes, the result is:
video/x-raw, format=(string){ I420, YV12, YUY2, UYVY, AYUV, RGBx, BGRx, xRGB, xBGR, { RGBA, RGBA, { RGBA, RGBA }, { RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, { RGBA, RGBA, { RGBA, RGBA } } }, { RGBA, RGBA, { RGBA, RGBA }, { RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, { RGBA, RGBA, { RGBA, RGBA } } } }, { RGBA, RGBA, { RGBA, RGBA }, { RGBA, RGBA,...

Fixing gstgamma also fixes the issue, but a more generic fix is attached.
Comment 2 Thiago Sousa Santos 2012-09-27 19:00:37 UTC
FYI to reproduce the original issue you should revert this patch in -good:

commit 25803d651bf75ee1c2c0d728962ed93a5254eee8
Author: Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>
Date:   Thu Sep 27 15:50:49 2012 -0300

    gamma: remove duplicate entries at format at caps
    
    Avoids extra caps/structures processing
Comment 3 Tim-Philipp Müller 2012-09-28 10:43:25 UTC
I'm wondering if it shouldn't be:

diff --git a/gst/gstvalue.c b/gst/gstvalue.c
index 80c59fe..de9fa06 100644
--- a/gst/gstvalue.c
+++ b/gst/gstvalue.c
@@ -3498,7 +3498,7 @@ gst_value_intersect_list (GValue * dest, const GValue * value1,
 
         gst_value_init_and_copy (&temp, dest);
         g_value_unset (dest);
-        gst_value_list_concat (dest, &temp, &intersection);
+        gst_value_list_merge (dest, &temp, &intersection);
         g_value_unset (&temp);
       }
       g_value_unset (&intersection);

which avoids duplicates in dest.
Comment 4 Andre Moreira Magalhaes 2012-09-28 15:12:55 UTC
(In reply to comment #3)
> I'm wondering if it shouldn't be:
> 
> diff --git a/gst/gstvalue.c b/gst/gstvalue.c
> index 80c59fe..de9fa06 100644
> --- a/gst/gstvalue.c
> +++ b/gst/gstvalue.c
> @@ -3498,7 +3498,7 @@ gst_value_intersect_list (GValue * dest, const GValue *
> value1,
> 
>          gst_value_init_and_copy (&temp, dest);
>          g_value_unset (dest);
> -        gst_value_list_concat (dest, &temp, &intersection);
> +        gst_value_list_merge (dest, &temp, &intersection);
>          g_value_unset (&temp);
>        }
>        g_value_unset (&intersection);
> 
> which avoids duplicates in dest.

Test here and it works with both this patch or my patch from comment #1.
Comment 5 Sebastian Dröge (slomo) 2012-09-29 13:16:45 UTC
Merging however requires to always iterate over the complete list while concat is just changing a few pointers.

I still think this change is correct, just has the potential of degraded performance in other cases.
Comment 6 Tim-Philipp Müller 2012-09-29 13:45:43 UTC
I think it's the right thing to do as well, and I hope the positive effects of keeping the list small right away will outweigh the negatives overall:


commit 507fc9cea7d587446fba08dfeac7e063e14c680e
Author: Tim-Philipp Müller <tim.muller@collabora.co.uk>
Date:   Sat Sep 29 14:35:58 2012 +0100

    value: avoid duplicates when intersecting lists
    
    Fixes negotiation taking a ridiculous amount of
    time (multiple 10s of seconds on a core2) when
    there are duplicate entries in lists.
    
    Could have a negative performance impact on other
    scenarios because we now have to iterate the
    dest list to avoid duplicates, but we don't
    have a lot of lists any more these days, and
    they tend to be small anyway. The negatives
    are hopefully countered by the positive effects
    of reducing the list length early on in the
    process. And in any case, it's the right thing
    to do.
    
    Based on patch by Andre Moreira Magalhaes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684981
Comment 7 Tim-Philipp Müller 2012-09-29 13:47:01 UTC
Comment on attachment 225274 [details] [review]
Do not hang on caps intersect when the caps have duplicated entries

I've pushed my patch now, because it's more generic.