Title: [231551] trunk/Source/WebCore
Revision
231551
Author
[email protected]
Date
2018-05-09 00:38:45 -0700 (Wed, 09 May 2018)

Log Message

[EME][GStreamer] Crash when the mediaKeys are created before loading the media in debug conf
https://bugs.webkit.org/show_bug.cgi?id=185244

Patch by Yacine Bandou <[email protected]> on 2018-05-09
Reviewed by Xabier Rodriguez-Calvar.

The function "MediaPlayerPrivateGStreamerBase::cdmInstanceAttached" is expected to be called once,
so there is an ASSERT(!m_cdmInstance).
But when the MediaKeys are created before loading the media, the cdminstance is created and attached
to the MediaPlayerPrivate via "MediaPlayerPrivateGStreamerBase::cdmInstanceAttached" before loading
the media, then when the media is loading, the function "MediaPlayerPrivateGStreamerBase::cdmInstanceAttached"
will be called several times via the function "mediaEngineWasUpdated" wich is called for each change
in the MediaElement state, thus the WebProcess crashes in the ASSERT(!m_cdmInstance).

This commit avoid the crash by replacing the assert with a simple check.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::cdmInstanceAttached):
(WebCore::MediaPlayerPrivateGStreamerBase::cdmInstanceDetached):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (231550 => 231551)


--- trunk/Source/WebCore/ChangeLog	2018-05-09 07:38:23 UTC (rev 231550)
+++ trunk/Source/WebCore/ChangeLog	2018-05-09 07:38:45 UTC (rev 231551)
@@ -1,3 +1,24 @@
+2018-05-09  Yacine Bandou  <[email protected]>
+
+        [EME][GStreamer] Crash when the mediaKeys are created before loading the media in debug conf
+        https://bugs.webkit.org/show_bug.cgi?id=185244
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The function "MediaPlayerPrivateGStreamerBase::cdmInstanceAttached" is expected to be called once,
+        so there is an ASSERT(!m_cdmInstance).
+        But when the MediaKeys are created before loading the media, the cdminstance is created and attached
+        to the MediaPlayerPrivate via "MediaPlayerPrivateGStreamerBase::cdmInstanceAttached" before loading
+        the media, then when the media is loading, the function "MediaPlayerPrivateGStreamerBase::cdmInstanceAttached"
+        will be called several times via the function "mediaEngineWasUpdated" wich is called for each change
+        in the MediaElement state, thus the WebProcess crashes in the ASSERT(!m_cdmInstance).
+
+        This commit avoid the crash by replacing the assert with a simple check.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::cdmInstanceAttached):
+        (WebCore::MediaPlayerPrivateGStreamerBase::cdmInstanceDetached):
+
 2018-05-09  Antti Koivisto  <[email protected]>
 
         Add OptionSet::operator& and operator bool

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (231550 => 231551)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2018-05-09 07:38:23 UTC (rev 231550)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2018-05-09 07:38:45 UTC (rev 231551)
@@ -1206,10 +1206,11 @@
 #if ENABLE(ENCRYPTED_MEDIA)
 void MediaPlayerPrivateGStreamerBase::cdmInstanceAttached(CDMInstance& instance)
 {
-    ASSERT(!m_cdmInstance);
-    m_cdmInstance = &instance;
-    GST_DEBUG_OBJECT(pipeline(), "CDM instance %p set", m_cdmInstance.get());
-    m_protectionCondition.notifyAll();
+    if (m_cdmInstance != &instance) {
+        m_cdmInstance = &instance;
+        GST_DEBUG_OBJECT(pipeline(), "CDM instance %p set", m_cdmInstance.get());
+        m_protectionCondition.notifyAll();
+    }
 }
 
 void MediaPlayerPrivateGStreamerBase::cdmInstanceDetached(CDMInstance& instance)
@@ -1217,10 +1218,11 @@
 #ifdef NDEBUG
     UNUSED_PARAM(instance);
 #endif
-    ASSERT(m_cdmInstance.get() == &instance);
-    GST_DEBUG_OBJECT(pipeline(), "detaching CDM instance %p", m_cdmInstance.get());
-    m_cdmInstance = nullptr;
-    m_protectionCondition.notifyAll();
+    if (m_cdmInstance == &instance) {
+        GST_DEBUG_OBJECT(pipeline(), "detaching CDM instance %p", m_cdmInstance.get());
+        m_cdmInstance = nullptr;
+        m_protectionCondition.notifyAll();
+    }
 }
 
 void MediaPlayerPrivateGStreamerBase::attemptToDecryptWithInstance(CDMInstance& instance)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to