Changeset 200455 in webkit


Ignore:
Timestamp:
May 5, 2016 6:03:46 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[GStreamer] Adaptive streaming issues
https://bugs.webkit.org/show_bug.cgi?id=144040

Reviewed by Philippe Normand.

In the case of adaptive streaming, the GST URI downloader object is creating the source object, in our case
WebKitWebSrc, without taking its ownership. This is breaking the lifetime of the WebKitWebSrc element. We are
using GRefPtr in WebKitWebSrc to ref/unref the object when sending notifications to the main thread, ensuring
that the object is not destroyed before the main thread dispatches the message. But our smart pointers are so
smart that in case of receiving a floating reference, it's converted to a full reference, so that the first time
we try to take a ref of a WebKitWebSrc having a floating reference we are actually taking the ownership
instead. When we try to release the reference, we are actuallty destroying the object, something that the actual
owner is not expecting and causing runtime critical warnings and very often web process crashes.

(WebKitWebProcess:6863): GStreamer-CRITICAL :
Trying to dispose element appsrc1, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

(WebKitWebProcess:6863): GStreamer-CRITICAL : gst_uri_handler_get_uri: assertion 'GST_IS_URI_HANDLER(handler)' failed

(WebKitWebProcess:6863): GStreamer-CRITICAL : gst_uri_get_protocol: assertion 'uri != NULL' failed

This should be fixed in GST, but we can workaround it in WebKit while it's fixed in GST or to prevent this from
happening if other users make the same mistake. The idea is to add a ensureGRef() only available for GRefPtr
when using WebKitWebSrc objects that consumes the floating reference if needed before taking the actual reference.

  • platform/graphics/gstreamer/GRefPtrGStreamer.cpp:

(WTF::ensureGRef): Consume the floating ref if needed.

  • platform/graphics/gstreamer/GRefPtrGStreamer.h:
  • platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:

(webKitWebSrcChangeState): Use ensureGRef().

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r200453 r200455  
     12016-05-05  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GStreamer] Adaptive streaming issues
     4        https://bugs.webkit.org/show_bug.cgi?id=144040
     5
     6        Reviewed by Philippe Normand.
     7
     8        In the case of adaptive streaming, the GST URI downloader object is creating the source object, in our case
     9        WebKitWebSrc, without taking its ownership. This is breaking the lifetime of the WebKitWebSrc element. We are
     10        using GRefPtr in WebKitWebSrc to ref/unref the object when sending notifications to the main thread, ensuring
     11        that the object is not destroyed before the main thread dispatches the message. But our smart pointers are so
     12        smart that in case of receiving a floating reference, it's converted to a full reference, so that the first time
     13        we try to take a ref of a WebKitWebSrc having a floating reference we are actually taking the ownership
     14        instead. When we try to release the reference, we are actuallty destroying the object, something that the actual
     15        owner is not expecting and causing runtime critical warnings and very often web process crashes.
     16
     17            (WebKitWebProcess:6863): GStreamer-CRITICAL **:
     18            Trying to dispose element appsrc1, but it is in READY instead of the NULL state.
     19            You need to explicitly set elements to the NULL state before
     20            dropping the final reference, to allow them to clean up.
     21            This problem may also be caused by a refcounting bug in the
     22            application or some element.
     23
     24            (WebKitWebProcess:6863): GStreamer-CRITICAL **: gst_uri_handler_get_uri: assertion 'GST_IS_URI_HANDLER(handler)' failed
     25
     26            (WebKitWebProcess:6863): GStreamer-CRITICAL **: gst_uri_get_protocol: assertion 'uri != NULL' failed
     27
     28        This should be fixed in GST, but we can workaround it in WebKit while it's fixed in GST or to prevent this from
     29        happening if other users make the same mistake. The idea is to add a ensureGRef() only available for GRefPtr
     30        when using WebKitWebSrc objects that consumes the floating reference if needed before taking the actual reference.
     31
     32        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
     33        (WTF::ensureGRef): Consume the floating ref if needed.
     34        * platform/graphics/gstreamer/GRefPtrGStreamer.h:
     35        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
     36        (webKitWebSrcChangeState): Use ensureGRef().
     37
    1382016-05-05  Csaba Osztrogonác  <ossy@webkit.org>
    239
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp

    r196809 r200455  
    343343}
    344344
     345// This method is only available for WebKitWebSrc and should not be used for any other type.
     346// This is only to work around a bug in GST where the URI downloader is not taking the ownership of WebKitWebSrc.
     347// See https://bugs.webkit.org/show_bug.cgi?id=144040.
     348GRefPtr<WebKitWebSrc> ensureGRef(WebKitWebSrc* ptr)
     349{
     350    if (ptr && g_object_is_floating(ptr))
     351        gst_object_ref_sink(GST_OBJECT(ptr));
     352    return GRefPtr<WebKitWebSrc>(ptr);
     353}
     354
    345355template <> WebKitWebSrc* refGPtr<WebKitWebSrc>(WebKitWebSrc* ptr)
    346356{
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h

    r195735 r200455  
    109109
    110110template<> GRefPtr<WebKitWebSrc> adoptGRef(WebKitWebSrc* ptr);
     111GRefPtr<WebKitWebSrc> ensureGRef(WebKitWebSrc* ptr);
    111112template<> WebKitWebSrc* refGPtr<WebKitWebSrc>(WebKitWebSrc* ptr);
    112113template<> void derefGPtr<WebKitWebSrc>(WebKitWebSrc* ptr);
  • trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp

    r197897 r200455  
    189189        }
    190190
    191         GRefPtr<WebKitWebSrc> protector(src);
     191        GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
    192192        priv->notifier.notify(MainThreadSourceNotification::NeedData, [protector] { webKitWebSrcNeedData(protector.get()); });
    193193    },
     
    203203        }
    204204
    205         GRefPtr<WebKitWebSrc> protector(src);
     205        GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
    206206        priv->notifier.notify(MainThreadSourceNotification::EnoughData, [protector] { webKitWebSrcEnoughData(protector.get()); });
    207207    },
     
    223223        }
    224224
    225         GRefPtr<WebKitWebSrc> protector(src);
     225        GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
    226226        priv->notifier.notify(MainThreadSourceNotification::Seek, [protector] { webKitWebSrcSeek(protector.get()); });
    227227        return TRUE;
     
    641641    {
    642642        GST_DEBUG_OBJECT(src, "READY->PAUSED");
    643         GRefPtr<WebKitWebSrc> protector(src);
     643        GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
    644644        priv->notifier.notify(MainThreadSourceNotification::Start, [protector] { webKitWebSrcStart(protector.get()); });
    645645        break;
     
    649649        GST_DEBUG_OBJECT(src, "PAUSED->READY");
    650650        priv->notifier.cancelPendingNotifications();
    651         GRefPtr<WebKitWebSrc> protector(src);
     651        GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
    652652        priv->notifier.notify(MainThreadSourceNotification::Stop, [protector] { webKitWebSrcStop(protector.get()); });
    653653        break;
Note: See TracChangeset for help on using the changeset viewer.