Bug 223089 - Use BinarySemaphore in SerializedScriptValue::writeBlobsToDiskForIndexedDBSynchronously()
Summary: Use BinarySemaphore in SerializedScriptValue::writeBlobsToDiskForIndexedDBSyn...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-03-11 14:03 PST by Chris Dumez
Modified: 2021-03-11 14:41 PST (History)
9 users (show)

See Also:


Attachments
Patch (2.42 KB, patch)
2021-03-11 14:05 PST, 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-03-11 14:03:20 PST
Use BinarySemaphore in SerializedScriptValue::writeBlobsToDiskForIndexedDBSynchronously() instead of a Condition. This simplifies the code a bit.
Comment 1 Chris Dumez 2021-03-11 14:05:23 PST
Created attachment 422963 [details]
Patch
Comment 2 Geoffrey Garen 2021-03-11 14:07:39 PST
Comment on attachment 422963 [details]
Patch

r=me
Comment 3 Alex Christensen 2021-03-11 14:08:30 PST
View in context: https://bugs.webkit.org/attachment.cgi?id=422963&action=review

> Source/WebCore/bindings/js/SerializedScriptValue.cpp:4159
> +    callOnMainThread([this, &semaphore, &value] {

Won't this do something different in UIWebView?  Does this matter?
Comment 4 Chris Dumez 2021-03-11 14:11:50 PST
(In reply to Alex Christensen from comment #3)
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=422963&action=review
> 
> > Source/WebCore/bindings/js/SerializedScriptValue.cpp:4159
> > +    callOnMainThread([this, &semaphore, &value] {
> 
> Won't this do something different in UIWebView?  Does this matter?

I mentioned this in the changelog. I changed this intentionally. We're in WebCore here so we should be using callOnMainThread() in my opinion. Also note that the surrounding code is using isMainThread(), not isMainRunLoop().
Comment 5 Alex Christensen 2021-03-11 14:12:23 PST
Comment on attachment 422963 [details]
Patch

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

Sounds good

> Source/WebCore/bindings/js/SerializedScriptValue.cpp:4159
> +    callOnMainThread([this, &semaphore, &value] {

Won't this do something different in UIWebView?  Does this matter?
Comment 6 Chris Dumez 2021-03-11 14:16:22 PST
(In reply to Chris Dumez from comment #4)
> (In reply to Alex Christensen from comment #3)
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=422963&action=review
> > 
> > > Source/WebCore/bindings/js/SerializedScriptValue.cpp:4159
> > > +    callOnMainThread([this, &semaphore, &value] {
> > 
> > Won't this do something different in UIWebView?  Does this matter?
> 
> I mentioned this in the changelog. I changed this intentionally. We're in
> WebCore here so we should be using callOnMainThread() in my opinion. Also
> note that the surrounding code is using isMainThread(), not isMainRunLoop().

I also checked the call site, it does:
if (!isMainThread()) {
     value->writeBlobsToDiskForIndexedDBSynchronously();
     return;   
}
value->writeBlobsToDiskForIndexedDB()

So for this call site, it was OK to call writeBlobsToDiskForIndexedDB() directly if isMainThread() returns true (potentially being the WebThread).
Comment 7 EWS 2021-03-11 14:40:05 PST
Committed r274300: <https://commits.webkit.org/r274300>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 422963 [details].
Comment 8 Radar WebKit Bug Importer 2021-03-11 14:41:18 PST
<rdar://problem/75333893>