Changeset 252008 in webkit


Ignore:
Timestamp:
Nov 4, 2019 12:58:52 PM (4 years ago)
Author:
Truitt Savell
Message:

Unreviewed, rolling out r251993.

Broke platform/mac/media/encrypted-media/fps-
generateRequest.html on Mojave+

Reverted changeset:

"MediaKeySession / WebKitMediaKeySession should not prevent
entering the back/forward cache"
https://bugs.webkit.org/show_bug.cgi?id=203089
https://trac.webkit.org/changeset/251993

Location:
trunk
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r252003 r252008  
     12019-11-04  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r251993.
     4
     5        Broke platform/mac/media/encrypted-media/fps-
     6        generateRequest.html on Mojave+
     7
     8        Reverted changeset:
     9
     10        "MediaKeySession / WebKitMediaKeySession should not prevent
     11        entering the back/forward cache"
     12        https://bugs.webkit.org/show_bug.cgi?id=203089
     13        https://trac.webkit.org/changeset/251993
     14
    1152019-11-04  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r252007 r252008  
     12019-11-04  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r251993.
     4
     5        Broke platform/mac/media/encrypted-media/fps-
     6        generateRequest.html on Mojave+
     7
     8        Reverted changeset:
     9
     10        "MediaKeySession / WebKitMediaKeySession should not prevent
     11        entering the back/forward cache"
     12        https://bugs.webkit.org/show_bug.cgi?id=203089
     13        https://trac.webkit.org/changeset/251993
     14
    1152019-11-04  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp

    r251993 r252008  
    3232#if ENABLE(ENCRYPTED_MEDIA)
    3333
    34 #include "AbstractEventLoop.h"
    3534#include "CDM.h"
    3635#include "CDMInstance.h"
     
    7271    , m_implementation(WTFMove(implementation))
    7372    , m_instanceSession(WTFMove(instanceSession))
     73    , m_eventQueue(MainThreadGenericEventQueue::create(*this))
    7474{
    7575    // https://w3c.github.io/encrypted-media/#dom-mediakeys-createsession
     
    158158    // 9. Let promise be a new promise.
    159159    // 10. Run the following steps in parallel:
    160     enqueueTask([this, initData = SharedBuffer::create(initData.data(), initData.length()), initDataType, promise = WTFMove(promise)] () mutable {
     160    m_taskQueue.enqueueTask([this, initData = SharedBuffer::create(initData.data(), initData.length()), initDataType, promise = WTFMove(promise)] () mutable {
    161161        // 10.1. If the init data is not valid for initDataType, reject promise with a newly created TypeError.
    162162        // 10.2. Let sanitized init data be a validated and sanitized version of init data.
     
    227227
    228228            // 10.10. Queue a task to run the following steps:
    229             enqueueTask([this, promise = WTFMove(promise), message = WTFMove(message), messageType, sessionId, succeeded] () mutable {
     229            m_taskQueue.enqueueTask([this, promise = WTFMove(promise), message = WTFMove(message), messageType, sessionId, succeeded] () mutable {
    230230                // 10.10.1. If any of the preceding steps failed, reject promise with a new DOMException whose name is the appropriate error name.
    231231                if (succeeded == CDMInstanceSession::SuccessValue::Failed) {
     
    278278    // 7. Let promise be a new promise.
    279279    // 8. Run the following steps in parallel:
    280     enqueueTask([this, sessionId, promise = WTFMove(promise)] () mutable {
     280    m_taskQueue.enqueueTask([this, sessionId, promise = WTFMove(promise)] () mutable {
    281281        // 8.1. Let sanitized session ID be a validated and/or sanitized version of sessionId.
    282282        // 8.2. If the preceding step failed, or if sanitized session ID is empty, reject promise with a newly created TypeError.
     
    330330
    331331            // 8.9. Queue a task to run the following steps:
    332             enqueueTask([this, knownKeys = WTFMove(knownKeys), expiration = WTFMove(expiration), message = WTFMove(message), sanitizedSessionId, succeeded, promise = WTFMove(promise)] () mutable {
     332            m_taskQueue.enqueueTask([this, knownKeys = WTFMove(knownKeys), expiration = WTFMove(expiration), message = WTFMove(message), sanitizedSessionId, succeeded, promise = WTFMove(promise)] () mutable {
    333333                // 8.9.1. If any of the preceding steps failed, reject promise with a the appropriate error name.
    334334                if (succeeded == CDMInstanceSession::SuccessValue::Failed) {
     
    387387    // 5. Let promise be a new promise.
    388388    // 6. Run the following steps in parallel:
    389     enqueueTask([this, response = SharedBuffer::create(response.data(), response.length()), promise = WTFMove(promise)] () mutable {
     389    m_taskQueue.enqueueTask([this, response = SharedBuffer::create(response.data(), response.length()), promise = WTFMove(promise)] () mutable {
    390390        // 6.1. Let sanitized response be a validated and/or sanitized version of response copy.
    391391        RefPtr<SharedBuffer> sanitizedResponse = m_implementation->sanitizeResponse(response);
     
    438438            //   6.7.3.2. Let message type be the appropriate MediaKeyMessageType for the message.
    439439            // 6.8. Queue a task to run the following steps:
    440             enqueueTask([this, sessionWasClosed, changedKeys = WTFMove(changedKeys), changedExpiration = WTFMove(changedExpiration), message = WTFMove(message), promise = WTFMove(promise)] () mutable {
     440            m_taskQueue.enqueueTask([this, sessionWasClosed, changedKeys = WTFMove(changedKeys), changedExpiration = WTFMove(changedExpiration), message = WTFMove(message), promise = WTFMove(promise)] () mutable {
    441441                LOG(EME, "EME - updating CDM license succeeded for session %s, sending a message to the license server", m_sessionId.utf8().data());
    442442                // 6.8.1.
     
    515515    // 4. Let promise be a new promise.
    516516    // 5. Run the following steps in parallel:
    517     enqueueTask([this, promise = WTFMove(promise)] () mutable {
     517    m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
    518518        // 5.1. Let cdm be the CDM instance represented by session's cdm instance value.
    519519        // 5.2. Use cdm to close the key session associated with session.
     
    524524
    525525            // 5.3. Queue a task to run the following steps:
    526             enqueueTask([this, promise = WTFMove(promise)] () mutable {
     526            m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
    527527                // 5.3.1. Run the Session Closed algorithm on the session.
    528528                sessionClosed();
     
    553553    // 3. Let promise be a new promise.
    554554    // 4. Run the following steps in parallel:
    555     enqueueTask([this, promise = WTFMove(promise)] () mutable {
     555    m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
    556556        // 4.1. Let cdm be the CDM instance represented by this object's cdm instance value.
    557557        // 4.2. Let message be null.
     
    578578
    579579            // 4.5. Queue a task to run the following steps:
    580             enqueueTask([this, keys = WTFMove(keys), message = WTFMove(message), succeeded, promise = WTFMove(promise)] () mutable {
     580            m_taskQueue.enqueueTask([this, keys = WTFMove(keys), message = WTFMove(message), succeeded, promise = WTFMove(promise)] () mutable {
    581581                // 4.5.1. Run the Update Key Statuses algorithm on the session, providing all key ID(s) in the session along with the "released" MediaKeyStatus value for each.
    582582                updateKeyStatuses(WTFMove(keys));
     
    617617    //    session.
    618618    auto messageEvent = MediaKeyMessageEvent::create(eventNames().messageEvent, {messageType, message.tryCreateArrayBuffer()}, Event::IsTrusted::Yes);
    619     enqueueEvent(WTFMove(messageEvent));
     619    m_eventQueue->enqueueEvent(WTFMove(messageEvent));
    620620}
    621621
     
    662662
    663663    // 5. Queue a task to fire a simple event named keystatuseschange at the session.
    664     enqueueEvent(Event::create(eventNames().keystatuseschangeEvent, Event::CanBubble::No, Event::IsCancelable::No));
     664    m_eventQueue->enqueueEvent(Event::create(eventNames().keystatuseschangeEvent, Event::CanBubble::No, Event::IsCancelable::No));
    665665
    666666    // 6. Queue a task to run the Attempt to Resume Playback If Necessary algorithm on each of the media element(s) whose mediaKeys attribute is the MediaKeys object that created the session.
    667     enqueueTask(
     667    m_taskQueue.enqueueTask(
    668668        [this] () mutable {
    669669            if (m_keys)
     
    734734bool MediaKeySession::hasPendingActivity() const
    735735{
    736     // A MediaKeySession object SHALL NOT be destroyed and SHALL continue to receive events if it is not closed and the MediaKeys object that created it remains accessible.
    737     return (!m_closed && m_keys) || ActiveDOMObject::hasPendingActivity();
     736    notImplemented();
     737    return false;
    738738}
    739739
    740740const char* MediaKeySession::activeDOMObjectName() const
    741741{
     742    notImplemented();
    742743    return "MediaKeySession";
    743744}
    744745
    745 void MediaKeySession::enqueueTask(Function<void()>&& task)
    746 {
    747     auto* context = scriptExecutionContext();
    748     if (!context)
    749         return;
    750 
    751     context->eventLoop().queueTask(TaskSource::Networking, *context, [pendingActivity = makePendingActivity(*this), task = WTFMove(task)] {
    752         task();
    753     });
    754 }
    755 
    756 void MediaKeySession::enqueueEvent(Ref<Event>&& event)
    757 {
    758     auto* context = scriptExecutionContext();
    759     if (!context)
    760         return;
    761 
    762     context->eventLoop().queueTask(TaskSource::Networking, *context, [this, pendingActivity = makePendingActivity(*this), event = WTFMove(event)]() mutable {
    763         dispatchEvent(WTFMove(event));
    764     });
     746// FIXME: This should never prevent entering the back/forward cache.
     747bool MediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED() const
     748{
     749    notImplemented();
     750    return true;
     751}
     752
     753void MediaKeySession::stop()
     754{
     755    notImplemented();
    765756}
    766757
  • trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h

    r251993 r252008  
    3434#include "CDMInstanceSession.h"
    3535#include "EventTarget.h"
     36#include "GenericEventQueue.h"
     37#include "GenericTaskQueue.h"
    3638#include "IDLTypes.h"
    3739#include "MediaKeyMessageType.h"
     
    3941#include "MediaKeyStatus.h"
    4042#include <wtf/RefCounted.h>
    41 #include <wtf/UniqueRef.h>
    4243#include <wtf/Vector.h>
    4344#include <wtf/WeakPtr.h>
     
    9192    String mediaKeysStorageDirectory() const;
    9293
    93     void enqueueTask(Function<void()>&&);
    94     void enqueueEvent(Ref<Event>&&);
    95 
    9694    // CDMInstanceSessionClient
    9795    void updateKeyStatuses(CDMInstanceSessionClient::KeyStatusVector&&) override;
     
    107105    // ActiveDOMObject
    108106    const char* activeDOMObjectName() const override;
     107    bool shouldPreventEnteringBackForwardCache_DEPRECATED() const override;
     108    void stop() override;
    109109
    110110    WeakPtr<MediaKeys> m_keys;
     
    120120    Ref<CDM> m_implementation;
    121121    Ref<CDMInstanceSession> m_instanceSession;
     122    UniqueRef<MainThreadGenericEventQueue> m_eventQueue;
     123    GenericTaskQueue<Timer> m_taskQueue;
    122124    Vector<Ref<SharedBuffer>> m_recordOfKeyUsage;
    123125    double m_firstDecryptTime { 0 };
  • trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp

    r251993 r252008  
    2929#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
    3030
    31 #include "AbstractEventLoop.h"
    3231#include "Document.h"
    3332#include "EventNames.h"
     
    5655    , m_keys(&keys)
    5756    , m_keySystem(keySystem)
     57    , m_asyncEventQueue(MainThreadGenericEventQueue::create(*this))
    5858    , m_session(keys.cdm().createSession(*this))
    5959    , m_keyRequestTimer(*this, &WebKitMediaKeySession::keyRequestTimerFired)
     
    6868    if (m_session)
    6969        m_session->setClient(nullptr);
     70
     71    m_asyncEventQueue->cancelAllEvents();
    7072}
    7173
     
    182184            auto keyaddedEvent = Event::create(eventNames().webkitkeyaddedEvent, Event::CanBubble::No, Event::IsCancelable::No);
    183185            keyaddedEvent->setTarget(this);
    184             enqueueEvent(WTFMove(keyaddedEvent));
     186            m_asyncEventQueue->enqueueEvent(WTFMove(keyaddedEvent));
    185187
    186188            ASSERT(m_keys);
     
    206208    auto event = WebKitMediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, message, destinationURL);
    207209    event->setTarget(this);
    208     enqueueEvent(WTFMove(event));
     210    m_asyncEventQueue->enqueueEvent(WTFMove(event));
    209211}
    210212
     
    215217    auto keyerrorEvent = Event::create(eventNames().webkitkeyerrorEvent, Event::CanBubble::No, Event::IsCancelable::No);
    216218    keyerrorEvent->setTarget(this);
    217     enqueueEvent(WTFMove(keyerrorEvent));
     219    m_asyncEventQueue->enqueueEvent(WTFMove(keyerrorEvent));
    218220}
    219221
     
    237239bool WebKitMediaKeySession::hasPendingActivity() const
    238240{
    239     return (m_keys && m_session) || ActiveDOMObject::hasPendingActivity();
     241    return (m_keys && m_session) || m_asyncEventQueue->hasPendingEvents();
    240242}
    241243
     
    250252}
    251253
    252 void WebKitMediaKeySession::enqueueEvent(Ref<Event>&& event)
    253 {
    254     auto* context = scriptExecutionContext();
    255     if (!context)
    256         return;
    257 
    258     context->eventLoop().queueTask(TaskSource::Networking, *context, [this, pendingActivity = makePendingActivity(*this), event = WTFMove(event)]() mutable {
    259         dispatchEvent(WTFMove(event));
    260     });
     254bool WebKitMediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED() const
     255{
     256    // FIXME: This should never prevent entering the back/forward cache.
     257    return true;
    261258}
    262259
  • trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.h

    r251993 r252008  
    3131#include "EventTarget.h"
    3232#include "ExceptionOr.h"
     33#include "GenericEventQueue.h"
    3334#include "LegacyCDMSession.h"
    3435#include "Timer.h"
     
    4142class WebKitMediaKeys;
    4243
    43 class WebKitMediaKeySession final : public RefCounted<WebKitMediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, private LegacyCDMSessionClient {
     44class WebKitMediaKeySession final : public RefCounted<WebKitMediaKeySession>, public EventTargetWithInlineData, private ActiveDOMObject, private LegacyCDMSessionClient {
    4445    WTF_MAKE_ISO_ALLOCATED(WebKitMediaKeySession);
    4546public:
     
    7475    String mediaKeysStorageDirectory() const final;
    7576
    76     void enqueueEvent(Ref<Event>&&);
    77 
    7877    void refEventTarget() final { ref(); }
    7978    void derefEventTarget() final { deref(); }
    8079
    8180    void stop() final;
     81    bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final;
    8282    const char* activeDOMObjectName() const final;
    8383
     
    8989    String m_sessionId;
    9090    RefPtr<WebKitMediaKeyError> m_error;
     91    UniqueRef<MainThreadGenericEventQueue> m_asyncEventQueue;
    9192    std::unique_ptr<LegacyCDMSession> m_session;
    9293
Note: See TracChangeset for help on using the changeset viewer.