Bug 227821 - Revoking Blob URL after calling XMLHttpRequest::open() causes the XHR to fail
Summary: Revoking Blob URL after calling XMLHttpRequest::open() causes the XHR to fail
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-07-08 16:13 PDT by Chris Dumez
Modified: 2021-08-09 14:06 PDT (History)
9 users (show)

See Also:


Attachments
Patch (15.00 KB, patch)
2021-07-08 16:20 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (14.96 KB, patch)
2021-07-09 14:23 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (14.96 KB, patch)
2021-07-09 14:25 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-07-08 16:13:15 PDT
Revoking Blob URL after calling XMLHttpRequest::open() causes the XHR to fail. This doesn't match the behavior of other browsers and is causing WebKit to fail one of the subtests on:
- http://wpt.live/FileAPI/url/url-with-xhr.any.html
Comment 1 Chris Dumez 2021-07-08 16:20:37 PDT
Created attachment 433182 [details]
Patch
Comment 2 youenn fablet 2021-07-09 13:38:55 PDT
Comment on attachment 433182 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=433182&action=review

> Source/WebCore/xml/XMLHttpRequest.cpp:121
> +    , m_url(makeUniqueRef<BlobURLLifeTimeExtender>())

We are doing an allocation for no good reason here.
I think it would look better if we had a separate BlobURLLifeTimeExtender that can happen to be null if URL is not a blob.
Also, we could probably try to nullify the blob life time extender as soon as we do not need it, maybe when clearing the request for instance.

> Source/WebCore/xml/XMLHttpRequest.h:219
> +    UniqueRef<BlobURLLifeTimeExtender> m_url;

It is a bit odd for BlobURLLifeTimeExtender to be called m_url.
Comment 3 Chris Dumez 2021-07-09 13:41:27 PDT
(In reply to youenn fablet from comment #2)
> Comment on attachment 433182 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=433182&action=review
> 
> > Source/WebCore/xml/XMLHttpRequest.cpp:121
> > +    , m_url(makeUniqueRef<BlobURLLifeTimeExtender>())
> 
> We are doing an allocation for no good reason here.
> I think it would look better if we had a separate BlobURLLifeTimeExtender
> that can happen to be null if URL is not a blob.
> Also, we could probably try to nullify the blob life time extender as soon
> as we do not need it, maybe when clearing the request for instance.

I initially had a separate data member to extend the lifetime of the blob URL. However, this is error prone and we need to make sure we update it whenever m_url gets updated.

> > Source/WebCore/xml/XMLHttpRequest.h:219
> > +    UniqueRef<BlobURLLifeTimeExtender> m_url;
> 
> It is a bit odd for BlobURLLifeTimeExtender to be called m_url.

Sure, we can rename it but it does store a URL.
Comment 4 Chris Dumez 2021-07-09 14:00:11 PDT
(In reply to Chris Dumez from comment #3)
> (In reply to youenn fablet from comment #2)
> > Comment on attachment 433182 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=433182&action=review
> > 
> > > Source/WebCore/xml/XMLHttpRequest.cpp:121
> > > +    , m_url(makeUniqueRef<BlobURLLifeTimeExtender>())
> > 
> > We are doing an allocation for no good reason here.
> > I think it would look better if we had a separate BlobURLLifeTimeExtender
> > that can happen to be null if URL is not a blob.
> > Also, we could probably try to nullify the blob life time extender as soon
> > as we do not need it, maybe when clearing the request for instance.
> 
> I initially had a separate data member to extend the lifetime of the blob
> URL. However, this is error prone and we need to make sure we update it
> whenever m_url gets updated.
> 
> > > Source/WebCore/xml/XMLHttpRequest.h:219
> > > +    UniqueRef<BlobURLLifeTimeExtender> m_url;
> > 
> > It is a bit odd for BlobURLLifeTimeExtender to be called m_url.
> 
> Sure, we can rename it but it does store a URL.

Maybe if I rename BlobURLLifeTimeExtender to URLWithBlobURLLifetimeExtension and add an assignment operator, then it will be clearer?
Comment 5 Chris Dumez 2021-07-09 14:23:08 PDT
Created attachment 433239 [details]
Patch
Comment 6 Chris Dumez 2021-07-09 14:25:45 PDT
Created attachment 433240 [details]
Patch
Comment 7 EWS 2021-07-13 12:18:58 PDT
Committed r279881 (239633@main): <https://commits.webkit.org/239633@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 433240 [details].
Comment 8 Radar WebKit Bug Importer 2021-07-13 12:19:18 PDT
<rdar://problem/80531744>