Changeset 241722 in webkit


Ignore:
Timestamp:
Feb 18, 2019 9:30:18 AM (5 years ago)
Author:
sihui_liu@apple.com
Message:

IndexedDB: leak IDBDatabase and IDBTransacstion in layout tests
https://bugs.webkit.org/show_bug.cgi?id=194709

Reviewed by Geoffrey Garen.

Source/WebCore:

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::finishedDispatchEventForRequest):
(WebCore::IDBTransaction::connectionClosedFromServer):

  • Modules/indexeddb/IDBTransaction.h:
  • testing/Internals.cpp:

(WebCore::Internals::numberOfIDBTransactions const):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

  • storage/indexeddb/IDBObject-leak.html: Added.
Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r241719 r241722  
     12019-02-18  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: leak IDBDatabase and IDBTransacstion in layout tests
     4        https://bugs.webkit.org/show_bug.cgi?id=194709
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * storage/indexeddb/IDBObject-leak.html: Added.
     9
    1102019-02-18  Megan Gardner  <megan_gardner@apple.com>
    211
  • trunk/Source/WebCore/ChangeLog

    r241721 r241722  
     12019-02-18  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: leak IDBDatabase and IDBTransacstion in layout tests
     4        https://bugs.webkit.org/show_bug.cgi?id=194709
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        When connection to IDB server is closed, IDBTransaction would abort without notifying IDBDatabase, so
     9        IDBDatabase didn't clear its reference to IDBTransaction which created a reference cycle.
     10
     11        Also IDBTransaction didn't clear its reference to IDBRequest in this case and it led to another reference cycle
     12        between IDBOpenDBRequest and IDBTransaction.
     13
     14        Test: storage/indexeddb/IDBObject-leak.html
     15
     16        * Modules/indexeddb/IDBDatabase.cpp:
     17        (WebCore::IDBDatabase::connectionToServerLost):
     18        * Modules/indexeddb/IDBTransaction.cpp:
     19        (WebCore::IDBTransaction::IDBTransaction):
     20        (WebCore::IDBTransaction::~IDBTransaction):
     21        (WebCore::IDBTransaction::finishedDispatchEventForRequest):
     22        (WebCore::IDBTransaction::connectionClosedFromServer):
     23        * Modules/indexeddb/IDBTransaction.h:
     24        * testing/Internals.cpp:
     25        (WebCore::Internals::numberOfIDBTransactions const):
     26        * testing/Internals.h:
     27        * testing/Internals.idl:
     28
    1292019-02-18  Chris Fleizach  <cfleizach@apple.com>
    230
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp

    r239535 r241722  
    265265    m_closedInServer = true;
    266266
    267     for (auto& transaction : m_activeTransactions.values())
     267    auto transactions = copyToVector(m_activeTransactions.values());
     268    for (auto& transaction : transactions)
    268269        transaction->connectionClosedFromServer(error);
    269270
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp

    r240658 r241722  
    8080
    8181{
     82    auto addResult = allIDBTransactions().add(this);
     83    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     84
    8285    LOG(IndexedDB, "IDBTransaction::IDBTransaction - %s", m_info.loggingString().utf8().data());
    8386    ASSERT(&m_database->originThread() == &Thread::current());
     
    107110{
    108111    ASSERT(&m_database->originThread() == &Thread::current());
     112    ASSERT(allIDBTransactions().contains(this));
     113    allIDBTransactions().remove(this);
     114}
     115
     116HashSet<IDBTransaction*>& IDBTransaction::allIDBTransactions()
     117{
     118    static NeverDestroyed<HashSet<IDBTransaction*>> transactions;
     119    return transactions;
    109120}
    110121
     
    14351446    LOG(IndexedDB, "IDBTransaction::connectionClosedFromServer - %s", error.message().utf8().data());
    14361447
    1437     m_state = IndexedDB::TransactionState::Aborting;
     1448    m_database->willAbortTransaction(*this);
     1449    transitionedToFinishing(IndexedDB::TransactionState::Aborting);
    14381450
    14391451    abortInProgressOperations(error);
     
    14461458        operation->doComplete(IDBResultData::error(operation->identifier(), error));
    14471459    }
     1460    m_currentlyCompletingRequest = nullptr;
    14481461
    14491462    connectionProxy().forgetActiveOperations(operations);
     
    14551468    m_idbError = error;
    14561469    m_domError = error.toDOMException();
     1470    m_database->didAbortTransaction(*this);
    14571471    fireOnAbort();
    14581472}
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h

    r240658 r241722  
    153153    void visitReferencedObjectStores(JSC::SlotVisitor&) const;
    154154
     155    WEBCORE_EXPORT static HashSet<IDBTransaction*>& allIDBTransactions();
     156
    155157private:
    156158    IDBTransaction(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest*);
  • trunk/Source/WebCore/testing/Internals.cpp

    r241480 r241722  
    9494#include "HistoryItem.h"
    9595#include "HitTestResult.h"
     96#include "IDBRequest.h"
     97#include "IDBTransaction.h"
    9698#include "InspectorClient.h"
    9799#include "InspectorController.h"
     
    23842386}
    23852387
     2388unsigned Internals::numberOfIDBTransactions() const
     2389{
     2390    return IDBTransaction::allIDBTransactions().size();
     2391}
     2392
    23862393unsigned Internals::numberOfLiveNodes() const
    23872394{
  • trunk/Source/WebCore/testing/Internals.h

    r241480 r241722  
    379379    ExceptionOr<void> insertUserCSS(const String&) const;
    380380
     381    unsigned numberOfIDBTransactions() const;
     382
    381383    unsigned numberOfLiveNodes() const;
    382384    unsigned numberOfLiveDocuments() const;
  • trunk/Source/WebCore/testing/Internals.idl

    r241480 r241722  
    406406    void endSimulatedMemoryPressure();
    407407
     408    unsigned long numberOfIDBTransactions();
     409
    408410    unsigned long numberOfLiveNodes();
    409411    unsigned long numberOfLiveDocuments();
Note: See TracChangeset for help on using the changeset viewer.