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 780140 - souphttpsrc: Implement soup session sharing
souphttpsrc: Implement soup session sharing
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
unspecified
Other All
: Normal enhancement
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 721807 751372 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-03-16 12:43 UTC by Sebastian Dröge (slomo)
Modified: 2018-11-03 15:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
souphttpsrc: Implement soup session sharing (13.15 KB, patch)
2017-03-16 12:43 UTC, Sebastian Dröge (slomo)
committed Details | Review
uridownloader: add new gst_uri_downloader_set_parent (4.39 KB, patch)
2017-03-16 12:44 UTC, Sebastian Dröge (slomo)
committed Details | Review
adaptivedemux: set uridownloader's parent (1.14 KB, patch)
2017-03-16 12:44 UTC, Sebastian Dröge (slomo)
committed Details | Review
souphttpsrc: Use a in-memory cookie jar by default in sessions we created (1.02 KB, patch)
2017-03-16 13:20 UTC, Sebastian Dröge (slomo)
committed Details | Review
uridownloader: Use a GWeakRef to the parent to prevent a reference cycle (3.28 KB, patch)
2017-03-17 10:58 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2017-03-16 12:43:35 UTC
Also needs some patches for adaptivedemux to make use of that, but with that
it's then possible to use exactly the same connection for the initial
manifest, any variant manifests and the fragments. Which speeds up
time-to-play a lot especially if using HTTPS where every connection setup is
very expensive.
Comment 1 Sebastian Dröge (slomo) 2017-03-16 12:43:40 UTC
Created attachment 348079 [details] [review]
souphttpsrc: Implement soup session sharing

souphttpsrc now shares its SoupSession with other elements in the
pipeline via GstContext if possible (session-wide settings are all the
defaults), or if the context was forced by the application.

This allows multiple souphttpsrcs to reuse connections, cookies, etc.
Comment 2 Sebastian Dröge (slomo) 2017-03-16 12:44:10 UTC
Created attachment 348080 [details] [review]
uridownloader: add new gst_uri_downloader_set_parent

If set, the parent is used to proxy need-context messages from
uridownloader's http source in order to get cookies/headers
from the pipeline.

Based on a patch from Philippe Normand

https://bugzilla.gnome.org/show_bug.cgi?id=726314
Comment 3 Sebastian Dröge (slomo) 2017-03-16 12:44:16 UTC
Created attachment 348081 [details] [review]
adaptivedemux: set uridownloader's parent

Allows internal http source to request contexts and share cookies
with the pipeline in case the server imposes any restriction based
on cookies.
Comment 4 Sebastian Dröge (slomo) 2017-03-16 13:20:44 UTC
Created attachment 348085 [details] [review]
souphttpsrc: Use a in-memory cookie jar by default in sessions we created

This ensures that cookies are stored and used as set by the server, and
shared with other souphttpsrc that use the same SoupSession.
Comment 5 Sebastian Dröge (slomo) 2017-03-16 13:24:54 UTC
Note that this also allows the application to set a SoupSession on the pipeline (with "force=true"), and then whatever the application wants can be done from there.
Comment 6 Xavier Claessens 2017-03-16 15:55:17 UTC
*** Bug 721807 has been marked as a duplicate of this bug. ***
Comment 7 Sebastian Dröge (slomo) 2017-03-17 10:37:06 UTC
Should this go into 1.12, possible disabled by default unless GST_SOUP_SESSION_SHARE=1 is defined in the environment to easily test it?
Comment 8 Sebastian Dröge (slomo) 2017-03-17 10:50:21 UTC
Review of attachment 348081 [details] [review]:

::: gst-libs/gst/adaptivedemux/gstadaptivedemux.c
@@ +441,3 @@
   demux->priv->input_adapter = gst_adapter_new ();
   demux->downloader = gst_uri_downloader_new ();
+  gst_uri_downloader_set_parent (demux->downloader, GST_ELEMENT_CAST (demux));

This creates a circular reference cycle between demux and downloader. The downloader should probably just use a GWeakRef here.
Comment 9 Sebastian Dröge (slomo) 2017-03-17 10:58:41 UTC
Created attachment 348162 [details] [review]
uridownloader: Use a GWeakRef to the parent to prevent a reference cycle
Comment 10 Sebastian Dröge (slomo) 2017-05-09 12:27:53 UTC
Attachment 348079 [details] pushed as 7cb70e7 - souphttpsrc: Implement soup session sharing
Attachment 348085 [details] pushed as eee911b - souphttpsrc: Use a in-memory cookie jar by default in sessions we created
Comment 11 Edward Hervey 2017-05-18 11:09:29 UTC
This is causing various deadlocks and refcount issues on the context.

One way to reproduce is gst-validate-launcher -m -f -t validate.dash.playback.scrub_forward_seeking.dash_exMPD_BIP_TC1

https://ci.gstreamer.net/job/GStreamer-master-validate/4932/testReport/junit/validate.dash.playback/scrub_forward_seeking/dash_exMPD_BIP_TC1/
Comment 12 Sebastian Dröge (slomo) 2017-05-18 11:26:10 UTC
I don't see refcount issue, but that deadlock I can reproduce. Something seems to be locking the main context's mutex but not releasing it again. Nothing in our code though, we don't do anything with that mutex (it's private to glib).
Comment 13 Sebastian Dröge (slomo) 2017-05-18 11:39:56 UTC
Ah the problem is that something destroys the context or session in the meantime.
Comment 14 Sebastian Dröge (slomo) 2017-05-18 12:11:31 UTC
Remaining problem is that there's either a bug in libsoup, or we use the API wrong (even before my patches).

commit 1f2e48852ee07bfb40e8fa2df9b11835a136a7ca
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Thu May 18 15:10:30 2017 +0300

    souphttpsrc: Make session sharing thread-safe on our side
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780140
Comment 15 Sebastian Dröge (slomo) 2017-05-19 09:26:22 UTC
It looks like libsoup is using the thread default main context for some reason here, which it shouldn't because we only use the sync libsoup API. And things randomly explode in libsoup, which might also be a thread-safety bug in there.

I don't see anything wrong with reference counting, etc. on our side.
Comment 16 Edward Hervey 2017-11-10 09:43:43 UTC
Updating title accordingly.
Comment 17 Sebastian Dröge (slomo) 2017-12-07 08:00:03 UTC
We should disable session sharing for any libsoup version that does not include https://bugzilla.gnome.org/show_bug.cgi?id=762138#c3
Comment 18 Eunhae Choi 2017-12-07 08:18:40 UTC
*** Bug 751372 has been marked as a duplicate of this bug. ***
Comment 19 Tim-Philipp Müller 2017-12-07 09:56:04 UTC
(In reply to Sebastian Dröge (slomo) from comment #17)
> We should disable session sharing for any libsoup version that does not
> include https://bugzilla.gnome.org/show_bug.cgi?id=762138#c3

Is this a blocker then?
Comment 20 Sebastian Dröge (slomo) 2017-12-07 14:12:24 UTC
Yes but Edward opened another bug for that, or not? This one here is solved and not a blocker, it's a new feature.
Comment 21 GStreamer system administrator 2018-11-03 15:17:27 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/gstreamer/gst-plugins-good/issues/356.