Title: [242110] trunk/Source/WebCore
Revision
242110
Author
[email protected]
Date
2019-02-26 15:38:31 -0800 (Tue, 26 Feb 2019)

Log Message

[Mac WK2] storage/indexeddb/IDBObject-leak.html is flaky
https://bugs.webkit.org/show_bug.cgi?id=195036

Reviewed by Geoffrey Garen.

When connection to IDBServer is lost, IDBDatabase in web process should not only stop active transactions, but
also transactions in committing process.

Also, TransactionOpration should clear its perform function when the operation is being completed, otherwise
there is a reference cycle of TransactionOpration.

Covered by existing tests storage/indexeddb/IDBObject-leak.html.

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::connectionToServerLost): notify committing transasctions that connection is lost.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::connectionClosedFromServer): notify IDBConnectionProxy that transaction ends.
* Modules/indexeddb/client/IDBConnectionProxy.cpp:
(WebCore::IDBClient::IDBConnectionProxy::forgetTransaction): clear finished transactions.
* Modules/indexeddb/client/IDBConnectionProxy.h:
* Modules/indexeddb/client/TransactionOperation.h:
(WebCore::IDBClient::TransactionOperation::doComplete): clear perform function unconditionally when the
operation is in completion process.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (242109 => 242110)


--- trunk/Source/WebCore/ChangeLog	2019-02-26 22:40:03 UTC (rev 242109)
+++ trunk/Source/WebCore/ChangeLog	2019-02-26 23:38:31 UTC (rev 242110)
@@ -1,3 +1,29 @@
+2019-02-26  Sihui Liu  <[email protected]>
+
+        [Mac WK2] storage/indexeddb/IDBObject-leak.html is flaky
+        https://bugs.webkit.org/show_bug.cgi?id=195036
+
+        Reviewed by Geoffrey Garen.
+
+        When connection to IDBServer is lost, IDBDatabase in web process should not only stop active transactions, but 
+        also transactions in committing process.
+
+        Also, TransactionOpration should clear its perform function when the operation is being completed, otherwise 
+        there is a reference cycle of TransactionOpration.
+
+        Covered by existing tests storage/indexeddb/IDBObject-leak.html.
+
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::connectionToServerLost): notify committing transasctions that connection is lost.
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::connectionClosedFromServer): notify IDBConnectionProxy that transaction ends.
+        * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+        (WebCore::IDBClient::IDBConnectionProxy::forgetTransaction): clear finished transactions.
+        * Modules/indexeddb/client/IDBConnectionProxy.h:
+        * Modules/indexeddb/client/TransactionOperation.h:
+        (WebCore::IDBClient::TransactionOperation::doComplete): clear perform function unconditionally when the 
+        operation is in completion process. 
+
 2019-02-26  Zalan Bujtas  <[email protected]>
 
         [ContentChangeObserver] clearContentChangeObservers should be internal to ContentChangeObserver class

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (242109 => 242110)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp	2019-02-26 22:40:03 UTC (rev 242109)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp	2019-02-26 23:38:31 UTC (rev 242110)
@@ -264,9 +264,13 @@
     m_closePending = true;
     m_closedInServer = true;
 
-    auto transactions = copyToVector(m_activeTransactions.values());
-    for (auto& transaction : transactions)
+    auto activeTransactions = copyToVector(m_activeTransactions.values());
+    for (auto& transaction : activeTransactions)
         transaction->connectionClosedFromServer(error);
+    
+    auto committingTransactions = copyToVector(m_committingTransactions.values());
+    for (auto& transaction : committingTransactions)
+        transaction->connectionClosedFromServer(error);
 
     auto errorEvent = Event::create(m_eventNames.errorEvent, Event::CanBubble::Yes, Event::IsCancelable::No);
     errorEvent->setTarget(this);

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (242109 => 242110)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2019-02-26 22:40:03 UTC (rev 242109)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2019-02-26 23:38:31 UTC (rev 242110)
@@ -1440,7 +1440,7 @@
     LOG(IndexedDB, "IDBTransaction::connectionClosedFromServer - %s", error.message().utf8().data());
 
     m_database->willAbortTransaction(*this);
-    transitionedToFinishing(IndexedDB::TransactionState::Aborting);
+    m_state = IndexedDB::TransactionState::Aborting;
 
     abortInProgressOperations(error);
 
@@ -1454,6 +1454,7 @@
     m_currentlyCompletingRequest = nullptr;
 
     connectionProxy().forgetActiveOperations(operations);
+    connectionProxy().forgetTransaction(*this);
 
     m_pendingTransactionOperationQueue.clear();
     m_abortQueue.clear();

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (242109 => 242110)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp	2019-02-26 22:40:03 UTC (rev 242109)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp	2019-02-26 23:38:31 UTC (rev 242110)
@@ -517,6 +517,15 @@
         m_activeOperations.remove(operation->identifier());
 }
 
+void IDBConnectionProxy::forgetTransaction(IDBTransaction& transaction)
+{
+    Locker<Lock> locker(m_transactionMapLock);
+
+    m_pendingTransactions.remove(transaction.info().identifier());
+    m_committingTransactions.remove(transaction.info().identifier());
+    m_abortingTransactions.remove(transaction.info().identifier());
+}
+
 template<typename KeyType, typename ValueType>
 void removeItemsMatchingCurrentThread(HashMap<KeyType, ValueType>& map)
 {

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h (242109 => 242110)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h	2019-02-26 22:40:03 UTC (rev 242109)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h	2019-02-26 23:38:31 UTC (rev 242110)
@@ -122,6 +122,7 @@
     void unregisterDatabaseConnection(IDBDatabase&);
 
     void forgetActiveOperations(const Vector<RefPtr<TransactionOperation>>&);
+    void forgetTransaction(IDBTransaction&);
     void forgetActivityForCurrentThread();
 
 private:

Modified: trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h (242109 => 242110)


--- trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h	2019-02-26 22:40:03 UTC (rev 242109)
+++ trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h	2019-02-26 23:38:31 UTC (rev 242110)
@@ -85,6 +85,9 @@
     {
         ASSERT(m_originThread.ptr() == &Thread::current());
 
+        if (m_performFunction)
+            m_performFunction = { };
+
         // Due to race conditions between the server sending an "operation complete" message and the client
         // forcefully aborting an operation, it's unavoidable that this method might be called twice.
         // It's okay to handle that gracefully with an early return.
@@ -98,8 +101,6 @@
         // so we need to do this trick to null it out without first destroying it.
         Function<void(const IDBResultData&)> oldCompleteFunction;
         std::swap(m_completeFunction, oldCompleteFunction);
-
-        m_performFunction = { };
     }
 
     const IDBResourceIdentifier& identifier() const { return m_identifier; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to