Bug 1900681 - Worker XHR self-manages XHRMT lifecycle. r=dom-worker-reviewers,smaug

We don't want the XHRMT to self-Abort() when the XHRWT state machine
is built assuming this doesn't happen.  This is likely the source of a
number of weird hangs and crashes we have hardened the implementation
against in the past, and potentially still some ongoing hangs and
weirdness.

Differential Revision: https://phabricator.services.mozilla.com/D212609
This commit is contained in:
Andrew Sutherland 2024-06-10 17:57:15 +00:00
parent ae55eb2a67
commit 546de62afb

View File

@ -469,7 +469,14 @@ NS_IMPL_RELEASE_INHERITED(XMLHttpRequestMainThread, XMLHttpRequestEventTarget)
void XMLHttpRequestMainThread::DisconnectFromOwner() {
XMLHttpRequestEventTarget::DisconnectFromOwner();
Abort();
// Worker-owned XHRs have their own complicated state machine that does not
// expect Abort() to be called here. The worker state machine cleanup will
// take care of ensuring the XHR is aborted in a timely fashion since the
// worker itself will inherently be canceled at the same time this is
// happening.
if (!mForWorker) {
Abort();
}
}
size_t XMLHttpRequestMainThread::SizeOfEventTargetIncludingThis(