Title: [221782] trunk/Source/WebCore
- Revision
- 221782
- Author
- [email protected]
- Date
- 2017-09-08 03:57:35 -0700 (Fri, 08 Sep 2017)
Log Message
[GStreamer] initializationDataEncountered() dispatch can outlive MediaPlayerPrivateGStreamerBase
https://bugs.webkit.org/show_bug.cgi?id=176544
Reviewed by Xabier Rodriguez-Calvar.
The RunLoop dispatch that invokes MediaPlayer::initializationDataEncountered()
can outlive the MediaPlayerPrivateGStreamerBase object that is referenced
from the dispatched functor. To avoid this, a WeakPtrFactory is placed onto
MediaPlayerPrivateGStreamerBase and a WeakPtr object is kept in the functor,
bailing during dispatch if the factory (along with MediaPlayerPrivateGStreamerBase)
has already been destroyed since the schedule of this dispatch.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::handleSyncMessage):
Also remove the unused `sessionId` string.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (221781 => 221782)
--- trunk/Source/WebCore/ChangeLog 2017-09-08 10:55:15 UTC (rev 221781)
+++ trunk/Source/WebCore/ChangeLog 2017-09-08 10:57:35 UTC (rev 221782)
@@ -1,5 +1,25 @@
2017-09-08 Zan Dobersek <[email protected]>
+ [GStreamer] initializationDataEncountered() dispatch can outlive MediaPlayerPrivateGStreamerBase
+ https://bugs.webkit.org/show_bug.cgi?id=176544
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ The RunLoop dispatch that invokes MediaPlayer::initializationDataEncountered()
+ can outlive the MediaPlayerPrivateGStreamerBase object that is referenced
+ from the dispatched functor. To avoid this, a WeakPtrFactory is placed onto
+ MediaPlayerPrivateGStreamerBase and a WeakPtr object is kept in the functor,
+ bailing during dispatch if the factory (along with MediaPlayerPrivateGStreamerBase)
+ has already been destroyed since the schedule of this dispatch.
+
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+ (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
+ (WebCore::MediaPlayerPrivateGStreamerBase::handleSyncMessage):
+ Also remove the unused `sessionId` string.
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+
+2017-09-08 Zan Dobersek <[email protected]>
+
[GStreamer] Add GRefPtr specializations for GstGLDisplay, GstGLContext
https://bugs.webkit.org/show_bug.cgi?id=176543
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (221781 => 221782)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2017-09-08 10:55:15 UTC (rev 221781)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2017-09-08 10:57:35 UTC (rev 221782)
@@ -43,7 +43,6 @@
#include <wtf/text/AtomicString.h>
#include <wtf/text/CString.h>
#include <wtf/MathExtras.h>
-#include <wtf/UUID.h>
#include <gst/audio/streamvolume.h>
#include <gst/video/gstvideometa.h>
@@ -227,7 +226,8 @@
#endif // USE(GSTREAMER_GL)
MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* player)
- : m_notifier(MainThreadNotifier<MainThreadNotification>::create())
+ : m_weakPtrFactory(this)
+ , m_notifier(MainThreadNotifier<MainThreadNotification>::create())
, m_player(player)
, m_fpsSink(nullptr)
, m_readyState(MediaPlayer::HaveNothing)
@@ -364,13 +364,13 @@
if (concatenatedInitDataChunksNumber > 1)
eventKeySystemIdString = emptyString();
- String sessionId(createCanonicalUUIDString());
+ RunLoop::main().dispatch([weakThis = m_weakPtrFactory.createWeakPtr(), eventKeySystemIdString, initData = WTFMove(concatenatedInitDataChunks)] {
+ if (!weakThis)
+ return;
- RunLoop::main().dispatch([this, eventKeySystemIdString, sessionId, initData = WTFMove(concatenatedInitDataChunks)] {
GST_DEBUG("scheduling initializationDataEncountered event for %s with concatenated init datas size of %" G_GSIZE_FORMAT, eventKeySystemIdString.utf8().data(), initData.size());
GST_MEMDUMP("init datas", initData.data(), initData.size());
-
- m_player->initializationDataEncountered(ASCIILiteral("cenc"), ArrayBuffer::create(initData.data(), initData.size()));
+ weakThis->m_player->initializationDataEncountered(ASCIILiteral("cenc"), ArrayBuffer::create(initData.data(), initData.size()));
});
GST_INFO("waiting for a CDM instance");
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (221781 => 221782)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2017-09-08 10:55:15 UTC (rev 221781)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2017-09-08 10:57:35 UTC (rev 221782)
@@ -34,6 +34,7 @@
#include <wtf/Condition.h>
#include <wtf/Forward.h>
#include <wtf/RunLoop.h>
+#include <wtf/WeakPtr.h>
#if USE(TEXTURE_MAPPER_GL)
#include "TextureMapperPlatformLayerProxyProvider.h"
@@ -196,6 +197,7 @@
SizeChanged = 1 << 6
};
+ WeakPtrFactory<MediaPlayerPrivateGStreamerBase> m_weakPtrFactory;
Ref<MainThreadNotifier<MainThreadNotification>> m_notifier;
MediaPlayer* m_player;
GRefPtr<GstElement> m_pipeline;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes