Diff
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog 2017-06-20 10:40:48 UTC (rev 218586)
@@ -1,3 +1,51 @@
+2017-06-18 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GStreamer] MainThreadNotifier ASSERTION FAILED: m_boundThread == currentThread() in _WebKitWebSrcPrivate::~_WebKitWebSrcPrivate
+ https://bugs.webkit.org/show_bug.cgi?id=152043
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ Stop using a WeakPtr in MainThreadNotifier, because it's not thread safe, which causes a crash in debug builds when
+ the notifier is destroyed in a different thread. Make MainThreadNotifier thread safe refcounted instead, and add
+ an invalidate() method to mark it as invalid.
+
+ * platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp:
+ (WebCore::InbandTextTrackPrivateGStreamer::handleSample):
+ (WebCore::InbandTextTrackPrivateGStreamer::streamChanged):
+ * platform/graphics/gstreamer/MainThreadNotifier.h:
+ (WebCore::MainThreadNotifier::MainThreadNotifier): Deleted.
+ (WebCore::MainThreadNotifier::notify): Deleted.
+ (WebCore::MainThreadNotifier::cancelPendingNotifications): Deleted.
+ (WebCore::MainThreadNotifier::addPendingNotification): Deleted.
+ (WebCore::MainThreadNotifier::removePendingNotification): Deleted.
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::videoChangedCallback):
+ (WebCore::MediaPlayerPrivateGStreamer::videoSinkCapsChangedCallback):
+ (WebCore::MediaPlayerPrivateGStreamer::audioChangedCallback):
+ (WebCore::MediaPlayerPrivateGStreamer::textChangedCallback):
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+ (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
+ (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
+ (WebCore::MediaPlayerPrivateGStreamerBase::volumeChangedCallback):
+ (WebCore::MediaPlayerPrivateGStreamerBase::muteChangedCallback):
+ (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint):
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+ * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
+ (WebCore::TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer):
+ (WebCore::TrackPrivateBaseGStreamer::~TrackPrivateBaseGStreamer):
+ (WebCore::TrackPrivateBaseGStreamer::disconnect):
+ (WebCore::TrackPrivateBaseGStreamer::activeChangedCallback):
+ (WebCore::TrackPrivateBaseGStreamer::tagsChanged):
+ * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h:
+ * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+ (webkit_web_src_init):
+ (webKitWebSrcDispose):
+ (webKitWebSrcStop):
+ (webKitWebSrcStart):
+ (webKitWebSrcNeedData):
+ (webKitWebSrcEnoughData):
+ (webKitWebSrcSeek):
+
2017-06-17 Antti Koivisto <an...@apple.com>
Crash due to infinite recursion via FrameSelection::updateAppearanceAfterLayout
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp 2017-06-20 10:40:48 UTC (rev 218586)
@@ -75,7 +75,7 @@
}
RefPtr<InbandTextTrackPrivateGStreamer> protectedThis(this);
- m_notifier.notify(MainThreadNotification::NewSample, [protectedThis] {
+ m_notifier->notify(MainThreadNotification::NewSample, [protectedThis] {
protectedThis->notifyTrackOfSample();
});
}
@@ -83,7 +83,7 @@
void InbandTextTrackPrivateGStreamer::streamChanged()
{
RefPtr<InbandTextTrackPrivateGStreamer> protectedThis(this);
- m_notifier.notify(MainThreadNotification::StreamChanged, [protectedThis] {
+ m_notifier->notify(MainThreadNotification::StreamChanged, [protectedThis] {
protectedThis->notifyTrackOfStreamChanged();
});
}
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MainThreadNotifier.h (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MainThreadNotifier.h 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MainThreadNotifier.h 2017-06-20 10:40:48 UTC (rev 218586)
@@ -16,27 +16,28 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef MainThreadNotifier_h
-#define MainThreadNotifier_h
+#pragma once
+#include <wtf/Atomics.h>
#include <wtf/Lock.h>
#include <wtf/MainThread.h>
#include <wtf/RunLoop.h>
-#include <wtf/WeakPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
namespace WebCore {
template <typename T>
-class MainThreadNotifier {
+class MainThreadNotifier final : public ThreadSafeRefCounted<MainThreadNotifier<T>> {
public:
- MainThreadNotifier()
- : m_weakPtrFactory(this)
+ static Ref<MainThreadNotifier> create()
{
+ return adoptRef(*new MainThreadNotifier());
}
template<typename F>
void notify(T notificationType, const F& callbackFunctor)
{
+ ASSERT(m_isValid.load());
if (isMainThread()) {
removePendingNotification(notificationType);
callbackFunctor();
@@ -46,10 +47,10 @@
if (!addPendingNotification(notificationType))
return;
- auto weakThis = m_weakPtrFactory.createWeakPtr();
- std::function<void ()> callback(callbackFunctor);
- RunLoop::main().dispatch([weakThis, notificationType, callback] {
- if (weakThis && weakThis->removePendingNotification(notificationType))
+ RunLoop::main().dispatch([this, protectedThis = makeRef(*this), notificationType, callback = std::function<void()>(callbackFunctor)] {
+ if (!m_isValid.load())
+ return;
+ if (removePendingNotification(notificationType))
callback();
});
}
@@ -56,6 +57,7 @@
void cancelPendingNotifications(unsigned mask = 0)
{
+ ASSERT(m_isValid.load());
LockHolder locker(m_pendingNotificationsLock);
if (mask)
m_pendingNotifications &= ~mask;
@@ -63,7 +65,17 @@
m_pendingNotifications = 0;
}
+ void invalidate()
+ {
+ ASSERT(m_isValid.load());
+ m_isValid.store(false);
+ }
+
private:
+ MainThreadNotifier()
+ {
+ m_isValid.store(true);
+ }
bool addPendingNotification(T notificationType)
{
@@ -84,12 +96,10 @@
return false;
}
- WeakPtrFactory<MainThreadNotifier> m_weakPtrFactory;
Lock m_pendingNotificationsLock;
unsigned m_pendingNotifications { 0 };
+ Atomic<bool> m_isValid;
};
-
} // namespace WebCore
-#endif // MainThreadNotifier_h
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2017-06-20 10:40:48 UTC (rev 218586)
@@ -620,7 +620,7 @@
void MediaPlayerPrivateGStreamer::videoChangedCallback(MediaPlayerPrivateGStreamer* player)
{
- player->m_notifier.notify(MainThreadNotification::VideoChanged, [player] { player->notifyPlayerOfVideo(); });
+ player->m_notifier->notify(MainThreadNotification::VideoChanged, [player] { player->notifyPlayerOfVideo(); });
}
void MediaPlayerPrivateGStreamer::notifyPlayerOfVideo()
@@ -674,7 +674,7 @@
void MediaPlayerPrivateGStreamer::videoSinkCapsChangedCallback(MediaPlayerPrivateGStreamer* player)
{
- player->m_notifier.notify(MainThreadNotification::VideoCapsChanged, [player] { player->notifyPlayerOfVideoCaps(); });
+ player->m_notifier->notify(MainThreadNotification::VideoCapsChanged, [player] { player->notifyPlayerOfVideoCaps(); });
}
void MediaPlayerPrivateGStreamer::notifyPlayerOfVideoCaps()
@@ -685,7 +685,7 @@
void MediaPlayerPrivateGStreamer::audioChangedCallback(MediaPlayerPrivateGStreamer* player)
{
- player->m_notifier.notify(MainThreadNotification::AudioChanged, [player] { player->notifyPlayerOfAudio(); });
+ player->m_notifier->notify(MainThreadNotification::AudioChanged, [player] { player->notifyPlayerOfAudio(); });
}
void MediaPlayerPrivateGStreamer::notifyPlayerOfAudio()
@@ -738,7 +738,7 @@
#if ENABLE(VIDEO_TRACK)
void MediaPlayerPrivateGStreamer::textChangedCallback(MediaPlayerPrivateGStreamer* player)
{
- player->m_notifier.notify(MainThreadNotification::TextChanged, [player] { player->notifyPlayerOfText(); });
+ player->m_notifier->notify(MainThreadNotification::TextChanged, [player] { player->notifyPlayerOfText(); });
}
void MediaPlayerPrivateGStreamer::notifyPlayerOfText()
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2017-06-20 10:40:48 UTC (rev 218586)
@@ -200,7 +200,8 @@
#endif // USE(COORDINATED_GRAPHICS_THREADED) && USE(GSTREAMER_GL)
MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* player)
- : m_player(player)
+ : m_notifier(MainThreadNotifier<MainThreadNotification>::create())
+ , m_player(player)
, m_fpsSink(nullptr)
, m_readyState(MediaPlayer::HaveNothing)
, m_networkState(MediaPlayer::Empty)
@@ -223,8 +224,9 @@
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
m_protectionCondition.notifyOne();
#endif
- m_notifier.cancelPendingNotifications();
+ m_notifier->invalidate();
+
cancelRepaint();
if (m_videoSink) {
@@ -566,7 +568,7 @@
// This is called when m_volumeElement receives the notify::volume signal.
GST_DEBUG("Volume changed to: %f", player->volume());
- player->m_notifier.notify(MainThreadNotification::VolumeChanged, [player] { player->notifyPlayerOfVolumeChange(); });
+ player->m_notifier->notify(MainThreadNotification::VolumeChanged, [player] { player->notifyPlayerOfVolumeChange(); });
}
MediaPlayer::NetworkState MediaPlayerPrivateGStreamerBase::networkState() const
@@ -615,7 +617,7 @@
void MediaPlayerPrivateGStreamerBase::muteChangedCallback(MediaPlayerPrivateGStreamerBase* player)
{
// This is called when m_volumeElement receives the notify::mute signal.
- player->m_notifier.notify(MainThreadNotification::MuteChanged, [player] { player->notifyPlayerOfMute(); });
+ player->m_notifier->notify(MainThreadNotification::MuteChanged, [player] { player->notifyPlayerOfMute(); });
}
void MediaPlayerPrivateGStreamerBase::acceleratedRenderingStateChanged()
@@ -755,7 +757,7 @@
if (triggerResize) {
GST_DEBUG("First sample reached the sink, triggering video dimensions update");
- m_notifier.notify(MainThreadNotification::SizeChanged, [this] { m_player->sizeChanged(); });
+ m_notifier->notify(MainThreadNotification::SizeChanged, [this] { m_player->sizeChanged(); });
}
#if USE(COORDINATED_GRAPHICS_THREADED)
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2017-06-20 10:40:48 UTC (rev 218586)
@@ -195,7 +195,7 @@
SizeChanged = 1 << 6
};
- MainThreadNotifier<MainThreadNotification> m_notifier;
+ Ref<MainThreadNotifier<MainThreadNotification>> m_notifier;
MediaPlayer* m_player;
GRefPtr<GstElement> m_pipeline;
GRefPtr<GstStreamVolume> m_volumeElement;
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp 2017-06-20 10:40:48 UTC (rev 218586)
@@ -44,7 +44,8 @@
namespace WebCore {
TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer(TrackPrivateBase* owner, gint index, GRefPtr<GstPad> pad)
- : m_index(index)
+ : m_notifier(MainThreadNotifier<MainThreadNotification>::create())
+ , m_index(index)
, m_pad(pad)
, m_owner(owner)
{
@@ -61,6 +62,7 @@
TrackPrivateBaseGStreamer::~TrackPrivateBaseGStreamer()
{
disconnect();
+ m_notifier->invalidate();
}
void TrackPrivateBaseGStreamer::disconnect()
@@ -68,7 +70,7 @@
if (!m_pad)
return;
- m_notifier.cancelPendingNotifications();
+ m_notifier->cancelPendingNotifications();
g_signal_handlers_disconnect_matched(m_pad.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
m_pad.clear();
@@ -77,7 +79,7 @@
void TrackPrivateBaseGStreamer::activeChangedCallback(TrackPrivateBaseGStreamer* track)
{
- track->m_notifier.notify(MainThreadNotification::ActiveChanged, [track] { track->notifyTrackOfActiveChanged(); });
+ track->m_notifier->notify(MainThreadNotification::ActiveChanged, [track] { track->notifyTrackOfActiveChanged(); });
}
void TrackPrivateBaseGStreamer::tagsChangedCallback(TrackPrivateBaseGStreamer* track)
@@ -98,7 +100,7 @@
m_tags.swap(tags);
}
- m_notifier.notify(MainThreadNotification::TagsChanged, [this] { notifyTrackOfTagsChanged(); });
+ m_notifier->notify(MainThreadNotification::TagsChanged, [this] { notifyTrackOfTagsChanged(); });
}
void TrackPrivateBaseGStreamer::notifyTrackOfActiveChanged()
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h 2017-06-20 10:40:48 UTC (rev 218586)
@@ -63,7 +63,7 @@
StreamChanged = 1 << 3
};
- MainThreadNotifier<MainThreadNotification> m_notifier;
+ Ref<MainThreadNotifier<MainThreadNotification>> m_notifier;
gint m_index;
AtomicString m_label;
AtomicString m_language;
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (218585 => 218586)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp 2017-06-20 10:38:21 UTC (rev 218585)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp 2017-06-20 10:40:48 UTC (rev 218586)
@@ -164,7 +164,7 @@
guint64 requestedOffset;
bool createdInMainThread;
- MainThreadNotifier<MainThreadSourceNotification> notifier;
+ RefPtr<MainThreadNotifier<MainThreadSourceNotification>> notifier;
GRefPtr<GstBuffer> buffer;
};
@@ -277,6 +277,7 @@
new (priv) WebKitWebSrcPrivate();
priv->createdInMainThread = isMainThread();
+ priv->notifier = MainThreadNotifier<MainThreadSourceNotification>::create();
priv->appsrc = GST_APP_SRC(gst_element_factory_make("appsrc", nullptr));
if (!priv->appsrc) {
@@ -326,8 +327,11 @@
static void webKitWebSrcDispose(GObject* object)
{
- WebKitWebSrc* src = ""
- WebKitWebSrcPrivate* priv = src->priv;
+ WebKitWebSrcPrivate* priv = WEBKIT_WEB_SRC(object)->priv;
+ if (priv->notifier) {
+ priv->notifier->invalidate();
+ priv->notifier = nullptr;
+ }
priv->player = nullptr;
@@ -408,8 +412,8 @@
if (priv->resource || (priv->loader && !priv->keepAlive)) {
GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.cancelPendingNotifications(MainThreadSourceNotification::NeedData | MainThreadSourceNotification::EnoughData | MainThreadSourceNotification::Seek);
- priv->notifier.notify(MainThreadSourceNotification::Stop, [protector, keepAlive = priv->keepAlive] {
+ priv->notifier->cancelPendingNotifications(MainThreadSourceNotification::NeedData | MainThreadSourceNotification::EnoughData | MainThreadSourceNotification::Seek);
+ priv->notifier->notify(MainThreadSourceNotification::Stop, [protector, keepAlive = priv->keepAlive] {
WebKitWebSrcPrivate* priv = protector->priv;
WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(protector.get()));
@@ -592,7 +596,7 @@
locker.unlock();
GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::Start, [protector, request = WTFMove(request)] {
+ priv->notifier->notify(MainThreadSourceNotification::Start, [protector, request = WTFMove(request)] {
WebKitWebSrcPrivate* priv = protector->priv;
WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(protector.get()));
@@ -792,7 +796,7 @@
}
GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::NeedData, [protector] {
+ priv->notifier->notify(MainThreadSourceNotification::NeedData, [protector] {
WebKitWebSrcPrivate* priv = protector->priv;
if (priv->resource)
priv->resource->setDefersLoading(false);
@@ -817,7 +821,7 @@
}
GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::EnoughData, [protector] {
+ priv->notifier->notify(MainThreadSourceNotification::EnoughData, [protector] {
WebKitWebSrcPrivate* priv = protector->priv;
if (priv->resource)
priv->resource->setDefersLoading(true);
@@ -848,7 +852,7 @@
}
GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::Seek, [protector] {
+ priv->notifier->notify(MainThreadSourceNotification::Seek, [protector] {
webKitWebSrcStop(protector.get());
webKitWebSrcStart(protector.get());
});