Changeset 242043 in webkit


Ignore:
Timestamp:
Feb 25, 2019 8:50:20 AM (5 years ago)
Author:
sihui_liu@apple.com
Message:

IndexedDB: IDBDatabase and IDBTransaction are leaked 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::connectionClosedFromServer):

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

(WebCore::Internals::numberOfIDBTransactions const):

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

LayoutTests:

  • TestExpectations:
  • platform/wk2/TestExpectations:
  • storage/indexeddb/IDBObject-leak-expected.txt: Added.
  • storage/indexeddb/IDBObject-leak.html: Added.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r242037 r242043  
     12019-02-25  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: IDBDatabase and IDBTransaction are leaked in layout tests
     4        https://bugs.webkit.org/show_bug.cgi?id=194709
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * TestExpectations:
     9        * platform/wk2/TestExpectations:
     10        * storage/indexeddb/IDBObject-leak-expected.txt: Added.
     11        * storage/indexeddb/IDBObject-leak.html: Added.
     12
    1132019-02-25  Zan Dobersek  <zdobersek@igalia.com>
    214
  • trunk/LayoutTests/TestExpectations

    r241942 r242043  
    131131http/tests/navigation/useragent-reload.php [ Skip ]
    132132storage/indexeddb/modern/opendatabase-after-storage-crash.html [ Skip ]
     133storage/indexeddb/IDBObject-leak.html [ Skip ]
    133134fast/forms/call-text-did-change-in-text-field-when-typing.html [ Skip ]
    134135
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r241755 r242043  
    747747http/tests/navigation/useragent-reload.php [ Pass ]
    748748storage/indexeddb/modern/opendatabase-after-storage-crash.html [ Pass ]
     749storage/indexeddb/IDBObject-leak.html [ Pass ]
    749750
    750751fast/forms/call-text-did-change-in-text-field-when-typing.html [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r242041 r242043  
     12019-02-25  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: IDBDatabase and IDBTransaction are leaked 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::connectionClosedFromServer):
     22        * Modules/indexeddb/IDBTransaction.h:
     23        * testing/Internals.cpp:
     24        (WebCore::Internals::numberOfIDBTransactions const):
     25        * testing/Internals.h:
     26        * testing/Internals.idl:
     27
    1282019-02-25  Zalan Bujtas  <zalan@apple.com>
    229
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp

    r241761 r242043  
    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

    r241761 r242043  
    6060using namespace JSC;
    6161
     62std::atomic<unsigned> IDBTransaction::numberOfIDBTransactions { 0 };
     63
    6264Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info)
    6365{
     
    8385    ASSERT(&m_database->originThread() == &Thread::current());
    8486
     87    ++numberOfIDBTransactions;
     88
    8589    if (m_info.mode() == IDBTransactionMode::Versionchange) {
    8690        ASSERT(m_openDBRequest);
     
    106110IDBTransaction::~IDBTransaction()
    107111{
     112    --numberOfIDBTransactions;
    108113    ASSERT(&m_database->originThread() == &Thread::current());
    109114}
     
    14351440    LOG(IndexedDB, "IDBTransaction::connectionClosedFromServer - %s", error.message().utf8().data());
    14361441
    1437     m_state = IndexedDB::TransactionState::Aborting;
     1442    m_database->willAbortTransaction(*this);
     1443    transitionedToFinishing(IndexedDB::TransactionState::Aborting);
    14381444
    14391445    abortInProgressOperations(error);
     
    14461452        operation->doComplete(IDBResultData::error(operation->identifier(), error));
    14471453    }
     1454    m_currentlyCompletingRequest = nullptr;
    14481455
    14491456    connectionProxy().forgetActiveOperations(operations);
     
    14551462    m_idbError = error;
    14561463    m_domError = error.toDOMException();
     1464    m_database->didAbortTransaction(*this);
    14571465    fireOnAbort();
    14581466}
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h

    r241761 r242043  
    153153    void visitReferencedObjectStores(JSC::SlotVisitor&) const;
    154154
     155    WEBCORE_EXPORT static std::atomic<unsigned> numberOfIDBTransactions;
     156
    155157private:
    156158    IDBTransaction(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest*);
  • trunk/Source/WebCore/testing/Internals.cpp

    r242019 r242043  
    9494#include "HistoryItem.h"
    9595#include "HitTestResult.h"
     96#include "IDBRequest.h"
     97#include "IDBTransaction.h"
    9698#include "InspectorClient.h"
    9799#include "InspectorController.h"
     
    23752377}
    23762378
     2379unsigned Internals::numberOfIDBTransactions() const
     2380{
     2381    return IDBTransaction::numberOfIDBTransactions;
     2382}
     2383
    23772384unsigned Internals::numberOfLiveNodes() const
    23782385{
  • trunk/Source/WebCore/testing/Internals.h

    r242019 r242043  
    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

    r242019 r242043  
    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.