[GStreamer] imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback...
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Jun 2020 12:06:44 +0000 (12:06 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Jun 2020 12:06:44 +0000 (12:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=213385

Reviewed by Philippe Normand.

Source/WebCore:

Add a way to release the decryption resources when the player
private is destroyed. That way we can release the secure memory
allocated by libgcrypt and allow for more tests to get, which
caused the crash.

Tests: imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-immediately.https.html.

* platform/encryptedmedia/CDMProxy.h:
(WebCore::CDMProxy::releaseDecryptionResources):
(WebCore::CDMInstanceSessionProxy::releaseDecryptionResources):
(WebCore::CDMInstanceProxy::releaseDecryptionResources):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
* platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp:
(WebCore::CDMProxyClearKey::~CDMProxyClearKey):
(WebCore::CDMProxyClearKey::releaseDecryptionResources):
(WebCore::CDMProxyClearKey::closeGCryptHandle):
* platform/graphics/gstreamer/eme/CDMProxyClearKey.h:

LayoutTests:

* platform/glib/TestExpectations: Removed test from expectations.

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

LayoutTests/ChangeLog
LayoutTests/platform/glib/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/encryptedmedia/CDMProxy.h
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp
Source/WebCore/platform/graphics/gstreamer/eme/CDMProxyClearKey.h

index 863790a..19c2588 100644 (file)
@@ -1,5 +1,14 @@
 2020-06-29  Xabier Rodriguez Calvar  <calvaris@igalia.com>
 
+        [GStreamer] imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-immediately.https.html is a flaky crash
+        https://bugs.webkit.org/show_bug.cgi?id=213385
+
+        Reviewed by Philippe Normand.
+
+        * platform/glib/TestExpectations: Removed test from expectations.
+
+2020-06-29  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
         [webkitpy] PHP7.4 support on Debian platforms
         https://bugs.webkit.org/show_bug.cgi?id=213721
 
index 7176ff8..0552b5a 100644 (file)
@@ -386,7 +386,6 @@ webkit.org/b/210965 imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4
 webkit.org/b/210966 imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-setmediakeys-again-after-playback.https.html [ Crash Pass ]
 webkit.org/b/178707 imported/w3c/web-platform-tests/encrypted-media/encrypted-media-default-feature-policy.https.sub.html [ Skip ]
 webkit.org/b/213364 imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-setmediakeys-to-multiple-video-elements.https.html [ Crash Pass ]
-webkit.org/b/213385 imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-immediately.https.html [ Crash Pass ]
 
 imported/w3c/web-platform-tests/encrypted-media/clearkey-check-encryption-scheme.https.html [ Pass ]
 imported/w3c/web-platform-tests/encrypted-media/clearkey-check-initdata-type.https.html [ Pass ]
index 0006ac0..2d5d5d8 100644 (file)
@@ -1,3 +1,29 @@
+2020-06-29  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        [GStreamer] imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-immediately.https.html is a flaky crash
+        https://bugs.webkit.org/show_bug.cgi?id=213385
+
+        Reviewed by Philippe Normand.
+
+        Add a way to release the decryption resources when the player
+        private is destroyed. That way we can release the secure memory
+        allocated by libgcrypt and allow for more tests to get, which
+        caused the crash.
+
+        Tests: imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-immediately.https.html.
+
+        * platform/encryptedmedia/CDMProxy.h:
+        (WebCore::CDMProxy::releaseDecryptionResources):
+        (WebCore::CDMInstanceSessionProxy::releaseDecryptionResources):
+        (WebCore::CDMInstanceProxy::releaseDecryptionResources):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
+        * platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp:
+        (WebCore::CDMProxyClearKey::~CDMProxyClearKey):
+        (WebCore::CDMProxyClearKey::releaseDecryptionResources):
+        (WebCore::CDMProxyClearKey::closeGCryptHandle):
+        * platform/graphics/gstreamer/eme/CDMProxyClearKey.h:
+
 2020-06-29  Alicia Boya GarcĂ­a  <aboya@igalia.com>
 
         [MSE][GStreamer] Rename MediaSourceGStreamer to MediaSourcePrivateGStreamer
index f2c3e34..a9e7bcd 100644 (file)
@@ -136,6 +136,12 @@ public:
     void updateKeyStore(const KeyStore& newKeyStore);
     void setInstance(CDMInstanceProxy*);
 
+    virtual void releaseDecryptionResources()
+    {
+        ASSERT(isMainThread());
+        m_keyStore.removeAllKeys();
+    }
+
 protected:
     Vector<uint8_t> keyValue(const Vector<uint8_t>& keyID) const;
     bool keyAvailable(const Vector<uint8_t>& keyID) const;
@@ -179,6 +185,8 @@ private:
 };
 
 class CDMInstanceSessionProxy : public CDMInstanceSession, public CanMakeWeakPtr<CDMInstanceSessionProxy, WeakPtrFactoryInitialization::Eager> {
+public:
+    virtual void releaseDecryptionResources() { }
 };
 
 // Base class for common session management code and for communicating messages
@@ -207,6 +215,19 @@ public:
     void startedWaitingForKey();
     void stoppedWaitingForKey();
 
+    virtual void releaseDecryptionResources()
+    {
+        ASSERT(isMainThread());
+        m_keyStore.removeAllKeys();
+        for (auto& session : m_sessions)
+            session.releaseDecryptionResources();
+        m_sessions.clear();
+        if (m_cdmProxy) {
+            m_cdmProxy->releaseDecryptionResources();
+            m_cdmProxy = nullptr;
+        }
+    }
+
 protected:
     void trackSession(const CDMInstanceSessionProxy&);
 
index dab32de..c20affc 100644 (file)
@@ -291,6 +291,14 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer()
     if (m_pipeline)
         gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);
 
+#if ENABLE(ENCRYPTED_MEDIA)
+    {
+        LockHolder lock(m_cdmAttachmentMutex);
+        if (m_cdmInstance)
+            m_cdmInstance->releaseDecryptionResources();
+    }
+#endif
+
     m_player = nullptr;
     m_notifier->invalidate();
 }
index 91d7b23..e7732ab 100644 (file)
@@ -84,8 +84,7 @@ bool CDMProxyFactoryClearKey::supportsKeySystem(const String& keySystem)
 
 CDMProxyClearKey::~CDMProxyClearKey()
 {
-    if (m_gCryptHandle)
-        gcry_cipher_close(*m_gCryptHandle);
+    closeGCryptHandle();
 }
 
 bool CDMProxyClearKey::cencSetCounterVector(const cencDecryptContext& input)
@@ -213,6 +212,20 @@ bool CDMProxyClearKey::cencDecrypt(CDMProxyClearKey::cencDecryptContext& input)
     return input.isSubsampled() ? cencDecryptSubsampled(input) : cencDecryptFullSample(input);
 }
 
+void CDMProxyClearKey::releaseDecryptionResources()
+{
+    closeGCryptHandle();
+    CDMProxy::releaseDecryptionResources();
+}
+
+void CDMProxyClearKey::closeGCryptHandle()
+{
+    if (m_gCryptHandle) {
+        gcry_cipher_close(*m_gCryptHandle);
+        m_gCryptHandle.reset();
+    }
+}
+
 gcry_cipher_hd_t& CDMProxyClearKey::gCryptHandle()
 {
     if (!m_gCryptHandle) {
index 6f93d7a..1e6b224 100644 (file)
@@ -111,6 +111,9 @@ private:
     bool cencDecryptFullSample(cencDecryptContext&);
     bool cencDecryptSubsampled(cencDecryptContext&);
 
+    void releaseDecryptionResources() final;
+    void closeGCryptHandle();
+
     // FIXME: It would be nice to use something in WebCore for crypto...
     Optional<gcry_cipher_hd_t> m_gCryptHandle { WTF::nullopt };
 };