Title: [201302] trunk/Source/WebCore
Revision
201302
Author
[email protected]
Date
2016-05-23 16:14:33 -0700 (Mon, 23 May 2016)

Log Message

Speculative fix for:
Modern IDB: Some blob tests ASSERT sometimes on the bots.
https://bugs.webkit.org/show_bug.cgi?id=157525

Reviewed by Alex Christensen.

No new tests (Should fix existing flakiness, not reproducibly testable).

For all of the lambdas involved in this operation, explicitly WTFMove all of the arguments around.

Critically, this includes the RefPtr<TransactionOperation> protector as well as the
std::function<void ()> completionHandler(s).

By doing so, this removes the possibility of a race between the background thread and the main thread
tearing down the TransactionOperation, guaranteeing that it is torn down on its original thread.

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::putOrAddOnServer):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB):
* platform/network/BlobRegistryImpl.cpp:
(WebCore::BlobRegistryImpl::writeBlobsToTemporaryFiles):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (201301 => 201302)


--- trunk/Source/WebCore/ChangeLog	2016-05-23 22:46:41 UTC (rev 201301)
+++ trunk/Source/WebCore/ChangeLog	2016-05-23 23:14:33 UTC (rev 201302)
@@ -1,3 +1,28 @@
+2016-05-23  Brady Eidson  <[email protected]>
+
+        Speculative fix for:
+        Modern IDB: Some blob tests ASSERT sometimes on the bots.
+        https://bugs.webkit.org/show_bug.cgi?id=157525
+
+        Reviewed by Alex Christensen.
+
+        No new tests (Should fix existing flakiness, not reproducibly testable).
+
+        For all of the lambdas involved in this operation, explicitly WTFMove all of the arguments around.
+        
+        Critically, this includes the RefPtr<TransactionOperation> protector as well as the 
+        std::function<void ()> completionHandler(s).
+        
+        By doing so, this removes the possibility of a race between the background thread and the main thread
+        tearing down the TransactionOperation, guaranteeing that it is torn down on its original thread.
+        
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::putOrAddOnServer):
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB):
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::BlobRegistryImpl::writeBlobsToTemporaryFiles):
+
 2016-05-23  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r201296.

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (201301 => 201302)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2016-05-23 22:46:41 UTC (rev 201301)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2016-05-23 23:14:33 UTC (rev 201302)
@@ -959,7 +959,7 @@
             // In that case, we cannot successfully store this record, so we callback with an error.
             RefPtr<IDBClient::TransactionOperation> protectedOperation(&operation);
             auto result = IDBResultData::error(operation.identifier(), { IDBDatabaseException::UnknownError, ASCIILiteral("Error preparing Blob/File data to be stored in object store") });
-            scriptExecutionContext()->postTask([protectedOperation, result](ScriptExecutionContext&) {
+            scriptExecutionContext()->postTask([protectedOperation = WTFMove(protectedOperation), result = WTFMove(result)](ScriptExecutionContext&) {
                 protectedOperation->completed(result);
             });
         }
@@ -968,7 +968,7 @@
 
     RefPtr<IDBTransaction> protectedThis(this);
     RefPtr<IDBClient::TransactionOperation> protectedOperation(&operation);
-    value->writeBlobsToDiskForIndexedDB([protectedThis, this, protectedOperation, key, value, overwriteMode](const IDBValue& idbValue) {
+    value->writeBlobsToDiskForIndexedDB([protectedThis = WTFMove(protectedThis), this, protectedOperation = WTFMove(protectedOperation), key = WTFMove(key), value = WTFMove(value), overwriteMode](const IDBValue& idbValue) mutable {
         ASSERT(currentThread() == originThreadID());
         ASSERT(isMainThread());
         if (idbValue.data().data()) {
@@ -979,7 +979,7 @@
         // If the IDBValue doesn't have any data, then something went wrong writing the blobs to disk.
         // In that case, we cannot successfully store this record, so we callback with an error.
         auto result = IDBResultData::error(protectedOperation->identifier(), { IDBDatabaseException::UnknownError, ASCIILiteral("Error preparing Blob/File data to be stored in object store") });
-        callOnMainThread([protectedThis, this, protectedOperation, result]() {
+        callOnMainThread([protectedThis = WTFMove(protectedThis), this, protectedOperation = WTFMove(protectedOperation), result = WTFMove(result)]() {
             protectedOperation->completed(result);
         });
     });

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (201301 => 201302)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2016-05-23 22:46:41 UTC (rev 201301)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2016-05-23 23:14:33 UTC (rev 201302)
@@ -2802,7 +2802,7 @@
     ASSERT(hasBlobURLs());
 
     RefPtr<SerializedScriptValue> protectedThis(this);
-    blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler, this, protectedThis](const Vector<String>& blobFilePaths) {
+    blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler = WTFMove(completionHandler), this, protectedThis = WTFMove(protectedThis)](const Vector<String>& blobFilePaths) {
         ASSERT(isMainThread());
 
         if (blobFilePaths.isEmpty()) {

Modified: trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp (201301 => 201302)


--- trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp	2016-05-23 22:46:41 UTC (rev 201301)
+++ trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp	2016-05-23 23:14:33 UTC (rev 201302)
@@ -284,11 +284,11 @@
         }
     }
 
-    blobUtilityQueue().dispatch([blobsForWriting, completionHandler]() {
+    blobUtilityQueue().dispatch([blobsForWriting = WTFMove(blobsForWriting), completionHandler = WTFMove(completionHandler)]() mutable {
         Vector<String> filePaths;
 
-        ScopeGuard completionCaller([completionHandler]() {
-            callOnMainThread([completionHandler]() {
+        ScopeGuard completionCaller([completionHandler]() mutable {
+            callOnMainThread([completionHandler = WTFMove(completionHandler)]() {
                 Vector<String> filePaths;
                 completionHandler(filePaths);
             });
@@ -328,7 +328,7 @@
         }
 
         completionCaller.disable();
-        callOnMainThread([completionHandler, filePaths]() {
+        callOnMainThread([completionHandler = WTFMove(completionHandler), filePaths = WTFMove(filePaths)]() {
             completionHandler(filePaths);
         });
     });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to