Diff
Modified: trunk/Source/WebCore/ChangeLog (291116 => 291117)
--- trunk/Source/WebCore/ChangeLog 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebCore/ChangeLog 2022-03-10 17:58:40 UTC (rev 291117)
@@ -1,3 +1,19 @@
+2022-03-10 Sihui Liu <[email protected]>
+
+ IndexedDB: free memory used by database connection on low-memory warning
+ https://bugs.webkit.org/show_bug.cgi?id=237673
+
+ Reviewed by Chris Dumez.
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+ * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::handleLowMemoryWarning):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::handleLowMemoryWarning):
+ * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
2022-03-10 Antoine Quint <[email protected]>
[web-animations] font-variant-position should support discrete animation
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (291116 => 291117)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2022-03-10 17:58:40 UTC (rev 291117)
@@ -96,6 +96,8 @@
virtual void close() = 0;
virtual bool hasTransaction(const IDBResourceIdentifier&) const = 0;
+ virtual void handleLowMemoryWarning() = 0;
+
protected:
IDBBackingStore() { RELEASE_ASSERT(!isMainThread()); }
};
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (291116 => 291117)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2022-03-10 17:58:40 UTC (rev 291117)
@@ -49,6 +49,7 @@
void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&);
void restoreObjectStoreForVersionChangeAbort(Ref<MemoryObjectStore>&&);
+ void handleLowMemoryWarning() final { };
private:
IDBError beginTransaction(const IDBTransactionInfo&) final;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (291116 => 291117)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2022-03-10 17:58:40 UTC (rev 291117)
@@ -2838,6 +2838,12 @@
return m_transactions.contains(transactionIdentifier);
}
+void SQLiteIDBBackingStore::handleLowMemoryWarning()
+{
+ if (m_sqliteDB)
+ m_sqliteDB->releaseMemory();
+}
+
#undef TABLE_SCHEMA_PREFIX
#undef V3_RECORDS_TABLE_SCHEMA_SUFFIX
#undef V3_INDEX_RECORDS_TABLE_SCHEMA_SUFFIX
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (291116 => 291117)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2022-03-10 17:58:40 UTC (rev 291117)
@@ -100,6 +100,7 @@
WEBCORE_EXPORT static String decodeDatabaseName(const String& encodedDatabaseName);
WEBCORE_EXPORT static std::optional<IDBDatabaseNameAndVersion> databaseNameAndVersionFromFile(const String&);
+ void handleLowMemoryWarning() final;
private:
IDBError ensureValidRecordsTable();
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (291116 => 291117)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2022-03-10 17:58:40 UTC (rev 291117)
@@ -1547,5 +1547,11 @@
return IDBDatabaseNameAndVersion { m_databaseInfo->name(), m_databaseInfo->version() };
}
+void UniqueIDBDatabase::handleLowMemoryWarning()
+{
+ if (m_backingStore)
+ m_backingStore->handleLowMemoryWarning();
+}
+
} // namespace IDBServer
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (291116 => 291117)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h 2022-03-10 17:58:40 UTC (rev 291117)
@@ -121,6 +121,7 @@
WEBCORE_EXPORT String filePath() const;
WEBCORE_EXPORT std::optional<IDBDatabaseNameAndVersion> nameAndVersion() const;
WEBCORE_EXPORT bool hasDataInMemory() const;
+ WEBCORE_EXPORT void handleLowMemoryWarning();
private:
void handleDatabaseOperations();
Modified: trunk/Source/WebKit/ChangeLog (291116 => 291117)
--- trunk/Source/WebKit/ChangeLog 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebKit/ChangeLog 2022-03-10 17:58:40 UTC (rev 291117)
@@ -1,3 +1,16 @@
+2022-03-10 Sihui Liu <[email protected]>
+
+ IndexedDB: free memory used by database connection on low-memory warning
+ https://bugs.webkit.org/show_bug.cgi?id=237673
+
+ Reviewed by Chris Dumez.
+
+ * NetworkProcess/storage/IDBStorageManager.cpp:
+ (WebKit::IDBStorageManager::handleLowMemoryWarning):
+ * NetworkProcess/storage/IDBStorageManager.h:
+ * NetworkProcess/storage/NetworkStorageManager.cpp:
+ (WebKit::NetworkStorageManager::handleLowMemoryWarning):
+
2022-03-10 Chris Dumez <[email protected]>
Unreviewed, reverting r290795.
Modified: trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp (291116 => 291117)
--- trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp 2022-03-10 17:58:40 UTC (rev 291117)
@@ -277,4 +277,10 @@
m_quotaCheckFunction(size, WTFMove(completionHandler));
}
+void IDBStorageManager::handleLowMemoryWarning()
+{
+ for (auto& database : m_databases.values())
+ database->handleLowMemoryWarning();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.h (291116 => 291117)
--- trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.h 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.h 2022-03-10 17:58:40 UTC (rev 291117)
@@ -58,6 +58,7 @@
bool hasDataInMemory() const;
void closeDatabasesForDeletion();
void stopDatabaseActivitiesForSuspend();
+ void handleLowMemoryWarning();
void openDatabase(WebCore::IDBServer::IDBConnectionToClient&, const WebCore::IDBRequestData&);
void openDBRequestCancelled(const WebCore::IDBRequestData&);
Modified: trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp (291116 => 291117)
--- trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp 2022-03-10 17:56:29 UTC (rev 291116)
+++ trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp 2022-03-10 17:58:40 UTC (rev 291117)
@@ -668,6 +668,8 @@
for (auto& manager : m_localOriginStorageManagers.values()) {
if (auto localStorageManager = manager->existingLocalStorageManager())
localStorageManager->handleLowMemoryWarning();
+ if (auto idbStorageManager = manager->existingIDBStorageManager())
+ idbStorageManager->handleLowMemoryWarning();
}
});
}