Changeset 247239 in webkit


Ignore:
Timestamp:
Jul 8, 2019 4:56:45 PM (5 years ago)
Author:
Chris Dumez
Message:

Make Document::postTask() safe to call from a background thread
https://bugs.webkit.org/show_bug.cgi?id=199585

Reviewed by Alex Christensen.

Make Document::postTask() safe to call from a background thread by not calling makeWeakPtr() on the Document.
Calling makeWeakPtr() on a document from a background thread is not safe since Document is a main thread
object. Instead, capture Document::identifier() in the lambda and lookup the document from its identifier
once we're on the main thread.

  • dom/Document.cpp:

(WebCore::Document::postTask):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247238 r247239  
     12019-07-08  Chris Dumez  <cdumez@apple.com>
     2
     3        Make Document::postTask() safe to call from a background thread
     4        https://bugs.webkit.org/show_bug.cgi?id=199585
     5
     6        Reviewed by Alex Christensen.
     7
     8        Make Document::postTask() safe to call from a background thread by not calling makeWeakPtr() on the Document.
     9        Calling makeWeakPtr() on a document from a background thread is not safe since Document is a main thread
     10        object. Instead, capture Document::identifier() in the lambda and lookup the document from its identifier
     11        once we're on the main thread.
     12
     13        * dom/Document.cpp:
     14        (WebCore::Document::postTask):
     15
    1162019-07-08  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/Source/WebCore/dom/Document.cpp

    r247222 r247239  
    61216121void Document::postTask(Task&& task)
    61226122{
    6123     callOnMainThread([documentReference = makeWeakPtr(*this), task = WTFMove(task)]() mutable {
     6123    callOnMainThread([documentID = identifier(), task = WTFMove(task)]() mutable {
    61246124        ASSERT(isMainThread());
    61256125
    6126         Document* document = documentReference.get();
     6126        auto* document = allDocumentsMap().get(documentID);
    61276127        if (!document)
    61286128            return;
Note: See TracChangeset for help on using the changeset viewer.