Bug 187143

Summary: Make sure the WebResourceLoadStatisticsStore gets destroyed on the main thread
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, ews-watchlist, mkwst, ryanhaddad, webkit-bug-importer, wilander, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 187055    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2018-06-28 09:37:55 PDT
Make sure the WebResourceLoadStatisticsStore gets destroyed on the main thread. Currently, we keep capturing a Ref<> to the WebResourceLoadStatisticsStore whenever we dispatch a task to the work queue. This means that the WebResourceLoadStatisticsStore will get destroyed on a background thread if the work queue is the last one to hold a ref to the store, which would not be safe.
Comment 1 Chris Dumez 2018-06-28 15:08:39 PDT
Created attachment 343857 [details]
Patch
Comment 2 youenn fablet 2018-06-28 15:50:17 PDT
Comment on attachment 343857 [details]
Patch

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

> Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp:188
> +    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), origins = WTFMove(origins)]() mutable {

origins should be isolated except if we are sure they are coming straight from IPC.
We should add a comment saying why this is ok.
And we should probably make WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated private to ensure it does not get used out of IPC.

> Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp:258
>  void WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener(String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain, bool isTriggeredByUserGesture)

Ditto.
Comment 3 Chris Dumez 2018-06-28 15:57:46 PDT
Created attachment 343868 [details]
Patch
Comment 4 WebKit Commit Bot 2018-06-28 17:06:06 PDT
Comment on attachment 343868 [details]
Patch

Clearing flags on attachment: 343868

Committed r233342: <https://trac.webkit.org/changeset/233342>
Comment 5 WebKit Commit Bot 2018-06-28 17:06:07 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Radar WebKit Bug Importer 2018-06-28 17:09:12 PDT
<rdar://problem/41609309>