Changeset 252878 in webkit


Ignore:
Timestamp:
Nov 26, 2019 12:30:42 AM (4 years ago)
Author:
youenn@apple.com
Message:

Queuing a task in EventLoop is not working with UserMediaRequest allow completion handler
Queuing a task in EventLoop is not working with completion handlers
https://bugs.webkit.org/show_bug.cgi?id=204565
<rdar://problem/57466280>

Reviewed by Ryosuke Niwa.

Do not capture the completion handler in lambda passed to the event queue.
Instead, keep it in UserMediqRequest and call it either when running the task or when destroying UserMediaRequest.
Covered by existing tests failing the debug assertion.

  • Modules/mediastream/UserMediaRequest.cpp:

(WebCore::UserMediaRequest::~UserMediaRequest):
(WebCore::UserMediaRequest::allow):

  • Modules/mediastream/UserMediaRequest.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252875 r252878  
     12019-11-26  youenn fablet  <youenn@apple.com>
     2
     3        Queuing a task in EventLoop is not working with UserMediaRequest allow completion handler
     4        Queuing a task in EventLoop is not working with completion handlers
     5        https://bugs.webkit.org/show_bug.cgi?id=204565
     6        <rdar://problem/57466280>
     7
     8        Reviewed by Ryosuke Niwa.
     9
     10        Do not capture the completion handler in lambda passed to the event queue.
     11        Instead, keep it in UserMediqRequest and call it either when running the task or when destroying UserMediaRequest.
     12        Covered by existing tests failing the debug assertion.
     13
     14        * Modules/mediastream/UserMediaRequest.cpp:
     15        (WebCore::UserMediaRequest::~UserMediaRequest):
     16        (WebCore::UserMediaRequest::allow):
     17        * Modules/mediastream/UserMediaRequest.h:
     18
    1192019-11-25  Yusuke Suzuki  <ysuzuki@apple.com>
    220
  • trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp

    r252497 r252878  
    6868}
    6969
    70 UserMediaRequest::~UserMediaRequest() = default;
     70UserMediaRequest::~UserMediaRequest()
     71{
     72    if (m_allowCompletionHandler)
     73        m_allowCompletionHandler();
     74}
    7175
    7276SecurityOrigin* UserMediaRequest::userMediaDocumentOrigin() const
     
    231235{
    232236    RELEASE_LOG(MediaStream, "UserMediaRequest::allow %s %s", audioDevice ? audioDevice.persistentId().utf8().data() : "", videoDevice ? videoDevice.persistentId().utf8().data() : "");
    233 
    234     queueTaskKeepingObjectAlive(*this, TaskSource::UserInteraction, [this, audioDevice = WTFMove(audioDevice), videoDevice = WTFMove(videoDevice), deviceIdentifierHashSalt = WTFMove(deviceIdentifierHashSalt), completionHandler = WTFMove(completionHandler)]() mutable {
    235         auto callback = [this, protector = makePendingActivity(*this), completionHandler = WTFMove(completionHandler)](RefPtr<MediaStreamPrivate>&& privateStream) mutable {
    236             auto scopeExit = makeScopeExit([completionHandler = WTFMove(completionHandler)]() mutable {
     237    m_allowCompletionHandler = WTFMove(completionHandler);
     238    queueTaskKeepingObjectAlive(*this, TaskSource::UserInteraction, [this, audioDevice = WTFMove(audioDevice), videoDevice = WTFMove(videoDevice), deviceIdentifierHashSalt = WTFMove(deviceIdentifierHashSalt)]() mutable {
     239        auto callback = [this, protector = makePendingActivity(*this)](RefPtr<MediaStreamPrivate>&& privateStream) mutable {
     240            auto scopeExit = makeScopeExit([completionHandler = WTFMove(m_allowCompletionHandler)]() mutable {
    237241                completionHandler();
    238242            });
  • trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.h

    r251746 r252878  
    9595
    9696    UniqueRef<DOMPromiseDeferred<IDLInterface<MediaStream>>> m_promise;
     97    CompletionHandler<void()> m_allowCompletionHandler;
    9798    MediaStreamRequest m_request;
    9899};
Note: See TracChangeset for help on using the changeset viewer.