Bug 100586

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

Description Fabrice Bellet 2017-04-05 16:43:47 UTC
Created attachment 130702 [details]
gdb backtrace

I noticed another case, where the error "not-linked" on the nicesrc element happens, like described in bug #100565
Comment 1 Fabrice Bellet 2017-04-05 16:47:08 UTC
Created attachment 130705 [details] [review]
rtp: stop the transmitter before unlinking its sink (session destroy case)

Possible fix, by stopping the transmitters earlier.
Comment 2 Olivier Crête 2017-04-05 17:04:47 UTC
(In reply to Fabrice Bellet from comment #1)
> Created attachment 130705 [details] [review] [review]
> rtp: stop the transmitter before unlinking its sink (session destroy case)

The state changes have to be sink to source, otherwise we risk a deadlock.

How do you reproduce this?
Comment 3 Fabrice Bellet 2017-04-05 20:28:12 UTC
(In reply to Olivier Crête from comment #2)
> 
> How do you reproduce this?

In empathy, with an audio + video session, when both peers close the video stream only (camera button), the last client closing it can cause this error on the first client's side. This is not 100% reproducible. The visible effect for the user is that the remaining audio session also closes, while remaining open on the other user's client.
Comment 4 Fabrice Bellet 2017-04-05 21:31:05 UTC
Created attachment 130716 [details]
gstreamer log messages
Comment 5 Fabrice Bellet 2017-04-11 12:11:53 UTC
If this can help, it seems to me that this case is more easily reproducible, when GST_DEBUG is set to a high value (in my case, the value is set to 6), maybe some subtle scheduling differences introduced by the logging overhead.
Comment 6 Fabrice Bellet 2017-05-24 19:07:18 UTC
Created attachment 131476 [details] [review]
rtp: stop the transmitter before unlinking its source

With this patch, we stop the transmitters a bit earlier but not too early compared to the previous one.
Comment 7 Olivier Crête 2017-06-05 22:29:34 UTC
the pipeline is

transmitter-src -> funnel -> rtpbin -> substream

So your new patch is still trying to stop the transmitter-src before the funnel, but indeed this can cause a not-linked error.. I wonder if we should split the state changing and the removing steps into two separate steps.
Comment 8 Fabrice Bellet 2017-06-13 12:15:05 UTC
Created attachment 131918 [details]
gstreamer pipeline dot file when reaching gstbasesrc.c:2950
Comment 9 Fabrice Bellet 2017-06-13 12:28:59 UTC
Created attachment 131919 [details]
gdb backtrace matching previous dot file

The bug still exists. What looks odd to me in fs_rtp_session_dispose() is the use of the function stop_and_remove() in places where the inline comments indicate that elements are just stopped. I'd say that the transmitter_rtp_funnel is stopped (ok) and removed (not ok) too early, before the gst-src transmitters themselves are stopped. 

I have a patch that splits this function in two parts, one that just stops the elements, and one that removes the elements from the bin. Stopping the elements first, and removing them in the same order after the comment " Now they should all be stopped...". This patch works for me on this bug. Would this solution be possible ?
Comment 10 Fabrice Bellet 2017-06-14 11:52:50 UTC
Created attachment 131952 [details] [review]
rtp: stop the transmitter src before unlinking the funnel

Following your comment #7, this patch splits the stop_and_remove() function and applies it to the funnel :

stop the funnel - stop the transmitters src - remove the funnel
Comment 11 GitLab Migration User 2018-08-21 12:16:28 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/7.

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.