Bug 208610

Summary: Construct fewer unnecessary temporary WebProcessPool objects in WebsiteDataStore implementation
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, beidson, commit-queue, sabouhallawa, sam, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=208546
Bug Depends on:    
Bug Blocks: 208541, 208619    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Chris Dumez 2020-03-04 15:38:35 PST
Construct less unnecessary temporary WebProcessPool objects in WebsiteDataStore implementation.
Comment 1 Chris Dumez 2020-03-04 16:12:49 PST
Created attachment 392502 [details]
Patch
Comment 2 Chris Dumez 2020-03-04 16:50:21 PST
Created attachment 392510 [details]
Patch
Comment 3 Said Abou-Hallawa 2020-03-04 17:05:45 PST
Comment on attachment 392510 [details]
Patch

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

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:1380
> -    for (auto& processPool : ensureProcessPools()) {
> +    for (auto& processPool : processPools()) {
>          if (auto* process = processPool->networkProcess()) {
>              process->isRegisteredAsSubresourceUnder(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { topFrameURL }, WTFMove(completionHandler));
> -            break;
> -        } else {
> -            ASSERT_NOT_REACHED();
> -            completionHandler(false);
> -            break;
> +            return;
>          }
> +        break;
>      }
> +    completionHandler(false);

I am not sure what this function is supposed to do. Does it expect (processPools().size() == 1 and processPools()[0]->networkProcess() != nullptr)? if this is the case why do we use a for-loop?

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:1481
> +    completionHandler();

completionHandler is moved above when creating callbackAggregator.
Comment 4 Chris Dumez 2020-03-04 17:09:30 PST
(In reply to Said Abou-Hallawa from comment #3)
> Comment on attachment 392510 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=392510&action=review
> 
> > Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:1380
> > -    for (auto& processPool : ensureProcessPools()) {
> > +    for (auto& processPool : processPools()) {
> >          if (auto* process = processPool->networkProcess()) {
> >              process->isRegisteredAsSubresourceUnder(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { topFrameURL }, WTFMove(completionHandler));
> > -            break;
> > -        } else {
> > -            ASSERT_NOT_REACHED();
> > -            completionHandler(false);
> > -            break;
> > +            return;
> >          }
> > +        break;
> >      }
> > +    completionHandler(false);
> 
> I am not sure what this function is supposed to do. Does it expect
> (processPools().size() == 1 and processPools()[0]->networkProcess() !=
> nullptr)? if this is the case why do we use a for-loop?
> 
> > Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:1481
> > +    completionHandler();
> 
> completionHandler is moved above when creating callbackAggregator.

Thanks for catching this. Will fix before landing.
Comment 5 Chris Dumez 2020-03-04 17:09:46 PST
Created attachment 392514 [details]
Patch
Comment 6 WebKit Commit Bot 2020-03-04 17:12:26 PST
Comment on attachment 392514 [details]
Patch

Rejecting attachment 392514 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'validate-changelog', '--check-oops', '--non-interactive', 392514, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

ChangeLog entry in Source/WebKit/ChangeLog contains OOPS!.

Full output: https://webkit-queues.webkit.org/results/13333735
Comment 7 Chris Dumez 2020-03-04 17:16:02 PST
Created attachment 392515 [details]
Patch
Comment 8 WebKit Commit Bot 2020-03-04 18:04:54 PST
Comment on attachment 392515 [details]
Patch

Clearing flags on attachment: 392515

Committed r257893: <https://trac.webkit.org/changeset/257893>
Comment 9 WebKit Commit Bot 2020-03-04 18:04:56 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2020-03-04 18:05:18 PST
<rdar://problem/60066720>