Changeset 228639 in webkit


Ignore:
Timestamp:
Feb 19, 2018 2:47:49 AM (6 years ago)
Author:
calvaris@igalia.com
Message:

[GStreamer] Crash in WebCore::MediaPlayerRequestInstallMissingPluginsCallback::complete
https://bugs.webkit.org/show_bug.cgi?id=166733

Reviewed by Philippe Normand.

There are a couple of issues to tackle here.

First is handling getting more than one missing plugin
installation request at the same time. For this we add the request
to a Vector and handle them there.

Second is that if the player is dead and we still get the result,
bad things happen. For that we "weaked" the pointer capture by the
lambda.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
Handle Vector of callbacks.
(WebCore::MediaPlayerPrivateGStreamer::handleMessage): Weak
private player pointer and put the callback in the Vector.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

Callback becomes Vector.

  • platform/graphics/gstreamer/MediaPlayerRequestInstallMissingPluginsCallback.h:

(WebCore::MediaPlayerRequestInstallMissingPluginsCallback::create):
(WebCore::MediaPlayerRequestInstallMissingPluginsCallback::complete):
(WebCore::MediaPlayerRequestInstallMissingPluginsCallback::MediaPlayerRequestInstallMissingPluginsCallback):
Callback function is refactored into a "using" type and added self
as parameter to the function.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228617 r228639  
     12018-02-19  Xabier Rodriguez Calvar  <calvaris@igalia.com>
     2
     3        [GStreamer] Crash in WebCore::MediaPlayerRequestInstallMissingPluginsCallback::complete
     4        https://bugs.webkit.org/show_bug.cgi?id=166733
     5
     6        Reviewed by Philippe Normand.
     7
     8        There are a couple of issues to tackle here.
     9
     10        First is handling getting more than one missing plugin
     11        installation request at the same time. For this we add the request
     12        to a Vector and handle them there.
     13
     14        Second is that if the player is dead and we still get the result,
     15        bad things happen. For that we "weaked" the pointer capture by the
     16        lambda.
     17
     18        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     19        (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
     20        Handle Vector of callbacks.
     21        (WebCore::MediaPlayerPrivateGStreamer::handleMessage): Weak
     22        private player pointer and put the callback in the Vector.
     23        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
     24        Callback becomes Vector.
     25        * platform/graphics/gstreamer/MediaPlayerRequestInstallMissingPluginsCallback.h:
     26        (WebCore::MediaPlayerRequestInstallMissingPluginsCallback::create):
     27        (WebCore::MediaPlayerRequestInstallMissingPluginsCallback::complete):
     28        (WebCore::MediaPlayerRequestInstallMissingPluginsCallback::MediaPlayerRequestInstallMissingPluginsCallback):
     29        Callback function is refactored into a "using" type and added self
     30        as parameter to the function.
     31
    1322018-02-19  Philippe Normand  <pnormand@igalia.com>
    233
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r228617 r228639  
    192192
    193193    m_readyTimerHandler.stop();
    194     if (m_missingPluginsCallback) {
    195         m_missingPluginsCallback->invalidate();
    196         m_missingPluginsCallback = nullptr;
    197     }
     194    for (auto& missingPluginCallback : m_missingPluginCallbacks) {
     195        if (missingPluginCallback)
     196            missingPluginCallback->invalidate();
     197    }
     198    m_missingPluginCallbacks.clear();
    198199
    199200    if (m_videoSink) {
     
    11081109    switch (GST_MESSAGE_TYPE(message)) {
    11091110    case GST_MESSAGE_ERROR:
    1110         if (m_resetPipeline || m_missingPluginsCallback || m_errorOccured)
     1111        if (m_resetPipeline || !m_missingPluginCallbacks.isEmpty() || m_errorOccured)
    11111112            break;
    11121113        gst_message_parse_error(message, &err.outPtr(), &debug.outPtr());
     
    12041205        if (gst_is_missing_plugin_message(message)) {
    12051206            if (gst_install_plugins_supported()) {
    1206                 m_missingPluginsCallback = MediaPlayerRequestInstallMissingPluginsCallback::create([this](uint32_t result) {
    1207                     m_missingPluginsCallback = nullptr;
     1207                RefPtr<MediaPlayerRequestInstallMissingPluginsCallback> missingPluginCallback = MediaPlayerRequestInstallMissingPluginsCallback::create([weakThis = createWeakPtr()](uint32_t result, MediaPlayerRequestInstallMissingPluginsCallback& missingPluginCallback) {
     1208                    if (!weakThis) {
     1209                        GST_INFO("got missing pluging installation callback in destroyed player with result %u", result);
     1210                        return;
     1211                    }
     1212
     1213                    GST_DEBUG("got missing plugin installation callback with result %u", result);
     1214                    RefPtr<MediaPlayerRequestInstallMissingPluginsCallback> protectedMissingPluginCallback = &missingPluginCallback;
     1215                    weakThis->m_missingPluginCallbacks.removeFirst(protectedMissingPluginCallback);
    12081216                    if (result != GST_INSTALL_PLUGINS_SUCCESS)
    12091217                        return;
    12101218
    1211                     changePipelineState(GST_STATE_READY);
    1212                     changePipelineState(GST_STATE_PAUSED);
     1219                    weakThis->changePipelineState(GST_STATE_READY);
     1220                    weakThis->changePipelineState(GST_STATE_PAUSED);
    12131221                });
     1222                m_missingPluginCallbacks.append(missingPluginCallback);
    12141223                GUniquePtr<char> detail(gst_missing_plugin_message_get_installer_detail(message));
    12151224                GUniquePtr<char> description(gst_missing_plugin_message_get_description(message));
    1216                 m_player->client().requestInstallMissingPlugins(String::fromUTF8(detail.get()), String::fromUTF8(description.get()), *m_missingPluginsCallback);
     1225                m_player->client().requestInstallMissingPlugins(String::fromUTF8(detail.get()), String::fromUTF8(description.get()), *missingPluginCallback);
    12171226            }
    12181227        }
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r228617 r228639  
    269269    GRefPtr<GstElement> m_autoAudioSink;
    270270    GRefPtr<GstElement> m_downloadBuffer;
    271     RefPtr<MediaPlayerRequestInstallMissingPluginsCallback> m_missingPluginsCallback;
     271    Vector<RefPtr<MediaPlayerRequestInstallMissingPluginsCallback>> m_missingPluginCallbacks;
    272272#if ENABLE(VIDEO_TRACK)
    273273    HashMap<AtomicString, RefPtr<AudioTrackPrivateGStreamer>> m_audioTracks;
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerRequestInstallMissingPluginsCallback.h

    r218615 r228639  
    3030    WTF_MAKE_FAST_ALLOCATED();
    3131public:
    32     static Ref<MediaPlayerRequestInstallMissingPluginsCallback> create(WTF::Function<void (uint32_t)>&& function)
     32    using MediaPlayerRequestInstallMissingPluginsCallbackFunction = std::function<void(uint32_t, MediaPlayerRequestInstallMissingPluginsCallback&)>;
     33
     34    static Ref<MediaPlayerRequestInstallMissingPluginsCallback> create(MediaPlayerRequestInstallMissingPluginsCallbackFunction&& function)
    3335    {
    3436        return adoptRef(*new MediaPlayerRequestInstallMissingPluginsCallback(WTFMove(function)));
     
    4446        if (!m_function)
    4547            return;
    46         m_function(result);
     48        m_function(result, *this);
    4749        m_function = nullptr;
    4850    }
    4951
    5052private:
    51     MediaPlayerRequestInstallMissingPluginsCallback(WTF::Function<void (uint32_t)>&& function)
     53    MediaPlayerRequestInstallMissingPluginsCallback(MediaPlayerRequestInstallMissingPluginsCallbackFunction&& function)
    5254        : m_function(WTFMove(function))
    5355    {
    5456    }
    5557
    56     WTF::Function<void (uint32_t)> m_function;
     58    MediaPlayerRequestInstallMissingPluginsCallbackFunction m_function;
    5759};
    5860
Note: See TracChangeset for help on using the changeset viewer.