commit 1fc5c668d7985133a2653a2cef10d1ba2873c549
parent ebdea8824e24d8a6e6712db398e3efba652434df
Author: Andrew Osmond <aosmond@gmail.com>
Date: Mon, 1 Dec 2025 19:49:36 +0000
Bug 2001773 - Combine license request and resolving promise in MediaDrmRemoteCDMParent::RecvCreateSession. r=media-playback-reviewers,padenot
The gap between these messages is causing race conditions in the EME
state machine where we fail to issue the session update before we
attempt to start decrypting/decoding frames.
Differential Revision: https://phabricator.services.mozilla.com/D273704
Diffstat:
3 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/dom/media/eme/mediadrm/MediaDrmRemoteCDMParent.cpp b/dom/media/eme/mediadrm/MediaDrmRemoteCDMParent.cpp
@@ -514,9 +514,7 @@ mozilla::ipc::IPCResult MediaDrmRemoteCDMParent::RecvCreateSession(
NS_ConvertUTF8toUTF16 sessionIdStr(
reinterpret_cast<const char*>(sessionId.ptr), sessionId.length);
mSessions[sessionIdStr] = {sessionId, std::move(mimeType)};
- aResolver(std::move(sessionIdStr));
-
- (void)SendOnSessionKeyMessage(RemoteCDMKeyMessageIPDL(
+ aResolver(RemoteCDMKeyMessageIPDL(
std::move(sessionIdStr), MediaKeyMessageType::License_request,
nsTArray<uint8_t>(reinterpret_cast<const uint8_t*>(keyRequest),
keyRequestSize)));
diff --git a/dom/media/ipc/PRemoteCDM.ipdl b/dom/media/ipc/PRemoteCDM.ipdl
@@ -18,6 +18,31 @@ using mozilla::dom::MediaKeyStatus from "mozilla/dom/MediaKeyStatusMapBinding.h"
namespace mozilla {
+// For EME spec 'message' event
+// https://w3c.github.io/encrypted-media/#queue-message
+struct RemoteCDMKeyMessageIPDL
+{
+ nsString sessionId;
+ MediaKeyMessageType type;
+ uint8_t[] message;
+};
+
+// For EME spec 'keystatuseschange' event
+// https://w3c.github.io/encrypted-media/#dom-evt-keystatuseschange
+struct RemoteCDMKeyStatusIPDL
+{
+ nsString sessionId;
+ CDMKeyInfo[] keyInfo;
+};
+
+// For EME spec Update Expiration algorithm
+// https://w3c.github.io/encrypted-media/#update-expiration
+struct RemoteCDMKeyExpirationIPDL
+{
+ nsString sessionId;
+ double expiredTimeMilliSecondsSinceEpoch;
+};
+
struct RemoteCDMInitRequestIPDL
{
bool allowDistinctiveIdentifier;
@@ -46,7 +71,7 @@ struct RemoteCDMUpdateSessionRequestIPDL
union RemoteCDMSessionResponseIPDL
{
MediaResult;
- nsString;
+ RemoteCDMKeyMessageIPDL;
};
struct RemoteCDMProvisionRequestIPDL
@@ -61,31 +86,6 @@ union RemoteCDMProvisionResponseIPDL
uint8_t[];
};
-// For EME spec 'message' event
-// https://w3c.github.io/encrypted-media/#queue-message
-struct RemoteCDMKeyMessageIPDL
-{
- nsString sessionId;
- MediaKeyMessageType type;
- uint8_t[] message;
-};
-
-// For EME spec 'keystatuseschange' event
-// https://w3c.github.io/encrypted-media/#dom-evt-keystatuseschange
-struct RemoteCDMKeyStatusIPDL
-{
- nsString sessionId;
- CDMKeyInfo[] keyInfo;
-};
-
-// For EME spec Update Expiration algorithm
-// https://w3c.github.io/encrypted-media/#update-expiration
-struct RemoteCDMKeyExpirationIPDL
-{
- nsString sessionId;
- double expiredTimeMilliSecondsSinceEpoch;
-};
-
// This protocol provides a way to use CDMProxy across processes.
async protocol PRemoteCDM
{
diff --git a/dom/media/ipc/RemoteCDMChild.cpp b/dom/media/ipc/RemoteCDMChild.cpp
@@ -232,10 +232,12 @@ void RemoteCDMChild::CreateSession(uint32_t aCreateSessionToken,
return;
}
- const auto& sessionId = response.get_nsString();
+ const auto& msg = response.get_RemoteCDMKeyMessageIPDL();
+ const auto& sessionId = msg.sessionId();
if (RefPtr<dom::MediaKeySession> session =
self->mKeys->GetPendingSession(aCreateSessionToken)) {
session->SetSessionId(sessionId);
+ session->DispatchKeyMessage(msg.type(), msg.message());
}
self->ResolvePromise(aPromiseId);