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 779945 - aggregator: Always call sink_event() from aggregate thread
aggregator: Always call sink_event() from aggregate thread
Status: RESOLVED DUPLICATE of bug 781673
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-12 16:26 UTC by Sebastian Dröge (slomo)
Modified: 2017-05-09 12:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
aggregator: Always handle serialized events from the aggregate thread (1.34 KB, patch)
2017-03-12 16:44 UTC, Sebastian Dröge (slomo)
needs-work Details | Review

Description Sebastian Dröge (slomo) 2017-03-12 16:26:00 UTC
Currently aggregator has this curious code in the sink event handler

>    if (!gst_aggregator_pad_queue_is_empty (aggpad) &&
>        GST_EVENT_TYPE (event) != GST_EVENT_FLUSH_STOP) {
>      GST_DEBUG_OBJECT (aggpad, "Store event in queue: %" GST_PTR_FORMAT,
>          event);
>      g_queue_push_head (&aggpad->priv->buffers, event);
>      event = NULL;
>      SRC_BROADCAST (self);
>    }

If the event is not queued up, it will be directly handled from the event thread. This seems a bit suboptimal as it means that sink_event() will be called from different threads, possible at the same time. At least for all serialized events (except for FLUSH_STOP) we should always queue them up and call them from the aggregate thread IMHO.

Easy enough to change, but there probably was a reason for this?
Comment 1 Sebastian Dröge (slomo) 2017-03-12 16:26:29 UTC
It seems like such a change would reduce a few potential race conditions.
Comment 2 Sebastian Dröge (slomo) 2017-03-12 16:44:20 UTC
Created attachment 347759 [details] [review]
aggregator: Always handle serialized events from the aggregate thread

Previously we were handling them from their own streaming thread
whenever the queue of the pad was empty, and otherwise queued them up
for later handling. This possibly caused the sink_event() vfunc to be
called simultaneously from different threads and possibly resulted in
race conditions.
Comment 3 Sebastian Dröge (slomo) 2017-03-12 17:25:09 UTC
Comment on attachment 347759 [details] [review]
aggregator: Always handle serialized events from the aggregate thread

This breaks the compositor unit test though
Comment 4 Matthew Waters (ystreet00) 2017-03-13 06:25:39 UTC
Olivier had the exact some change here: https://git.collabora.com/cgit/user/tester/gst-plugins-bad.git/log/?h=agg-neg-2.  Sounds like a good idea :).
Comment 5 Olivier Crête 2017-03-13 20:30:27 UTC
You want to first get the change to the clipping, look at the other patches before this one  in the  same branch. I just rebased it over master.
Comment 6 Olivier Crête 2017-03-13 20:33:48 UTC
I think the main reason I had not pushed those patches is that the end goal of this branch is to change the way aggregator handles caps, moving it all to the output thread, then add propose_allocation() and decide_allocation(). And I never got to the point where those were mergeable.
Comment 7 Sebastian Dröge (slomo) 2017-05-09 12:49:12 UTC

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