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 749676 - playbin: failed to get end-of-stream event when visualization flag is enabled
playbin: failed to get end-of-stream event when visualization flag is enabled
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-05-21 11:03 UTC by Brijesh Singh
Modified: 2015-06-12 16:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
playsink: use queue to avoid lock in audiotee audio branches (5.29 KB, patch)
2015-05-26 11:33 UTC, Thiago Sousa Santos
accepted-commit_now Details | Review

Description Brijesh Singh 2015-05-21 11:03:54 UTC
If visualization flags is enabled then pipeline failed to exit cleanly. Below pipeline failed to reach EOS:

gst-launch-1.0 playbin uri=file:///home/brijesh/gst-player/tests/media/audio-short.ogg flags=audio+vis
Comment 1 Brijesh Singh 2015-05-21 20:24:22 UTC
Did git bisect and found that the below commit is causing this issue. 

commit 9f81931716b7f8fd29862f0bfa1a3891cb414bdc
Author: Song Bing <b06498@freescale.com>
Date:   Mon Jan 12 16:08:33 2015 +0800

    streamsynchronizer: Send GAP event to finish preroll when change state from PLAYING to PAUSED

    Wait in the event function when EOS is received until all pads are EOS
    and then forward the EOS event from each pads own event function.

    Also send a new GAP event for EOS pads from the event function whenever
    going from PLAYING->PAUSED by shortly waking up the GCond. This is needed
    to allow sinks to pre-roll again, as they did not receive EOS yet because
    we blocked that, but also will never get data again.

    https://bugzilla.gnome.org/show_bug.cgi?id=736655
Comment 2 Thiago Sousa Santos 2015-05-25 20:59:04 UTC
Looks like a queue is missing. Audiotee pushes EOS into streamsynchronizer and then it blocks waiting for EOS on other pads. As there is no queue before streamsynchronizer it locks up the pipeline as audiotee will never push the EOS on the visualizer branch.
Comment 3 Sebastian Dröge (slomo) 2015-05-25 21:25:54 UTC
Yeah, I think there's also a comment about this in playsink's code somewhere. The above commit probably should've come together with adding queues :)
Comment 4 Thiago Sousa Santos 2015-05-25 22:04:32 UTC
Indeed. Quickly added a queue here and it fixed the problem. Will work on the proper patch and attach it here.
Comment 5 Thiago Sousa Santos 2015-05-26 11:33:09 UTC
Created attachment 303999 [details] [review]
playsink: use queue to avoid lock in audiotee audio branches

This part of pipeline is:

tee name=t ! visualizationbin ! streamsynchronizer name=s
t. ! s.

streamsynchronizer might block and it could starve the visualization
branch of the pipeline when it is enabled.

The visualization bin has queues internally but the other branch
that links the audiotee directly to the synchronizer is vulnerable
to block. Adding a queue between "t. ! s." fixes deadlocks.
Comment 6 Brijesh Singh 2015-05-26 12:32:45 UTC
I tried the patch and it works well in both gst-launch as well as gst-player lib.
Comment 7 Sebastian Dröge (slomo) 2015-05-28 07:21:53 UTC
Comment on attachment 303999 [details] [review]
playsink: use queue to avoid lock in audiotee audio branches

Does this only add the queue if vis is enabled? If so, please push, looks good :)
Comment 8 Thiago Sousa Santos 2015-05-28 07:26:20 UTC
(In reply to Sebastian Dröge (slomo) from comment #7)
> Comment on attachment 303999 [details] [review] [review]
> playsink: use queue to avoid lock in audiotee audio branches
> 
> Does this only add the queue if vis is enabled? If so, please push, looks
> good :)

It is always adding the queue, I'll update and push. From the code it seems vis can't be enabled/disabled during playback so it should be simple.
Comment 9 Sebastian Dröge (slomo) 2015-05-28 07:30:28 UTC
Vis can be enabled/disabled during playback IIRC. That will trigger the reconfigure thing inside playsink then.
Comment 10 Thiago Sousa Santos 2015-05-28 07:35:15 UTC
Ah, that is done called from playbin and not internally from playsink. Will check that.
Comment 11 Thiago Sousa Santos 2015-05-28 08:22:10 UTC
Thanks for the review, patch pushed

commit 12ac087807232df52392bfb21cdff7f89c393606
Author: Thiago Santos <thiagoss@osg.samsung.com>
Date:   Tue May 26 08:06:50 2015 -0300

    playsink: use queue to avoid lock in audiotee audio branches
    
    This part of pipeline is:
    
    tee name=t ! visualizationbin ! streamsynchronizer name=s
    t. ! s.
    
    streamsynchronizer might block and it could starve the visualization
    branch of the pipeline when it is enabled.
    
    The visualization bin has queues internally but the other branch
    that links the audiotee directly to the synchronizer is vulnerable
    to block. Adding a queue between "t. ! s." fixes deadlocks.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749676
Comment 12 Brijesh Singh 2015-05-28 12:09:14 UTC
I have tried looping a short audio file with vis enabled and after 10 min of loop (~ 250+ iteration) i get the following messages on the console 

(gtk-play:25751): GStreamer-CRITICAL **: gst_poll_write_control: assertion 'set != NULL' failed

The looping is still working. If i disable the vis then i do not see this message. It seems like this patch fixed the main issue but exposed something else ..

I am using gst-player lib https://github.com/sdroege/gst-player to reproduce the problems.
Comment 13 Brijesh Singh 2015-05-28 12:38:50 UTC
You can reproduce the issue with minor modification in gst-play-1.0. I just hacked gst-play to add loop and enable vis. See the code below. 

The test audio file is available here: 

https://github.com/sdroege/gst-player/blob/master/tests/media/audio-short.ogg


brijesh@brijesh-M11BB:~/gst-plugins-base/tools$ git diff .
diff --git a/tools/gst-play.c b/tools/gst-play.c
index f2b8ad6..c1a6275 100644
--- a/tools/gst-play.c
+++ b/tools/gst-play.c
@@ -131,6 +131,7 @@ play_new (gchar ** uris, const gchar * audio_sink, const gchar * video_sink,
 {
   GstElement *sink;
   GstPlay *play;
+  guint flags;
 
   play = g_new0 (GstPlay, 1);
 
@@ -163,6 +164,10 @@ play_new (gchar ** uris, const gchar * audio_sink, const gchar * video_sink,
       g_warning ("Couldn't create specified video sink '%s'", video_sink);
   }
 
+  g_object_get (play->playbin, "flags", &flags, NULL);
+  flags |= 0x8;
+  g_object_set (play->playbin, "flags", flags, NULL);
+
   play->loop = g_main_loop_new (NULL, FALSE);
 
   play->bus_watch = gst_bus_add_watch (GST_ELEMENT_BUS (play->playbin),
@@ -533,7 +538,8 @@ static gboolean
 play_next (GstPlay * play)
 {
   if ((play->cur_idx + 1) >= play->num_uris)
-    return FALSE;
+    play->cur_idx = -1;
+//    return FALSE;
 
   play_uri (play, play->uris[++play->cur_idx]);
   return TRUE;
Comment 14 Sebastian Dröge (slomo) 2015-05-30 09:49:06 UTC
I had that running for about 5 minutes without problems, it also didn't look like any bigger amount of memory is leaked.

Can you run in a debugger and get a backtrace? If you set G_DEBUG=fatal_warnings in the environment, the debugger will stop on the critical warning.
Comment 15 Brijesh Singh 2015-06-01 14:59:49 UTC
Sometime it just takes a bit longer to see it, I am using Ubuntu 15.04 with latest gstreamer code from git tree. 

Here is backtrack generate from the corefile. 
----------------

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `gst-play-1.0 gst-player/tests/media/audio-short.ogg'.
Program terminated with signal SIGTRAP, Trace/breakpoint trap.
  • #0 g_logv
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #0 g_logv
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #1 g_log
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #2 gst_poll_write_control
    at gstpoll.c line 1521
  • #3 gst_buffer_pool_init
    at gstbufferpool.c line 174
  • #4 g_type_create_instance
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #5 ??
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #6 g_object_newv
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #7 g_object_new
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #8 gst_video_buffer_pool_new
    at gstvideopool.c line 260
  • #9 gst_video_filter_propose_allocation
    at gstvideofilter.c line 92
  • #10 gst_base_transform_default_query
  • #11 gst_pad_query
    at gstpad.c line 3792
  • #12 gst_pad_peer_query
    at gstpad.c line 3920
  • #13 query_forward_func
    at gstpad.c line 3199
  • #14 gst_pad_forward
    at gstpad.c line 2838
  • #15 gst_pad_query_default
    at gstpad.c line 3266
  • #16 gst_play_sink_convert_bin_query
    at gstplaysinkconvertbin.c line 501
  • #17 gst_pad_query
    at gstpad.c line 3792
  • #18 gst_pad_peer_query
    at gstpad.c line 3920
  • #19 gst_queue_push_one
    at gstqueue.c line 1421
  • #20 gst_queue_loop
    at gstqueue.c line 1484
  • #21 gst_task_func
    at gsttask.c line 331
  • #22 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #23 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #24 start_thread
    at pthread_create.c line 333
  • #25 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 109

Comment 16 Sebastian Dröge (slomo) 2015-06-01 16:02:43 UTC
That seems like we're running out of fds at some point, there must be an fd leak somewhere. Maybe a buffer pool.
Comment 17 Thiago Sousa Santos 2015-06-01 20:07:14 UTC
I let it running here for 1h (8805 iterations) and it didn't crash. Is there anything particular with your setup? I'm using latest git master, no hardware decoders and the default video sink is xvimagesink. Debian sid.
Comment 18 Brijesh Singh 2015-06-03 14:54:12 UTC
That is interesting. I just updated to latest gstreamer, gst-plugins-good and gst-plugins-base and still able to reproduce it.  I am using Ubuntu 15.04 with all latest updates etc. I will try to follow Sebastian's recommendation and run lsof in background to see if i see any fd leaks
Comment 19 Sebastian Dröge (slomo) 2015-06-07 18:26:04 UTC
Run a few iterations in valgrind and let it exit then, IIRC valgrind can also tell you about fd leaks.
Comment 20 Brijesh Singh 2015-06-12 00:58:44 UTC
I have tried with latest gstreamer release 1.5.1 and no longer able to reproduce this. We can close this bug.
Comment 21 Thiago Sousa Santos 2015-06-12 04:06:59 UTC
Do you know what changed as you had tested with git? 1.5.1 shouldn't be much different from git of a couple days ago.
Comment 22 Brijesh Singh 2015-06-12 16:43:05 UTC
I think the main difference was, in past i was updating gst-plugin-base git but was  still using somewhat a older version of gstreamer and gst-plugins-good. And this time i did git pull on all (gstreamer, gst-plugins-base and gst-plugins-good) and now do not see this issue anymore.
Comment 23 Thiago Sousa Santos 2015-06-12 16:44:49 UTC
Ok, let's mark this as fixed again.

Thanks for confirming.