Changeset 245756 in webkit


Ignore:
Timestamp:
May 24, 2019 3:13:02 PM (5 years ago)
Author:
david_quesada@apple.com
Message:

Crash under WebCore::TimerBase::~TimerBase after a download is canceled
https://bugs.webkit.org/show_bug.cgi?id=197927
rdar://problem/50822728

Reviewed by Ryosuke Niwa.

  • NetworkProcess/Downloads/cocoa/DownloadCocoa.mm:

(WebKit::Download::platformCancelNetworkLoad):

CFNetwork makes no guarantees about what thread is used to call the completion block
passed to -[NSURLSessionDownloadTask cancelByProducingResumeData], and in some cases,
it can be called on a background queue. This eventually causes the Download to be
deallocated on the background queue, which triggers a release assertion failure in
~TimerBase. When CFNetwork finishes canceling the download, we should move to the
main thread before calling didCancel().

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r245749 r245756  
     12019-05-24  David Quesada  <david_quesada@apple.com>
     2
     3        Crash under WebCore::TimerBase::~TimerBase after a download is canceled
     4        https://bugs.webkit.org/show_bug.cgi?id=197927
     5        rdar://problem/50822728
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * NetworkProcess/Downloads/cocoa/DownloadCocoa.mm:
     10        (WebKit::Download::platformCancelNetworkLoad):
     11            CFNetwork makes no guarantees about what thread is used to call the completion block
     12            passed to -[NSURLSessionDownloadTask cancelByProducingResumeData], and in some cases,
     13            it can be called on a background queue. This eventually causes the Download to be
     14            deallocated on the background queue, which triggers a release assertion failure in
     15            ~TimerBase. When CFNetwork finishes canceling the download, we should move to the
     16            main thread before calling didCancel().
     17
    1182019-05-24  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm

    r242339 r245756  
    8282    ASSERT(m_downloadTask);
    8383    [m_downloadTask cancelByProducingResumeData:^(NSData *resumeData) {
    84         if (resumeData && resumeData.bytes && resumeData.length)
    85             didCancel(IPC::DataReference(reinterpret_cast<const uint8_t*>(resumeData.bytes), resumeData.length));
    86         else
    87             didCancel({ });
     84        callOnMainThread([this, resumeData = retainPtr(resumeData)] {
     85            if (resumeData && resumeData.get().bytes && resumeData.get().length)
     86                didCancel(IPC::DataReference(reinterpret_cast<const uint8_t*>(resumeData.get().bytes), resumeData.get().length));
     87            else
     88                didCancel({ });
     89        });
    8890    }];
    8991}
Note: See TracChangeset for help on using the changeset viewer.