WebKit Bugzilla
Attachment 362773 Details for
Bug 194709
: IndexedDB: IDBDatabase and IDBTransaction are leaked in layout tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194709-20190222155114.patch (text/plain), 11.50 KB, created by
Sihui Liu
on 2019-02-22 15:51:15 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sihui Liu
Created:
2019-02-22 15:51:15 PST
Size:
11.50 KB
patch
obsolete
>Subversion Revision: 241963 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 8e793d00f733f8073f2e44115fdb41270b0b65c5..8f0567c68007949113ed1cf4916987b626a1bb65 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2019-02-22 Sihui Liu <sihui_liu@apple.com> >+ >+ IndexedDB: IDBDatabase and IDBTransaction are leaked in layout tests >+ https://bugs.webkit.org/show_bug.cgi?id=194709 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-22 Wenson Hsieh <wenson_hsieh@apple.com> > > Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >index 1847439190a8b79bef706432fd2f9d7556907365..0a095725fd2fbd324b957118924149eba26364e7 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >@@ -264,7 +264,8 @@ void IDBDatabase::connectionToServerLost(const IDBError& error) > 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); >diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >index 2e965e97d2909ec0c70f3f8741a188ff6c549b2f..a3995d3210680facbc8358027a9efac00683ba55 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >@@ -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 @@ IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& > 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(IDBDatabase& database, const IDBTransactionInfo& > > IDBTransaction::~IDBTransaction() > { >+ --numberOfIDBTransactions; > ASSERT(&m_database->originThread() == &Thread::current()); > } > >@@ -1434,7 +1439,8 @@ void IDBTransaction::connectionClosedFromServer(const IDBError& error) > { > 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 @@ void IDBTransaction::connectionClosedFromServer(const IDBError& error) > ASSERT(m_transactionOperationsInProgressQueue.first() == operation.get()); > operation->doComplete(IDBResultData::error(operation->identifier(), error)); > } >+ m_currentlyCompletingRequest = nullptr; > > connectionProxy().forgetActiveOperations(operations); > >@@ -1454,6 +1461,7 @@ void IDBTransaction::connectionClosedFromServer(const IDBError& error) > > m_idbError = error; > m_domError = error.toDOMException(); >+ m_database->didAbortTransaction(*this); > fireOnAbort(); > } > >diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.h b/Source/WebCore/Modules/indexeddb/IDBTransaction.h >index 722f12c84a787dc1a32a33bc5d236f0cecdc4f04..6a2815f539120e367e17a1dadc0d39617fa014c4 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBTransaction.h >+++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.h >@@ -152,6 +152,8 @@ public: > > void visitReferencedObjectStores(JSC::SlotVisitor&) const; > >+ WEBCORE_EXPORT static std::atomic<unsigned> numberOfIDBTransactions; >+ > private: > IDBTransaction(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest*); > >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 73b6776bb2dfb20ae5a8781c5e6980aa6276de6e..7cf81d174969993228d953f5940828d328a464aa 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -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" >@@ -2383,6 +2385,11 @@ ExceptionOr<unsigned> Internals::countFindMatches(const String& text, const Vect > return document->page()->countFindMatches(text, parsedOptions.releaseReturnValue(), 1000); > } > >+unsigned Internals::numberOfIDBTransactions() const >+{ >+ return IDBTransaction::numberOfIDBTransactions; >+} >+ > unsigned Internals::numberOfLiveNodes() const > { > unsigned nodeCount = 0; >diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h >index 8430fd973a0292ad3f0b119774123776b1b7e3de..df84c6784fa346fe223dfcb951699d0bf7b8d362 100644 >--- a/Source/WebCore/testing/Internals.h >+++ b/Source/WebCore/testing/Internals.h >@@ -379,6 +379,8 @@ public: > 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; >diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl >index 3bc508dc1e191bbc27fa9117bba9060194306546..7ccdc77ac7b9f25e8df4a7ccf1211856b2de5d92 100644 >--- a/Source/WebCore/testing/Internals.idl >+++ b/Source/WebCore/testing/Internals.idl >@@ -406,6 +406,8 @@ enum CompositingPolicy { > void beginSimulatedMemoryPressure(); > void endSimulatedMemoryPressure(); > >+ unsigned long numberOfIDBTransactions(); >+ > unsigned long numberOfLiveNodes(); > unsigned long numberOfLiveDocuments(); > unsigned long referencingNodeCount(Document document); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 929b955bd70916303fbb84ffdf147e0c04531505..91ffc18296a2bdab6330f69a78ae2a25020812c7 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-22 Sihui Liu <sihui_liu@apple.com> >+ >+ IndexedDB: IDBDatabase and IDBTransaction are leaked in layout tests >+ https://bugs.webkit.org/show_bug.cgi?id=194709 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestExpectations: >+ * platform/wk2/TestExpectations: >+ * storage/indexeddb/IDBObject-leak-expected.txt: Added. >+ * storage/indexeddb/IDBObject-leak.html: Added. >+ > 2019-02-22 Wenson Hsieh <wenson_hsieh@apple.com> > > Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index 29817deb360d9236e2deaa323320dd1eb60ed353..ada9652d48d21a681f6190580a4dda2b6d5e13e8 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -130,6 +130,7 @@ http/tests/storageAccess/ [ Skip ] > 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(). >diff --git a/LayoutTests/platform/wk2/TestExpectations b/LayoutTests/platform/wk2/TestExpectations >index 42d447e536b1573e903040a69a385f793a48400a..c40ff4402a061abaf6a840722556e7256f766e17 100644 >--- a/LayoutTests/platform/wk2/TestExpectations >+++ b/LayoutTests/platform/wk2/TestExpectations >@@ -746,6 +746,7 @@ http/wpt/cross-origin-resource-policy/ [ Pass ] > > 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 ] > >diff --git a/LayoutTests/storage/indexeddb/IDBObject-leak-expected.txt b/LayoutTests/storage/indexeddb/IDBObject-leak-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..b286595a5bdb0f7b0982880b1f9f3170420539c8 >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/IDBObject-leak-expected.txt >@@ -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 >+ >diff --git a/LayoutTests/storage/indexeddb/IDBObject-leak.html b/LayoutTests/storage/indexeddb/IDBObject-leak.html >new file mode 100644 >index 0000000000000000000000000000000000000000..e18b68b91ac7f6195a1e1e111af4cad03b863c57 >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/IDBObject-leak.html >@@ -0,0 +1,40 @@ >+<!DOCTYPE html> >+<script src="../../resources/js-test.js"></script> >+<script src="resources/shared.js"></script> >+<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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194709
:
362122
|
362196
|
362300
|
362332
|
362346
|
362353
|
362356
|
362504
|
362509
|
362516
|
362517
| 362773