WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
230278
Use ObjectIdentifier for ResourceLoader
https://bugs.webkit.org/show_bug.cgi?id=230278
Summary
Use ObjectIdentifier for ResourceLoader
Michael Catanzaro
Reported
2021-09-14 15:00:38 PDT
Use ObjectIdentifier for URL scheme handlers and tasks: WebURLSchemeTask, WebURLSchemeTaskProxy, and WebURLSchemeHandler This patch is not ready quite yet because it currently conflicts with the patch in
bug #229116
. I'll refresh it after the patch in
bug #229116
lands.
Attachments
Patch
(53.64 KB, patch)
2021-09-14 15:14 PDT
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
Patch
(57.30 KB, patch)
2021-09-14 15:16 PDT
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
Patch
(57.58 KB, patch)
2021-09-15 13:09 PDT
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
Patch
(48.61 KB, patch)
2021-09-15 14:48 PDT
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
Patch
(356.12 KB, patch)
2021-09-16 13:39 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(5.93 MB, patch)
2021-09-17 11:18 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(362.59 KB, patch)
2021-09-17 12:39 PDT
,
Alex Christensen
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(368.60 KB, patch)
2021-09-17 13:44 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(368.00 KB, patch)
2021-09-17 15:23 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(366.95 KB, patch)
2021-09-17 15:43 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Show Obsolete
(9)
View All
Add attachment
proposed patch, testcase, etc.
Michael Catanzaro
Comment 1
2021-09-14 15:14:40 PDT
Created
attachment 438177
[details]
Patch
EWS Watchlist
Comment 2
2021-09-14 15:15:43 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See
https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Michael Catanzaro
Comment 3
2021-09-14 15:16:30 PDT
Created
attachment 438178
[details]
Patch
Michael Catanzaro
Comment 4
2021-09-14 15:34:15 PDT
Looks like I have some build errors to fix. It looks like release logs are not enabled for GTK/WPE release builds, because these look like mostly cross-platform build errors that I didn't hit....
Radar WebKit Bug Importer
Comment 5
2021-09-15 08:55:27 PDT
<
rdar://problem/83152801
>
Michael Catanzaro
Comment 6
2021-09-15 13:09:42 PDT
Created
attachment 438282
[details]
Patch
Alex Christensen
Comment 7
2021-09-15 13:13:52 PDT
Comment on
attachment 438282
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438282&action=review
> Source/WebKit/Shared/URLSchemeTaskParameters.cpp:50 > + WebURLSchemeHandlerIdentifier handlerIdentifier;
Doesn't Decoder::operator>> work here?
> Source/WebKit/UIProcess/WebURLSchemeHandler.cpp:107 > + for (auto& t : m_tasks.values()) { > + if (t->webProcessTaskID() == webProcessTaskIdentifier) {
This is a loop we don't want to introduce in this patch.
Michael Catanzaro
Comment 8
2021-09-15 13:27:13 PDT
(In reply to Alex Christensen from
comment #7
)
> Doesn't Decoder::operator>> work here?
I'm not sure. Will find out.
> > Source/WebKit/UIProcess/WebURLSchemeHandler.cpp:107 > > + for (auto& t : m_tasks.values()) { > > + if (t->webProcessTaskID() == webProcessTaskIdentifier) { > > This is a loop we don't want to introduce in this patch.
Yeah it's the same loop we're already discussing in
https://bugs.webkit.org/show_bug.cgi?id=229116#c24
. Once we agree how to proceed there, I will update this patch to match.
Alex Christensen
Comment 9
2021-09-15 13:28:03 PDT
I think we should make this patch only changing uint64_t to ObjectIdentifier, then we can do another change to address that bug.
Michael Catanzaro
Comment 10
2021-09-15 13:37:41 PDT
(In reply to Alex Christensen from
comment #9
)
> I think we should make this patch only changing uint64_t to > ObjectIdentifier, then we can do another change to address that bug.
OK, as you prefer, but note it's going to be a little weird for the reason I mention in
https://bugs.webkit.org/show_bug.cgi?id=229116#c25
.
Michael Catanzaro
Comment 11
2021-09-15 14:26:23 PDT
(In reply to Michael Catanzaro from
comment #10
)
> OK, as you prefer, but note it's going to be a little weird for the reason I > mention in
https://bugs.webkit.org/show_bug.cgi?id=229116#c25
.
I decided to avoid that by removing WebURLSchemeTaskIdentifier. Instead, I only introduce WebURLSchemeTaskProxyIdentifier here, that way this patch can misuse it exactly the same as the original code and avoid behavior changes in this bug. Then in
bug #229116
I can fix things by introducing WebURLSchemeTaskIndentifier.
Michael Catanzaro
Comment 12
2021-09-15 14:40:49 PDT
(In reply to Alex Christensen from
comment #7
)
> > Source/WebKit/Shared/URLSchemeTaskParameters.cpp:50 > > + WebURLSchemeHandlerIdentifier handlerIdentifier; > > Doesn't Decoder::operator>> work here?
It actually does work fine. I must have misread an error message at some point.
Michael Catanzaro
Comment 13
2021-09-15 14:48:49 PDT
Created
attachment 438293
[details]
Patch
Michael Catanzaro
Comment 14
2021-09-15 14:51:54 PDT
Comment on
attachment 438293
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438293&action=review
> Source/WebKit/WebProcess/WebPage/WebURLSchemeTaskProxy.cpp:88 > - m_urlSchemeHandler.page().send(Messages::WebPageProxy::StartURLSchemeTask(URLSchemeTaskParameters { m_urlSchemeHandler.identifier(), m_coreLoader->identifier(), m_request, m_frame->info() })); > + m_urlSchemeHandler.page().send(Messages::WebPageProxy::StartURLSchemeTask(URLSchemeTaskParameters { m_urlSchemeHandler.identifier(), m_identifier, m_request, m_frame->info() })); > } > > void WebURLSchemeTaskProxy::stopLoading() > { > ASSERT(m_coreLoader); > WEBURLSCHEMETASKPROXY_RELEASE_LOG("stopLoading"); > - m_urlSchemeHandler.page().send(Messages::WebPageProxy::StopURLSchemeTask(m_urlSchemeHandler.identifier(), m_coreLoader->identifier())); > + m_urlSchemeHandler.page().send(Messages::WebPageProxy::StopURLSchemeTask(m_urlSchemeHandler.identifier(), m_identifier));
These are the only two changes that aren't a literal translation of the existing code, but it makes no difference because WebCore::ResourceLoader's identifier does not change after it is created. Seems cleaner to avoid converting from that to ObjectIdentifier again when we have a member variable handy already.
Darin Adler
Comment 15
2021-09-15 18:17:47 PDT
Comment on
attachment 438293
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438293&action=review
> Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:465 > + if (auto task = m_urlSchemeTasks.take(makeObjectIdentifier<WebURLSchemeTaskProxy>(resourceLoader->identifier()))) {
I don’t understand this recurring pattern. Does the resource loader have an identifier that is a plain old integer; is it a different type of identifier for each different type of resource load? What makes it safe to just assume it’s a scheme task proxy identifier here?
youenn fablet
Comment 16
2021-09-16 00:32:03 PDT
Comment on
attachment 438293
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438293&action=review
> Source/WebKit/UIProcess/WebURLSchemeTask.cpp:51 > + //
https://bugs.webkit.org/show_bug.cgi?id=229116
s/not not/not/ But also, m_identifier+m_webPageProxyID is unique within UIProcess. It could be that paired identifier that could be publicly exposed.
>> Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:465 >> + if (auto task = m_urlSchemeTasks.take(makeObjectIdentifier<WebURLSchemeTaskProxy>(resourceLoader->identifier()))) { > > I don’t understand this recurring pattern. Does the resource loader have an identifier that is a plain old integer; is it a different type of identifier for each different type of resource load? What makes it safe to just assume it’s a scheme task proxy identifier here?
I also feel like we can do without this change. Typing ResourceLoader::identifier() is a good thing and we could then reuse ResourceLoaderIdentifier directly. If needed, there could be a mapping in UIProcess from PageProxyID+ResourceLoaderIdentifier to UIProcess generated WebURLSchemeTaskIdentifier.
> Source/WebKit/WebProcess/Network/WebLoaderStrategy.h:140 > HashMap<unsigned long, PreconnectCompletionHandler> m_preconnectCompletionHandlers;
All these maps should in the end take the same key type (uint64_t or ResourceLoaderIdentifier).
Michael Catanzaro
Comment 17
2021-09-16 10:47:18 PDT
(In reply to Darin Adler from
comment #15
)
> > Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:465 > > + if (auto task = m_urlSchemeTasks.take(makeObjectIdentifier<WebURLSchemeTaskProxy>(resourceLoader->identifier()))) { > > I don’t understand this recurring pattern. Does the resource loader have an > identifier that is a plain old integer;
This is correct.
> is it a different type of identifier > for each different type of resource load?
No, it's just one identifier.
> What makes it safe to just assume > it’s a scheme task proxy identifier here?
It's safe in the web process because each task corresponds to exactly one resource load. But in the UI process code, it is not safe. That's causing
bug #229116
and ultimately that's what I want to fix. But in this intermediate patch, I'm just trying to switch to ObjectIdentifier without changing behavior, since that's the order in which Alex preferred to do this. That is: it's intentionally incorrect, matching the existing code, as a precursor to fix it in
bug #229116
. (In reply to youenn fablet from
comment #16
)
> s/not not/not/ > But also, m_identifier+m_webPageProxyID is unique within UIProcess. > It could be that paired identifier that could be publicly exposed.
Hm, I'm not certain whether that is actually right with PSON. In theory, the WebPageProxy could correspond to multiple different WebPages. Maybe if a URI scheme request for a subresource load that is in flight at the same time that a process swap occurs, there could be confusion? I'm not sure. We should discuss this proposal more in
bug #229116
.
> I also feel like we can do without this change. > Typing ResourceLoader::identifier() is a good thing and we could then reuse > ResourceLoaderIdentifier directly. > If needed, there could be a mapping in UIProcess from > PageProxyID+ResourceLoaderIdentifier to UIProcess generated > WebURLSchemeTaskIdentifier. > > > Source/WebKit/WebProcess/Network/WebLoaderStrategy.h:140 > > HashMap<unsigned long, PreconnectCompletionHandler> m_preconnectCompletionHandlers; > > All these maps should in the end take the same key type (uint64_t or > ResourceLoaderIdentifier).
Hm, that does seem elegant, but it would require changes in a lot more code, unrelated to the URI scheme handlers. It's taking me a bit far away from the goal of fixing
bug #229116
. That said, we should absolutely convert ResourceLoader to use ObjectIdentifier. I would just rather not block
bug #229116
on this.
Alex Christensen
Comment 18
2021-09-16 13:39:18 PDT
Created
attachment 438397
[details]
Patch
Michael Catanzaro
Comment 19
2021-09-16 14:27:51 PDT
Comment on
attachment 438397
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438397&action=review
OK, thanks Alex. This obviously turned out better than my approach. I'm surprised you managed such a huge change so quickly. (Note: I reviewed the first patch you attached.)
> Source/WebCore/loader/DocumentLoader.cpp:2019 > -void DocumentLoader::addSubresourceLoader(ResourceLoader* loader) > +void DocumentLoader::addSubresourceLoader(ResourceLoader& loader)
Nice pointer -> ref improvements too.
> Source/WebCore/loader/ProgressTracker.cpp:290 > unsigned long ProgressTracker::createUniqueIdentifier() > { > + // FIXME: Use a strongly typed identifier for websockets and remove this. > return ++s_uniqueIdentifier; > }
Ah great, I was going to ask if it was possible to remove this.
> Source/WebCore/loader/WorkerThreadableLoader.cpp:118 > + // FIXME: m_workerRequestIdentifier should have its own type, distinct from ResourceLoaderIdentifier, which should only be used to identify ResourceLoaders.
Hm, is this FIXME actually practical? You have to eventually cast to ResourceLoaderIdentifier no matter what, right? So you have to ensure the values don't clash with the values of ResourceLoaderIdentifiers. Am I missing something? Unless you have thought of something that I missed, I would just remove the FIXME.
> Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:1271 > -void NetworkConnectionToWebProcess::prioritizeResourceLoads(Vector<ResourceLoadIdentifier> loadIdentifiers) > +void NetworkConnectionToWebProcess::prioritizeResourceLoads(const Vector<WebCore::ResourceLoaderIdentifier>& loadIdentifiers)
Oops, good.
> Source/WebKit/UIProcess/ProvisionalPageProxy.h:128 > - void decidePolicyForResponse(WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, WebCore::BrowsingContextGroupSwitchDecision, uint64_t listenerID, uint64_t mainResourceLoadIdentifier, const UserData&); > + void decidePolicyForResponse(WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, WebCore::BrowsingContextGroupSwitchDecision, WebCore::ResourceLoaderIdentifier mainResourceLoadIdentifier, uint64_t listenerID, const UserData&);
Wow, I see the parameters here were previously misnamed. Dangerous. Another win for ObjectIdentifier....
> Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:709 > - loadParameters.identifier = WebLoaderStrategy::generateLoadIdentifier(); > + loadParameters.identifier = WebCore::ResourceLoaderIdentifier::generate();
Extra space here.
> Source/WebKit/WebProcess/WebPage/WebURLSchemeHandlerProxy.h:72 > + // FIXME: This should be a strongly typed identifier. > uint64_t m_identifier { 0 };
Do you want to follow up on WebURLSchemeHandlerProxy, or want me to do it? This seems like the least-controversial portion of my patch since it's just a straight 1:1 conversion to use ObjectIdentifier.
Michael Catanzaro
Comment 20
2021-09-16 14:30:28 PDT
Comment on
attachment 438397
[details]
Patch r=me, of course I assume you placate EWS. Looks like there are missing spots in WebFrameLoaderClientIOS.mm. Then I'm not sure what's wrong with the include path on the Windows bot....
Alex Christensen
Comment 21
2021-09-17 11:17:20 PDT
Comment on
attachment 438397
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438397&action=review
> Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:852 > + auto mainResourceLoadIdentifier = policyDocumentLoader && policyDocumentLoader->mainResourceLoader() ? policyDocumentLoader->mainResourceLoader()->identifier() : WebCore::ResourceLoaderIdentifier();
This needs to be std::nullopt instead of an empty ResourceLoaderIdentifier because we are sending it across IPC, which only allows valid identifiers.
Alex Christensen
Comment 22
2021-09-17 11:18:22 PDT
Created
attachment 438489
[details]
Patch
Michael Catanzaro
Comment 23
2021-09-17 12:30:49 PDT
Careful, you accidentally included a project.pbxproj.orig in the diff. Also the GTK/WPE EWS is not happy with this version of the patch.
Michael Catanzaro
Comment 24
2021-09-17 12:32:52 PDT
Comment on
attachment 438489
[details]
Patch There's also a Document.cpp.orig... probably more, not sure because it's taking forever to load the full diff.
Alex Christensen
Comment 25
2021-09-17 12:39:55 PDT
Created
attachment 438502
[details]
Patch
Michael Catanzaro
Comment 26
2021-09-17 13:38:40 PDT
Comment on
attachment 438502
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438502&action=review
> Source/WebCore/loader/FrameLoader.cpp:3598 > - identifier = 0; > + identifier = { }; > if (Page* page = m_frame.page()) { > - identifier = page->progress().createUniqueIdentifier(); > + identifier = ResourceLoaderIdentifier::generate(); > notifier().assignIdentifierToInitialRequest(identifier, m_documentLoader.get(), request); > }
This condition needs to be removed, because page is no longer required to generate the identifier.
Michael Catanzaro
Comment 27
2021-09-17 13:41:14 PDT
Comment on
attachment 438502
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=438502&action=review
> Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.h:61 > + void didInitiateLoadForResource(WebPage&, WebFrame&, WebCore::ResourceLoaderIdentifier, const WebCore::ResourceRequest&, bool /*pageIsProvisionallyLoading*/) override; > + void willSendRequestForFrame(WebPage&, WebFrame&, WebCore::ResourceLoaderIdentifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse&) override; > + void didReceiveResponseForResource(WebPage&, WebFrame&, WebCore::ResourceLoaderIdentifier, const WebCore::ResourceResponse&) override; > + void didReceiveContentLengthForResource(WebPage&, WebFrame&, WebCore::ResourceLoaderIdentifier, uint64_t contentLength) override; > + void didFinishLoadForResource(WebPage&, WebFrame&, WebCore::ResourceLoaderIdentifier) override; > + void didFailLoadForResource(WebPage&, WebFrame&, WebCore::ResourceLoaderIdentifier, const WebCore::ResourceError&) override; > + bool shouldCacheResponse(WebPage&, WebFrame&, WebCore::ResourceLoaderIdentifier) override; > + bool shouldUseCredentialStorage(WebPage&, WebFrame&, WebCore::ResourceLoaderIdentifier) override;
This is what's breaking the WPE/GTK EWS. It should work if you also update PageResourceLoadClient in WebKitWebPage.cpp. Should be trivial.
Alex Christensen
Comment 28
2021-09-17 13:44:25 PDT
Created
attachment 438510
[details]
Patch
Michael Catanzaro
Comment 29
2021-09-17 13:51:46 PDT
Comment on
attachment 438502
[details]
Patch Ah, I notice there is also Source/WebKit/NetworkProcess/NetworkProcess.h.rej added my mistake.
Alex Christensen
Comment 30
2021-09-17 13:52:50 PDT
(In reply to Michael Catanzaro from
comment #29
)
> Comment on
attachment 438502
[details]
> Patch > > Ah, I notice there is also Source/WebKit/NetworkProcess/NetworkProcess.h.rej > added my mistake.
Oops. I'll remove in my next iteration. (In reply to Michael Catanzaro from
comment #26
)
> Comment on
attachment 438502
[details]
> Patch > > This condition needs to be removed, because page is no longer required to > generate the identifier.
That may be true, but in a separate patch. I think this should change as little as possible to help with bisection.
Michael Catanzaro
Comment 31
2021-09-17 14:05:08 PDT
(In reply to Alex Christensen from
comment #30
)
> That may be true, but in a separate patch. I think this should change as > little as possible to help with bisection.
I mean it's really totally unused, I noticed because it introduces a -Wunused-variable warning. Don't do that. :P
Darin Adler
Comment 32
2021-09-17 14:42:58 PDT
(In reply to Michael Catanzaro from
comment #31
)
> (In reply to Alex Christensen from
comment #30
) > > That may be true, but in a separate patch. I think this should change as > > little as possible to help with bisection. > > I mean it's really totally unused, I noticed because it introduces a > -Wunused-variable warning. Don't do that. :P
So we can leave the null check in for now, and remove that in a later patch, but must not put it in a local variable.
Alex Christensen
Comment 33
2021-09-17 15:07:49 PDT
Ohhh. Now I see what you're talking about. page is no longer needed. Will remove the now-unnecessary branch.
Alex Christensen
Comment 34
2021-09-17 15:23:31 PDT
Created
attachment 438522
[details]
Patch
Alex Christensen
Comment 35
2021-09-17 15:43:46 PDT
Created
attachment 438523
[details]
Patch
Alex Christensen
Comment 36
2021-09-17 17:10:33 PDT
Comment on
attachment 438523
[details]
Patch
https://trac.webkit.org/r282712
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug