[GTK][GStreamer] media/video-preload.html is flakily crashing on WK2
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Dec 2013 18:54:40 +0000 (18:54 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Dec 2013 18:54:40 +0000 (18:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125411

Patch by Brendan Long <b.long@cablelabs.com> on 2013-12-10
Reviewed by Philippe Normand.

No new tests because this fixes flakeyness in existing tests (media/video-preload.html, and various tests in media/track/{audio,in-band,video}).

* platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
(webkitTextCombinerPadGetProperty): Copy tag list to prevent concurrent modification problems.
(webkitTextCombinerPadEvent): Add locking.
* platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
(WebCore::TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer): Call tagsChanged() because we need it to setup m_tags.
(WebCore::TrackPrivateBaseGStreamer::disconnect): Clear m_tags.
(WebCore::TrackPrivateBaseGStreamer::tagsChanged): Lookup the tags while we're in this callback, because it's the only time we can guarantee that the input-selector won't unref them.
(WebCore::TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged): Use m_tags.
* platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h: Add m_tags and a mutex.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160375 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h

index f8ecb46..4430b97 100644 (file)
@@ -1,3 +1,22 @@
+2013-12-10  Brendan Long  <b.long@cablelabs.com>
+
+        [GTK][GStreamer] media/video-preload.html is flakily crashing on WK2
+        https://bugs.webkit.org/show_bug.cgi?id=125411
+
+        Reviewed by Philippe Normand.
+
+        No new tests because this fixes flakeyness in existing tests (media/video-preload.html, and various tests in media/track/{audio,in-band,video}).
+
+        * platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
+        (webkitTextCombinerPadGetProperty): Copy tag list to prevent concurrent modification problems.
+        (webkitTextCombinerPadEvent): Add locking.
+        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
+        (WebCore::TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer): Call tagsChanged() because we need it to setup m_tags.
+        (WebCore::TrackPrivateBaseGStreamer::disconnect): Clear m_tags.
+        (WebCore::TrackPrivateBaseGStreamer::tagsChanged): Lookup the tags while we're in this callback, because it's the only time we can guarantee that the input-selector won't unref them.
+        (WebCore::TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged): Use m_tags.
+        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h: Add m_tags and a mutex.
+
 2013-12-10  László Langó  <lango@inf.u-szeged.hu>
 
         PageConsole::addMessage should automatically determine column number alongside line number
index d963268..339ca37 100644 (file)
@@ -111,7 +111,8 @@ static void webkitTextCombinerPadGetProperty(GObject* object, guint propertyId,
     switch (propertyId) {
     case PROP_PAD_TAGS:
         GST_OBJECT_LOCK(object);
-        g_value_set_boxed(value, pad->tags);
+        if (pad->tags)
+            g_value_take_boxed(value, gst_tag_list_copy(pad->tags));
         GST_OBJECT_UNLOCK(object);
         break;
     default:
@@ -202,10 +203,13 @@ static gboolean webkitTextCombinerPadEvent(GstPad* pad, GstObject* parent, GstEv
         gst_event_parse_tag(event, &tags);
         ASSERT(tags);
 
+        GST_OBJECT_LOCK(pad);
         if (!combinerPad->tags)
             combinerPad->tags = gst_tag_list_copy(tags);
         else
             gst_tag_list_insert(combinerPad->tags, tags, GST_TAG_MERGE_REPLACE);
+        GST_OBJECT_UNLOCK(pad);
+
         g_object_notify(G_OBJECT(pad), "tags");
         break;
     }
index bd7a68d..a6f927f 100644 (file)
@@ -75,7 +75,9 @@ TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer(TrackPrivateBase* owner, gi
     g_signal_connect(m_pad.get(), "notify::active", G_CALLBACK(trackPrivateActiveChangedCallback), this);
     g_signal_connect(m_pad.get(), "notify::tags", G_CALLBACK(trackPrivateTagsChangedCallback), this);
 
-    notifyTrackOfTagsChanged();
+    // We can't call notifyTrackOfTagsChanged() directly, because we need tagsChanged()
+    // to setup m_tags.
+    tagsChanged();
 }
 
 TrackPrivateBaseGStreamer::~TrackPrivateBaseGStreamer()
@@ -100,6 +102,7 @@ void TrackPrivateBaseGStreamer::disconnect()
         g_source_remove(m_tagTimerHandler);
 
     m_pad.clear();
+    m_tags.clear();
 }
 
 void TrackPrivateBaseGStreamer::activeChanged()
@@ -114,6 +117,14 @@ void TrackPrivateBaseGStreamer::tagsChanged()
 {
     if (m_tagTimerHandler)
         g_source_remove(m_tagTimerHandler);
+
+    GRefPtr<GstTagList> tags;
+    g_object_get(m_pad.get(), "tags", &tags.outPtr(), NULL);
+    {
+        MutexLocker lock(m_tagMutex);
+        m_tags.swap(tags);
+    }
+
     m_tagTimerHandler = g_timeout_add(0,
         reinterpret_cast<GSourceFunc>(trackPrivateTagsChangeTimeoutCallback), this);
 }
@@ -149,7 +160,10 @@ void TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged()
 
     TrackPrivateBaseClient* client = m_owner->client();
     GRefPtr<GstTagList> tags;
-    g_object_get(m_pad.get(), "tags", &tags.outPtr(), NULL);
+    {
+        MutexLocker lock(m_tagMutex);
+        tags.swap(m_tags);
+    }
     if (!tags)
         return;
 
index 4faf9b2..1e3b8c8 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(VIDEO) && USE(GSTREAMER) && ENABLE(VIDEO_TRACK)
 
 #include "GRefPtrGStreamer.h"
+#include <wtf/ThreadingPrimitives.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -67,6 +68,9 @@ private:
     TrackPrivateBase* m_owner;
     guint m_activeTimerHandler;
     guint m_tagTimerHandler;
+
+    Mutex m_tagMutex;
+    GRefPtr<GstTagList> m_tags;
 };
 
 } // namespace WebCore