WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
200817
Clarify StorageManagerSet / StorageManager threading model after
r248734
https://bugs.webkit.org/show_bug.cgi?id=200817
Summary
Clarify StorageManagerSet / StorageManager threading model after r248734
Chris Dumez
Reported
2019-08-16 09:34:18 PDT
Clarify StorageManagerSet / StorageManager threading model after
r248734
. StorageManager is now a background thread object but it still calls its completion handlers on the main thread, which is very error prone.
Attachments
Patch
(15.01 KB, patch)
2019-08-16 09:38 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(15.21 KB, patch)
2019-08-16 09:45 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(15.60 KB, patch)
2019-08-16 10:13 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(17.25 KB, patch)
2019-08-16 10:49 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2019-08-16 09:38:32 PDT
Created
attachment 376503
[details]
Patch
Chris Dumez
Comment 2
2019-08-16 09:45:00 PDT
Created
attachment 376505
[details]
Patch
Sihui Liu
Comment 3
2019-08-16 10:05:01 PDT
Comment on
attachment 376505
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=376505&action=review
> Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp:188 > void StorageManagerSet::getSessionStorageOrigins(PAL::SessionID sessionID, CompletionHandler<void(HashSet<WebCore::SecurityOriginData>&&)>&& completionHandler)
Probably not very related: CompletionHandler<void(HashSet<WebCore::SecurityOriginData>&&)>&& here can be changed to GetOriginsCallback&&.
> Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp:203 > void StorageManagerSet::deleteSessionStorage(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
CompletionHandler<void()>&& => DeleteCallback&&
> Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp:270 > void StorageManagerSet::getLocalStorageOriginDetails(PAL::SessionID sessionID, CompletionHandler<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&& completionHandler)
CompletionHandler<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&& => GetOriginDetailsCallback&&
Chris Dumez
Comment 4
2019-08-16 10:13:17 PDT
Created
attachment 376508
[details]
Patch
Geoffrey Garen
Comment 5
2019-08-16 10:35:28 PDT
Comment on
attachment 376508
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=376508&action=review
r=me
> Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp:279 > + auto originDetails = storageManager->getLocalStorageOriginDetails(); > + RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originDetails = crossThreadCopy(originDetails)]() mutable {
Kind of unfortunate that this idiom creates a throw-away copy followed by a cross-thread copy. Maybe we should consider renaming getLocalStorageOriginDetails() -> getLocalStorageOriginDetailsCrossThreadCopy(), and change the implementation to produce a crossThreadCopy.
Chris Dumez
Comment 6
2019-08-16 10:36:36 PDT
Comment on
attachment 376508
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=376508&action=review
>> Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp:279 >> + RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originDetails = crossThreadCopy(originDetails)]() mutable { > > Kind of unfortunate that this idiom creates a throw-away copy followed by a cross-thread copy. > > Maybe we should consider renaming getLocalStorageOriginDetails() -> getLocalStorageOriginDetailsCrossThreadCopy(), and change the implementation to produce a crossThreadCopy.
Ok, I can do that.
Chris Dumez
Comment 7
2019-08-16 10:40:36 PDT
(In reply to Chris Dumez from
comment #6
)
> Comment on
attachment 376508
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=376508&action=review
> > >> Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp:279 > >> + RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originDetails = crossThreadCopy(originDetails)]() mutable { > > > > Kind of unfortunate that this idiom creates a throw-away copy followed by a cross-thread copy. > > > > Maybe we should consider renaming getLocalStorageOriginDetails() -> getLocalStorageOriginDetailsCrossThreadCopy(), and change the implementation to produce a crossThreadCopy. > > Ok, I can do that.
I would just like to point out that the previous code was already creating a throw-away copy since LocalStorageDatabaseTracker::originDetails() returns a new Vector. I merely moved the place where the Vector was crossThreadCopied.
Chris Dumez
Comment 8
2019-08-16 10:49:00 PDT
Created
attachment 376510
[details]
Patch
Chris Dumez
Comment 9
2019-08-16 10:52:51 PDT
(In reply to Chris Dumez from
comment #8
)
> Created
attachment 376510
[details]
> Patch
This latest iteration should have no perf impact as it always cross-thread-copies at the source.
Geoffrey Garen
Comment 10
2019-08-16 10:58:51 PDT
Comment on
attachment 376510
[details]
Patch r=me
Geoffrey Garen
Comment 11
2019-08-16 10:59:32 PDT
> I would just like to point out that the previous code was already creating a > throw-away copy since LocalStorageDatabaseTracker::originDetails() returns a > new Vector. I merely moved the place where the Vector was crossThreadCopied.
True! :P I guess I only noticed this because the new code is clearer.
Chris Dumez
Comment 12
2019-08-16 11:01:26 PDT
(In reply to Geoffrey Garen from
comment #11
)
> > I would just like to point out that the previous code was already creating a > > throw-away copy since LocalStorageDatabaseTracker::originDetails() returns a > > new Vector. I merely moved the place where the Vector was crossThreadCopied. > > True! :P > > I guess I only noticed this because the new code is clearer.
Your point still stands for the other 2 calls sites. You just happened to comment on the only one when there is no perf-hit :P
WebKit Commit Bot
Comment 13
2019-08-16 11:15:28 PDT
Comment on
attachment 376510
[details]
Patch Clearing flags on attachment: 376510 Committed
r248779
: <
https://trac.webkit.org/changeset/248779
>
WebKit Commit Bot
Comment 14
2019-08-16 11:15:29 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 15
2019-08-16 15:06:22 PDT
<
rdar://problem/54409115
>
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