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 779131 - waylandsink: disable last sample sink feature
waylandsink: disable last sample sink feature
Status: RESOLVED INVALID
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.11.1
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-02-23 12:46 UTC by Fabien Dessenne
Modified: 2017-02-24 14:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
waylandsink-disable-last-sample-sink-feature (1.13 KB, patch)
2017-02-23 12:46 UTC, Fabien Dessenne
rejected Details | Review

Description Fabien Dessenne 2017-02-23 12:46:13 UTC
Created attachment 346564 [details] [review]
waylandsink-disable-last-sample-sink-feature

The "last-sample" basesink feature stores a reference to the last buffer sent for rendering. A consequence is that one buffer is always locked, decreasing the number of buffers of the pool actually available.

Disabling this feature improves the buffer pool capacity and prevents some deadlock race conditions.
Comment 1 Tim-Philipp Müller 2017-02-23 12:58:44 UTC
Wonder if this has undesirable side-effects though, like affecting playbin's screenshot functionality for example.
Comment 2 Fabien Dessenne 2017-02-23 13:12:17 UTC
Oh yes it probably prevents screenshot.

The point is that waylandsink does not really have the full control of the buffer locking since this is delegated to the wayland compositor. From what I have observed weston keeps a reference on a buffer even after that one is no more displayed (released more or less one frame later). So the pool is always close to propose 'unavailable' buffers.
In some cases, I observed dead lock :  all buffers used by weston or decoder and no one wants to free any.
The other point is that when DMABuf buffers are used, waylandsink does not propose any pool but it is up to the upstream element to propose one. But this upstream element is not aware of sink/weston buffer locking, so it is hard to set correctly the min_buffer value.
Disabling last-sample solves a part of the problem

But I agree with you: this has a drawback (that I shall have explicitly mentioned in the initial comment).
Comment 3 Nicolas Dufresne (ndufresne) 2017-02-23 15:23:32 UTC
Review of attachment 346564 [details] [review]:

I'll nack this one, sorry. We use "pipeline stall" for what you described as a deadlock here. The right way it to add 1 to the number of requested buffer in propose_allocation().
Comment 4 Fabien Dessenne 2017-02-23 15:43:59 UTC
Do you mean that I shall raise a new ticket to increase min_buffers from 2 to 3 in gst_wayland_sink_propose_allocation() to avoid pipeline stall?

snip:
static gboolean
gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
{
...
  if (pool) {
    gst_query_add_allocation_pool (query, pool, sink->video_info.size, 2, 0);
    g_object_unref (pool);
  }
...
Comment 5 Nicolas Dufresne (ndufresne) 2017-02-23 17:38:14 UTC
You can re-purpose this one really. What you came up with, is a solution to your problem. I'm just saying, this isn't a solution. last-sample should not stall your pipeline, and that's what you should fix. enable-last-sample is ON on every single video-sink by default. It would be very inconsistent to not follow this. Obviously, if you don't use screenshot in your application, turn it off. Now, 2 should be enough, but slow, since it means a buffer cannot be filled while being rendered. So 3 is a much better default. Exception, if you add support for interlacing at some point, you may need to increase this a bit. So the buffer purpose would be:

1. Upstream being filled
2. Being rendered by the compositor
3. Stuck in last-sample

Arguably, this extra one could have been proposed by upstream, but I think in practice no one does that, so better account at least 1 buffer being out. In many many cases, you will not notice, as most buffer pools can grow on demand.
Comment 6 Fabien Dessenne 2017-02-24 14:26:53 UTC
OK, thank your for the clarification.
Since this is definitively not the right way to solve this issue, I close this ticket.