Bug 100565

Summary: nicesrc gst element failing (reason not-linked) while removing it
Product: Farstream Reporter: Fabrice Bellet <fabrice>
Component: CoreAssignee: Olivier Crête <olivier.crete>
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium CC: fabrice, olivier.crete
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: gdb session
GST related log file (edited)
rtp: stop the transmitter before unlinking its sink (stream destroy case)
nice transmitter: Flush source before stopping
gstreamer pipeline dot file when reaching gstbasesrc.c:2950
gstreamer pipeline dot file when reaching gstbasesrc.c:2950 (the good one)
gdb backtrace matching previous dot file
flush source before unlinking

Description Fabrice Bellet 2017-04-04 19:42:44 UTC
Hi!

I encountered this bug while removing the video stream (and the video stream only) in a fsrtpsession in empathy. The problem happens while the  farstream session is destroyed, there is some kind of race, when the nicesrc element transition changes from PLAYING to PAUSED to READY, and still handles buffers, without an attached sink, causing the not-linked error in the basesrc gst element. 

This error being fatal for the pipeline, the connection is unexpectedly closed in the client.
Comment 1 Fabrice Bellet 2017-04-04 19:46:58 UTC
Created attachment 130674 [details]
gdb session

The nicesrc70:src thread stops in gstbasesrc.c:2950, when the "streaming stopped, reason not-linked" error is generated. At the same time, the main thread is locked while changing the nicesrc state from PAUSED to READY.
Comment 2 Fabrice Bellet 2017-04-04 19:51:46 UTC
Created attachment 130675 [details]
GST related log file (edited)

the interesting part of the log is just before the jump from timestamp 0:15:17 to 12:04:29 (this gap is because empathy-call remained stopped in the debugger for quite a long time, before continuing), following the nicesrc70 element.
Comment 3 Fabrice Bellet 2017-04-04 20:36:42 UTC
I reassign this bug to the Farstream product instead.
Comment 4 Fabrice Bellet 2017-04-05 16:35:06 UTC
Created attachment 130701 [details] [review]
rtp: stop the transmitter before unlinking its sink (stream destroy case)

This patch seems to work for me, by stopping the nicesrc element, before removing it from the bin.
Comment 5 Olivier Crête 2017-04-05 17:02:59 UTC
Comment on attachment 130701 [details] [review]
rtp: stop the transmitter before unlinking its sink (stream destroy case)

Review of attachment 130701 [details] [review]:
-----------------------------------------------------------------

That may result in a EOS event being sent downstream which may break other FsStreams connected to the same FsSession


And the patch subject is wrong, your unlinking the source there..
Comment 6 Olivier Crête 2017-06-05 23:28:11 UTC
Created attachment 131729 [details] [review]
nice transmitter: Flush source before stopping

Maybe we should just send a flush to the source first. Here is a patch that does just that. Let me know if this helps.
Comment 7 Fabrice Bellet 2017-06-13 12:32:31 UTC
Created attachment 131920 [details]
gstreamer pipeline dot file when reaching gstbasesrc.c:2950
Comment 8 Fabrice Bellet 2017-06-13 12:33:49 UTC
Created attachment 131923 [details]
gstreamer pipeline dot file when reaching gstbasesrc.c:2950 (the good one)
Comment 9 Fabrice Bellet 2017-06-13 12:55:53 UTC
Created attachment 131924 [details]
gdb backtrace matching previous dot file

The patch from comment #6 doesn't help. 

What seems interesting in this backtrace compared to the backtrace from bug #100586 is that fs_rtp_stream_dispose() is called *before* fs_rtp_session_dispose(), which explains why the conference bin is not stopped, and the removal of the nicesrc88 element from the bin91 GstBin causes this not-linked error.

The other (working) call stack should be fs_rtp_session_dispose() --> fs_stream_destroy() --> fs_rtp_stream_dispose() --> fs_stream_transmitter_stop(), and in that case the gst-src transmitters would stopped first.

The junction point where the behaviour diverges is in call-content.c:2363 in telepathy-farstream. When the stream is not destroyed there, the session is destroyed in _tf_call_content_destroy().

I wonder if the order of destruction should not be forced in _tf_call_content_destroy() ?
Comment 10 Fabrice Bellet 2017-06-14 11:48:59 UTC
Created attachment 131951 [details] [review]
flush source before unlinking

Would it be correct to send the flush event before removing the nice source and not after ?
Comment 11 GitLab Migration User 2018-08-21 12:16:07 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/farstream/farstream/issues/4.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.