Bug 140881

Summary: [WK2] Replace AsyncTask with C++ lambdas
Product: WebKit Reporter: Zan Dobersek <zan>
Component: New BugsAssignee: Zan Dobersek <zan>
Status: RESOLVED WONTFIX    
Severity: Normal CC: alecflett, andersca, beidson, cgarcia, commit-queue, darin, jsbell, ossy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP
none
Patch darin: review-

Description Zan Dobersek 2015-01-26 01:13:31 PST
[WK2] Replace AsyncTask with C++ lambdas
Comment 1 Zan Dobersek 2015-01-26 01:16:33 PST
Created attachment 245332 [details]
WIP
Comment 2 WebKit Commit Bot 2015-01-26 03:48:55 PST
Attachment 245332 [details] did not pass style-queue:


ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:352:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:1349:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:1371:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:1388:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:1414:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/DatabaseProcess.h:68:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/DatabaseProcess.h:108:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:122:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:135:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:139:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:205:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:208:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebCore/WebCore.exp.in:0:  Source/WebCore/WebCore.exp.in should be sorted, use Tools/Scripts/sort-export-file script  [list/order] [5]
ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
ERROR: Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp:154:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp:171:  Extra space before ( in function call  [whitespace/parens] [4]
Total errors found: 16 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Carlos Garcia Campos 2015-01-27 08:13:52 PST
Comment on attachment 245332 [details]
WIP

Is this really wip? what's missing? EWS is green for all ports.
Comment 4 Carlos Garcia Campos 2015-01-29 01:12:00 PST
Darin, Anders, what do you think about this? it makes the code simpler and more compatible with the compilers.
Comment 5 Zan Dobersek 2015-01-29 12:43:34 PST
Created attachment 245638 [details]
Patch
Comment 6 WebKit Commit Bot 2015-01-29 12:46:09 PST
Attachment 245638 [details] did not pass style-queue:


ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:352:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:1349:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:1371:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:1388:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:1414:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/DatabaseProcess.h:68:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/DatabaseProcess.h:110:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:122:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:135:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:139:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:205:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:208:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebCore/WebCore.exp.in:0:  Source/WebCore/WebCore.exp.in should be sorted, use Tools/Scripts/sort-export-file script  [list/order] [5]
ERROR: Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp:154:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp:171:  Extra space before ( in function call  [whitespace/parens] [4]
Total errors found: 15 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Darin Adler 2015-01-30 22:28:15 PST
Comment on attachment 245638 [details]
Patch

I prefer this style; proofreading all the call sites to makes sure they are all correct is a bit of a challenge.
Comment 8 Carlos Garcia Campos 2015-02-03 01:06:07 PST
(In reply to comment #7)
> Comment on attachment 245638 [details]
> Patch
> 
> I prefer this style; proofreading all the call sites to makes sure they are
> all correct is a bit of a challenge.

I have reviewed them and everything looks correct. Mac EWS would have caught any issue anyway, I guess.
Comment 9 Darin Adler 2015-02-07 08:03:39 PST
Comment on attachment 245638 [details]
Patch

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

> Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:305
> +    IDBIdentifier capturedIdentifier(transactionIdentifier.isolatedCopy());

This idiom isn’t great. right now, the isolatedCopy function does nothing special. If it did, we still might have a race condition on deref like the one we have in String, so isolatedCopy might be insufficient. I’m not sure it’s all that helpful to write the code this way instead of just using straight construction; it’s not really future proof to have a function need isolatedCopy.

> Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:416
> +    IDBIdentifier capturedIdentifier = transactionIdentifier.isolatedCopy();

Strange that this uses "=" syntax where the other call sites use construction syntax. I don’t have a strong preference, but I do prefer consistency.

> Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:650
> +    IDBObjectStoreMetadata capturedMetadata(m_metadata->objectStores.get(objectStoreID).isolatedCopy());

This won’t work. We have a race condition where the main thread will deref capturedMetadata.name and the database task thread will also deref it. And String does not have a thread-safe reference count.

> Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:651
> +    IDBKeyData capturedKeyData(keyData.isolatedCopy());

Same problem here with capturedKeyData.stringValue.
Comment 10 Carlos Garcia Campos 2015-05-25 00:08:15 PDT
This no longer blocks #98932 , since we bumped GCC requirements in the end, but I think it would still be desirable if we manage to fix the thread-safety issues
Comment 11 Zan Dobersek 2017-09-25 01:23:40 PDT
AsyncTask doesn't exist anymore.