Changeset 259080 in webkit


Ignore:
Timestamp:
Mar 26, 2020 2:33:33 PM (4 years ago)
Author:
Chris Dumez
Message:

[ Mac wk1] ASSERTION FAILED: m_wrapper under WebCore::XMLHttpRequestUpload::dispatchProgressEvent
https://bugs.webkit.org/show_bug.cgi?id=209560
<rdar://problem/60887773>

Reviewed by Geoffrey Garen.

XMLHttpRequest::hasPendingActivity() was returning false if the XMLHttpRequest object did not
have any relevant event listeners. However, the XMLHttpRequestUpload's wrapper lifetime is tried
to the lifetime of its XMLHttpRequest wrapper. As a result, both the XMLHttpRequest and
XMLHttpRequestUpload wrappers could get garbage collected if the XMLHttpRequest did not have a
relevant listener, even though XMLHttpRequestUpload may have a relevant event listeners. We would
then hit the assertion when trying to fire an event on this XMLHttpRequestUpload object.

To address the issue, we update XMLHttpRequest::hasPendingActivity() to return false if both
XMLHttpRequest AND XMLHttpRequestUpload have no relevant event listeners.

No new tests, covered by imported/w3c/web-platform-tests/xhr/send-response-upload-event-progress.htm

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::hasPendingActivity const):

  • xml/XMLHttpRequestUpload.cpp:

(WebCore::XMLHttpRequestUpload::eventListenersDidChange):

  • xml/XMLHttpRequestUpload.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259079 r259080  
     12020-03-26  Chris Dumez  <cdumez@apple.com>
     2
     3        [ Mac wk1] ASSERTION FAILED: m_wrapper under WebCore::XMLHttpRequestUpload::dispatchProgressEvent
     4        https://bugs.webkit.org/show_bug.cgi?id=209560
     5        <rdar://problem/60887773>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        XMLHttpRequest::hasPendingActivity() was returning false if the XMLHttpRequest object did not
     10        have any relevant event listeners. However, the XMLHttpRequestUpload's wrapper lifetime is tried
     11        to the lifetime of its XMLHttpRequest wrapper. As a result, both the XMLHttpRequest and
     12        XMLHttpRequestUpload wrappers could get garbage collected if the XMLHttpRequest did not have a
     13        relevant listener, even though XMLHttpRequestUpload may have a relevant event listeners. We would
     14        then hit the assertion when trying to fire an event on this XMLHttpRequestUpload object.
     15
     16        To address the issue, we update XMLHttpRequest::hasPendingActivity() to return false if both
     17        XMLHttpRequest AND XMLHttpRequestUpload have no relevant event listeners.
     18
     19        No new tests, covered by imported/w3c/web-platform-tests/xhr/send-response-upload-event-progress.htm
     20
     21        * xml/XMLHttpRequest.cpp:
     22        (WebCore::XMLHttpRequest::hasPendingActivity const):
     23        * xml/XMLHttpRequestUpload.cpp:
     24        (WebCore::XMLHttpRequestUpload::eventListenersDidChange):
     25        * xml/XMLHttpRequestUpload.h:
     26
    1272020-03-26  Ryosuke Niwa  <rniwa@webkit.org>
    228
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r258866 r259080  
    11831183        return true;
    11841184
    1185     if (!m_hasRelevantEventListener)
     1185    if (!m_hasRelevantEventListener && !(m_upload && m_upload->hasRelevantEventListener()))
    11861186        return false;
    11871187
  • trunk/Source/WebCore/xml/XMLHttpRequestUpload.cpp

    r246490 r259080  
    4242}
    4343
     44void XMLHttpRequestUpload::eventListenersDidChange()
     45{
     46    m_hasRelevantEventListener = hasEventListeners(eventNames().abortEvent)
     47        || hasEventListeners(eventNames().errorEvent)
     48        || hasEventListeners(eventNames().loadEvent)
     49        || hasEventListeners(eventNames().loadendEvent)
     50        || hasEventListeners(eventNames().loadstartEvent)
     51        || hasEventListeners(eventNames().progressEvent)
     52        || hasEventListeners(eventNames().timeoutEvent);
     53}
     54
    4455void XMLHttpRequestUpload::dispatchProgressEvent(const AtomString& type, unsigned long long loaded, unsigned long long total)
    4556{
  • trunk/Source/WebCore/xml/XMLHttpRequestUpload.h

    r246490 r259080  
    4141    void dispatchProgressEvent(const AtomString& type, unsigned long long loaded, unsigned long long total);
    4242
     43    bool hasRelevantEventListener() const { return m_hasRelevantEventListener; }
     44
    4345private:
     46    // EventTarget.
     47    void eventListenersDidChange() final;
    4448    void refEventTarget() final { ref(); }
    4549    void derefEventTarget() final { deref(); }
     
    4953
    5054    XMLHttpRequest& m_request;
     55    bool m_hasRelevantEventListener { false };
    5156};
    5257   
Note: See TracChangeset for help on using the changeset viewer.