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 789462 - Multi branched pipe freezes in case CPU overloaded
Multi branched pipe freezes in case CPU overloaded
Status: RESOLVED INVALID
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.8.3
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-10-25 08:45 UTC by Alex
Modified: 2017-10-25 19:09 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Alex 2017-10-25 08:45:29 UTC
So during custom plugin development I found that multi branched pipe freezes in some cases.
According with my investigation I found that CPU overloading has critical influence to this issue

For example pipe like this
===
gst-launch-1.0 rtspsrc location=rtsp://admin:admin@192.168.1.108 ! decodebin ! tee name=teebranch ! queue ! autovideosink teebranch. ! queue ! fakesink
===

in most cases works fine

but this one:
===
gst-launch-1.0 rtspsrc location=rtsp://admin:admin@192.168.1.108 ! decodebin ! tee name=teebranch ! queue ! autovideosink teebranch. ! queue ! x264enc ! fakesink
===
in most cases freezes

The different in the CPU consuming element - x264enc
Comment 1 Mathieu Duponchelle 2017-10-25 11:17:38 UTC
This is probably a case of not large enough queues, by default x264enc has a pretty large latency, try to either increase the size of the queues or set tune=zerolatency

Setting to NEEDINFO for now, please let us know whether that fixed it :)
Comment 2 Nicolas Dufresne (ndufresne) 2017-10-25 12:19:12 UTC
My impression is that we already address this in https://bugzilla.gnome.org/show_bug.cgi?id=789467

With adding QoS to the encoder. A leaky queue could also work, but may not drop the appropriate frames.
Comment 3 Mathieu Duponchelle 2017-10-25 12:45:46 UTC
(In reply to Nicolas Dufresne (stormer) from comment #2)
> My impression is that we already address this in
> https://bugzilla.gnome.org/show_bug.cgi?id=789467
> 
> With adding QoS to the encoder. A leaky queue could also work, but may not
> drop the appropriate frames.

Hm maybe, what I observe here with videotestsrc is simply that the pipeline fails to preroll with:

gst-launch-1.0 videotestsrc ! tee name=teebranch ! queue ! autovideosink teebranch. ! queue ! x264enc ! fakesink

because the video sink branch prerolls then blocks, and the encoder branch never pushes a buffer because its latency is superior to 1 second :)
Comment 4 Alex 2017-10-25 14:20:42 UTC
Hi
this latest case is close to original issue.
I mean originally instead x264enc I did use my custom OpenCV plugin.

So does any body know why pipe freezes and how it could be resolved?
I mean probably somehow allow to drop frames or other things... ???
Comment 5 Mathieu Duponchelle 2017-10-25 15:53:02 UTC
(In reply to Alex from comment #4)
> Hi
> this latest case is close to original issue.
> I mean originally instead x264enc I did use my custom OpenCV plugin.
> 
> So does any body know why pipe freezes and how it could be resolved?

There may be multiple reasons for that, as we do not know the implementation of your custom plugin, we can only guess: does your plugin need more than one second of buffers before it outputs something ? If you know exactly what latency it introduces, you can use that to set a higher max-size-time on the queues. Alternatively, you could also set async=false on the fakesink.

> I mean probably somehow allow to drop frames or other things... ???

It really depends on what the problem is, we can't really know that for your custom element. For the pipeline with an x264enc , you can use either of the solutions I pointed out earlier (larger queues, tune=zerolatency).
Comment 6 Alex 2017-10-25 15:57:35 UTC
Hi
Yes my plugin sometime takes more than one second but
1) when I did try to use sleep(1) for one second. I scan see messages of the gstreamer-bus about dropped frames
2) But when I did try to use CPU overloaded like:

    static int val =0;
    ++val;
    if(val > 40)
    {
        val = 0;
        for(int i = 0;  i< 4000; ++i)
        {
            sleep(0);
        }
    }
pipe freezes
Comment 7 Mathieu Duponchelle 2017-10-25 19:09:39 UTC
If you cannot provide more information about how to reproduce the issue, I'm afraid I'm going to have to close this as INVALID. Please feel free to come and discuss the implementation of your custom plugin in our IRC, or on the mailing list :)