Diff
Modified: trunk/LayoutTests/ChangeLog (242042 => 242043)
--- trunk/LayoutTests/ChangeLog 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/LayoutTests/ChangeLog 2019-02-25 16:50:20 UTC (rev 242043)
@@ -1,3 +1,15 @@
+2019-02-25 Sihui Liu <[email protected]>
+
+ IndexedDB: IDBDatabase and IDBTransaction are leaked in layout tests
+ https://bugs.webkit.org/show_bug.cgi?id=194709
+
+ Reviewed by Geoffrey Garen.
+
+ * TestExpectations:
+ * platform/wk2/TestExpectations:
+ * storage/indexeddb/IDBObject-leak-expected.txt: Added.
+ * storage/indexeddb/IDBObject-leak.html: Added.
+
2019-02-25 Zan Dobersek <[email protected]>
Unreviewed WPE gardening. Adding a few failure expectations as well
Modified: trunk/LayoutTests/TestExpectations (242042 => 242043)
--- trunk/LayoutTests/TestExpectations 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/LayoutTests/TestExpectations 2019-02-25 16:50:20 UTC (rev 242043)
@@ -130,6 +130,7 @@
http/tests/navigation/process-swap-window-open.html [ Skip ]
http/tests/navigation/useragent-reload.php [ Skip ]
storage/indexeddb/modern/opendatabase-after-storage-crash.html [ Skip ]
+storage/indexeddb/IDBObject-leak.html [ Skip ]
fast/forms/call-text-did-change-in-text-field-when-typing.html [ Skip ]
# Only Mac and iOS have an implementation of UIScriptController::doAsyncTask().
Modified: trunk/LayoutTests/platform/wk2/TestExpectations (242042 => 242043)
--- trunk/LayoutTests/platform/wk2/TestExpectations 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/LayoutTests/platform/wk2/TestExpectations 2019-02-25 16:50:20 UTC (rev 242043)
@@ -746,6 +746,7 @@
http/tests/navigation/useragent-reload.php [ Pass ]
storage/indexeddb/modern/opendatabase-after-storage-crash.html [ Pass ]
+storage/indexeddb/IDBObject-leak.html [ Pass ]
fast/forms/call-text-did-change-in-text-field-when-typing.html [ Pass ]
Added: trunk/LayoutTests/storage/indexeddb/IDBObject-leak-expected.txt (0 => 242043)
--- trunk/LayoutTests/storage/indexeddb/IDBObject-leak-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/IDBObject-leak-expected.txt 2019-02-25 16:50:20 UTC (rev 242043)
@@ -0,0 +1,10 @@
+This test verifies that IDBTransaction objects are freed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.numberOfIDBTransactions() is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/storage/indexeddb/IDBObject-leak.html (0 => 242043)
--- trunk/LayoutTests/storage/indexeddb/IDBObject-leak.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/IDBObject-leak.html 2019-02-25 16:50:20 UTC (rev 242043)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<script src=""
+<script src=""
+<script>
+description('This test verifies that IDBTransaction objects are freed.');
+
+jsTestIsAsync = true;
+
+function test() {
+ if (!window.internals || !internals.numberOfIDBTransactions) {
+ testFailed('This test requires access to the Internals object');
+ finishJSTest();
+ return;
+ }
+
+ if (sessionStorage.doneFirstLoad) {
+ gc();
+ shouldBeEqualToNumber("internals.numberOfIDBTransactions()", 0);
+ finishJSTest();
+ return;
+ }
+
+ var dbname = setDBNameFromPath() + Date();
+ var request = window.indexedDB.open(dbname);
+ request._onupgradeneeded_ = function(evt) {
+ sessionStorage.doneFirstLoad = true;
+ if (!window.testRunner || !testRunner.terminateNetworkProcess) {
+ testFailed('This test requires access to the TestRunner object and terminateNetworkProcess() function');
+ finishJSTest();
+ return;
+ }
+ testRunner.terminateNetworkProcess();
+ setTimeout((()=> {
+ location.reload();
+ }), 0);
+ }
+}
+
+test();
+</script>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (242042 => 242043)
--- trunk/Source/WebCore/ChangeLog 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/Source/WebCore/ChangeLog 2019-02-25 16:50:20 UTC (rev 242043)
@@ -1,3 +1,30 @@
+2019-02-25 Sihui Liu <[email protected]>
+
+ IndexedDB: IDBDatabase and IDBTransaction are leaked in layout tests
+ https://bugs.webkit.org/show_bug.cgi?id=194709
+
+ Reviewed by Geoffrey Garen.
+
+ When connection to IDB server is closed, IDBTransaction would abort without notifying IDBDatabase, so
+ IDBDatabase didn't clear its reference to IDBTransaction which created a reference cycle.
+
+ Also IDBTransaction didn't clear its reference to IDBRequest in this case and it led to another reference cycle
+ between IDBOpenDBRequest and IDBTransaction.
+
+ Test: storage/indexeddb/IDBObject-leak.html
+
+ * Modules/indexeddb/IDBDatabase.cpp:
+ (WebCore::IDBDatabase::connectionToServerLost):
+ * Modules/indexeddb/IDBTransaction.cpp:
+ (WebCore::IDBTransaction::IDBTransaction):
+ (WebCore::IDBTransaction::~IDBTransaction):
+ (WebCore::IDBTransaction::connectionClosedFromServer):
+ * Modules/indexeddb/IDBTransaction.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::numberOfIDBTransactions const):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2019-02-25 Zalan Bujtas <[email protected]>
Add missing stream parameter. Unreviewed.
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (242042 => 242043)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2019-02-25 16:50:20 UTC (rev 242043)
@@ -264,7 +264,8 @@
m_closePending = true;
m_closedInServer = true;
- for (auto& transaction : m_activeTransactions.values())
+ auto transactions = copyToVector(m_activeTransactions.values());
+ for (auto& transaction : transactions)
transaction->connectionClosedFromServer(error);
auto errorEvent = Event::create(m_eventNames.errorEvent, Event::CanBubble::Yes, Event::IsCancelable::No);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (242042 => 242043)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp 2019-02-25 16:50:20 UTC (rev 242043)
@@ -59,6 +59,8 @@
namespace WebCore {
using namespace JSC;
+std::atomic<unsigned> IDBTransaction::numberOfIDBTransactions { 0 };
+
Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info)
{
return adoptRef(*new IDBTransaction(database, info, nullptr));
@@ -82,6 +84,8 @@
LOG(IndexedDB, "IDBTransaction::IDBTransaction - %s", m_info.loggingString().utf8().data());
ASSERT(&m_database->originThread() == &Thread::current());
+ ++numberOfIDBTransactions;
+
if (m_info.mode() == IDBTransactionMode::Versionchange) {
ASSERT(m_openDBRequest);
m_openDBRequest->setVersionChangeTransaction(*this);
@@ -105,6 +109,7 @@
IDBTransaction::~IDBTransaction()
{
+ --numberOfIDBTransactions;
ASSERT(&m_database->originThread() == &Thread::current());
}
@@ -1434,7 +1439,8 @@
{
LOG(IndexedDB, "IDBTransaction::connectionClosedFromServer - %s", error.message().utf8().data());
- m_state = IndexedDB::TransactionState::Aborting;
+ m_database->willAbortTransaction(*this);
+ transitionedToFinishing(IndexedDB::TransactionState::Aborting);
abortInProgressOperations(error);
@@ -1445,6 +1451,7 @@
ASSERT(m_transactionOperationsInProgressQueue.first() == operation.get());
operation->doComplete(IDBResultData::error(operation->identifier(), error));
}
+ m_currentlyCompletingRequest = nullptr;
connectionProxy().forgetActiveOperations(operations);
@@ -1454,6 +1461,7 @@
m_idbError = error;
m_domError = error.toDOMException();
+ m_database->didAbortTransaction(*this);
fireOnAbort();
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h (242042 => 242043)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h 2019-02-25 16:50:20 UTC (rev 242043)
@@ -152,6 +152,8 @@
void visitReferencedObjectStores(JSC::SlotVisitor&) const;
+ WEBCORE_EXPORT static std::atomic<unsigned> numberOfIDBTransactions;
+
private:
IDBTransaction(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest*);
Modified: trunk/Source/WebCore/testing/Internals.cpp (242042 => 242043)
--- trunk/Source/WebCore/testing/Internals.cpp 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/Source/WebCore/testing/Internals.cpp 2019-02-25 16:50:20 UTC (rev 242043)
@@ -93,6 +93,8 @@
#include "HistoryController.h"
#include "HistoryItem.h"
#include "HitTestResult.h"
+#include "IDBRequest.h"
+#include "IDBTransaction.h"
#include "InspectorClient.h"
#include "InspectorController.h"
#include "InspectorFrontendClientLocal.h"
@@ -2374,6 +2376,11 @@
return document->page()->countFindMatches(text, parsedOptions.releaseReturnValue(), 1000);
}
+unsigned Internals::numberOfIDBTransactions() const
+{
+ return IDBTransaction::numberOfIDBTransactions;
+}
+
unsigned Internals::numberOfLiveNodes() const
{
unsigned nodeCount = 0;
Modified: trunk/Source/WebCore/testing/Internals.h (242042 => 242043)
--- trunk/Source/WebCore/testing/Internals.h 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/Source/WebCore/testing/Internals.h 2019-02-25 16:50:20 UTC (rev 242043)
@@ -378,6 +378,8 @@
ExceptionOr<void> insertAuthorCSS(const String&) const;
ExceptionOr<void> insertUserCSS(const String&) const;
+ unsigned numberOfIDBTransactions() const;
+
unsigned numberOfLiveNodes() const;
unsigned numberOfLiveDocuments() const;
unsigned referencingNodeCount(const Document&) const;
Modified: trunk/Source/WebCore/testing/Internals.idl (242042 => 242043)
--- trunk/Source/WebCore/testing/Internals.idl 2019-02-25 16:10:31 UTC (rev 242042)
+++ trunk/Source/WebCore/testing/Internals.idl 2019-02-25 16:50:20 UTC (rev 242043)
@@ -405,6 +405,8 @@
void beginSimulatedMemoryPressure();
void endSimulatedMemoryPressure();
+ unsigned long numberOfIDBTransactions();
+
unsigned long numberOfLiveNodes();
unsigned long numberOfLiveDocuments();
unsigned long referencingNodeCount(Document document);