Changeset 239236 in webkit


Ignore:
Timestamp:
Dec 14, 2018 2:59:36 PM (5 years ago)
Author:
jer.noble@apple.com
Message:

CRASH in CDMInstanceSessionFairPlayStreamingAVFObjC::closeSession(WTF::String const&, WTF::Function<void ()>&&)
https://bugs.webkit.org/show_bug.cgi?id=192713
<rdar://problem/46739706>

Reviewed by Eric Carlson.

A callback is being called twice, and the second time has a null Promise. Instead of these
callbacks being WTF::Function, make them WTF::CompletionHandlers, which self-nullify and
have ASSERTS() that they are called once-and-only-once.

  • platform/encryptedmedia/CDMInstanceSession.h:
  • platform/encryptedmedia/clearkey/CDMClearKey.cpp:

(WebCore::CDMInstanceSessionClearKey::closeSession):

  • platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:

(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::closeSession):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRenewingRequest):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didFailToProvideRequest):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestDidSucceed):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239230 r239236  
     12018-12-14  Jer Noble  <jer.noble@apple.com>
     2
     3        CRASH in CDMInstanceSessionFairPlayStreamingAVFObjC::closeSession(WTF::String const&, WTF::Function<void ()>&&)
     4        https://bugs.webkit.org/show_bug.cgi?id=192713
     5        <rdar://problem/46739706>
     6
     7        Reviewed by Eric Carlson.
     8
     9        A callback is being called twice, and the second time has a null Promise. Instead of these
     10        callbacks being WTF::Function, make them WTF::CompletionHandlers, which self-nullify and
     11        have ASSERTS() that they are called once-and-only-once.
     12
     13        * platform/encryptedmedia/CDMInstanceSession.h:
     14        * platform/encryptedmedia/clearkey/CDMClearKey.cpp:
     15        (WebCore::CDMInstanceSessionClearKey::closeSession):
     16        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
     17        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::closeSession):
     18        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
     19        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRenewingRequest):
     20        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didFailToProvideRequest):
     21        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestDidSucceed):
     22
    1232018-12-14  David Kilzer  <ddkilzer@apple.com>
    224
  • trunk/Source/WebCore/platform/encryptedmedia/CDMInstanceSession.h

    r237649 r239236  
    3131#include "CDMMessageType.h"
    3232#include "CDMSessionType.h"
     33#include <wtf/CompletionHandler.h>
    3334#include <wtf/RefCounted.h>
    3435#include <wtf/Vector.h>
     
    6566    };
    6667
    67     using LicenseCallback = Function<void(Ref<SharedBuffer>&& message, const String& sessionId, bool needsIndividualization, SuccessValue succeeded)>;
     68    using LicenseCallback = CompletionHandler<void(Ref<SharedBuffer>&& message, const String& sessionId, bool needsIndividualization, SuccessValue succeeded)>;
    6869    virtual void requestLicense(LicenseType, const AtomicString& initDataType, Ref<SharedBuffer>&& initData, LicenseCallback&&) = 0;
    6970
    7071    using KeyStatusVector = CDMInstanceSessionClient::KeyStatusVector;
    7172    using Message = std::pair<MessageType, Ref<SharedBuffer>>;
    72     using LicenseUpdateCallback = Function<void(bool sessionWasClosed, std::optional<KeyStatusVector>&& changedKeys, std::optional<double>&& changedExpiration, std::optional<Message>&& message, SuccessValue succeeded)>;
     73    using LicenseUpdateCallback = CompletionHandler<void(bool sessionWasClosed, std::optional<KeyStatusVector>&& changedKeys, std::optional<double>&& changedExpiration, std::optional<Message>&& message, SuccessValue succeeded)>;
    7374    virtual void updateLicense(const String& sessionId, LicenseType, const SharedBuffer& response, LicenseUpdateCallback&&) = 0;
    7475
     
    8182    };
    8283
    83     using LoadSessionCallback = Function<void(std::optional<KeyStatusVector>&&, std::optional<double>&&, std::optional<Message>&&, SuccessValue, SessionLoadFailure)>;
     84    using LoadSessionCallback = CompletionHandler<void(std::optional<KeyStatusVector>&&, std::optional<double>&&, std::optional<Message>&&, SuccessValue, SessionLoadFailure)>;
    8485    virtual void loadSession(LicenseType, const String& sessionId, const String& origin, LoadSessionCallback&&) = 0;
    8586
    86     using CloseSessionCallback = Function<void()>;
     87    using CloseSessionCallback = CompletionHandler<void()>;
    8788    virtual void closeSession(const String& sessionId, CloseSessionCallback&&) = 0;
    8889
    89     using RemoveSessionDataCallback = Function<void(KeyStatusVector&&, std::optional<Ref<SharedBuffer>>&&, SuccessValue)>;
     90    using RemoveSessionDataCallback = CompletionHandler<void(KeyStatusVector&&, std::optional<Ref<SharedBuffer>>&&, SuccessValue)>;
    9091    virtual void removeSessionData(const String& sessionId, LicenseType, RemoveSessionDataCallback&&) = 0;
    9192
  • trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp

    r236317 r239236  
    677677{
    678678    callOnMainThread(
    679         [weakThis = makeWeakPtr(*this), callback = WTFMove(callback)] {
     679        [weakThis = makeWeakPtr(*this), callback = WTFMove(callback)] () mutable {
    680680            if (!weakThis)
    681681                return;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm

    r237649 r239236  
    429429    if (m_requestLicenseCallback) {
    430430        m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed);
    431         m_requestLicenseCallback = nullptr;
     431        ASSERT(!m_requestLicenseCallback);
    432432    }
    433433    if (m_updateLicenseCallback) {
    434434        m_updateLicenseCallback(true, std::nullopt, std::nullopt, std::nullopt, Failed);
    435         m_updateLicenseCallback = nullptr;
     435        ASSERT(!m_updateLicenseCallback);
    436436    }
    437437    if (m_removeSessionDataCallback) {
    438438        m_removeSessionDataCallback({ }, std::nullopt, Failed);
    439         m_removeSessionDataCallback = nullptr;
     439        ASSERT(!m_removeSessionDataCallback);
    440440    }
    441441    m_currentRequest = nullptr;
     
    517517        if (m_requestLicenseCallback) {
    518518            m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed);
    519             m_requestLicenseCallback = nullptr;
     519            ASSERT(!m_requestLicenseCallback);
    520520        }
    521521        return;
     
    534534            else if (m_client)
    535535                m_client->sendMessage(CDMMessageType::LicenseRequest, SharedBuffer::create(contentKeyRequestData.get()));
    536             m_requestLicenseCallback = nullptr;
     536            ASSERT(!m_requestLicenseCallback);
    537537        });
    538538    }];
     
    570570            else if (m_client)
    571571                m_client->sendMessage(CDMMessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get()));
    572             m_updateLicenseCallback = nullptr;
     572            ASSERT(!m_updateLicenseCallback);
    573573        });
    574574    }];
     
    584584    UNUSED_PARAM(request);
    585585    UNUSED_PARAM(error);
    586     if (m_updateLicenseCallback)
     586    if (m_updateLicenseCallback) {
    587587        m_updateLicenseCallback(false, std::nullopt, std::nullopt, std::nullopt, Failed);
     588        ASSERT(!m_updateLicenseCallback);
     589    }
    588590
    589591    m_currentRequest = nullptr;
     
    595597{
    596598    UNUSED_PARAM(request);
    597     if (m_updateLicenseCallback)
     599    if (m_updateLicenseCallback) {
    598600        m_updateLicenseCallback(false, std::make_optional(keyStatuses()), std::nullopt, std::nullopt, Succeeded);
     601        ASSERT(!m_updateLicenseCallback);
     602    }
    599603
    600604    m_currentRequest = nullptr;
Note: See TracChangeset for help on using the changeset viewer.