Title: [290544] trunk
- Revision
- 290544
- Author
- [email protected]
- Date
- 2022-02-25 21:42:38 -0800 (Fri, 25 Feb 2022)
Log Message
[macOS] TestWebKitAPI.WebKit.MigrateLocalStorageDataToGeneralStorageDirectory is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=237065
<rdar://problem/89324250>
Reviewed by Alexey Proskuryakov.
Source/WebKit:
Commit transactions of SQLiteStorageArea at exit of network process.
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::didClose):
* NetworkProcess/storage/SQLiteStorageArea.cpp:
(WebKit::commitTransactionsAtExit):
(WebKit::SQLiteStorageArea::SQLiteStorageArea):
(WebKit::SQLiteStorageArea::startTransactionIfNecessary):
(WebKit::SQLiteStorageArea::commitTransactionIfNecessary):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (290543 => 290544)
--- trunk/Source/WebKit/ChangeLog 2022-02-26 05:38:48 UTC (rev 290543)
+++ trunk/Source/WebKit/ChangeLog 2022-02-26 05:42:38 UTC (rev 290544)
@@ -1,3 +1,21 @@
+2022-02-25 Sihui Liu <[email protected]>
+
+ [macOS] TestWebKitAPI.WebKit.MigrateLocalStorageDataToGeneralStorageDirectory is a flaky failure
+ https://bugs.webkit.org/show_bug.cgi?id=237065
+ <rdar://problem/89324250>
+
+ Reviewed by Alexey Proskuryakov.
+
+ Commit transactions of SQLiteStorageArea at exit of network process.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::didClose):
+ * NetworkProcess/storage/SQLiteStorageArea.cpp:
+ (WebKit::commitTransactionsAtExit):
+ (WebKit::SQLiteStorageArea::SQLiteStorageArea):
+ (WebKit::SQLiteStorageArea::startTransactionIfNecessary):
+ (WebKit::SQLiteStorageArea::commitTransactionIfNecessary):
+
2022-02-25 Wenson Hsieh <[email protected]>
Adjust -[WKContentView _requiresKeyboardWhenFirstResponder] to account for editable web views
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (290543 => 290544)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2022-02-26 05:38:48 UTC (rev 290543)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2022-02-26 05:42:38 UTC (rev 290544)
@@ -261,9 +261,10 @@
stopRunLoop();
});
- // Make sure we flush all cookies to disk before exiting.
forEachNetworkSession([&] (auto& session) {
platformFlushCookies(session.sessionID(), [callbackAggregator] { });
+ if (auto* storageManager = session.storageManager())
+ storageManager->syncLocalStorage([callbackAggregator] { });
});
}
Modified: trunk/Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.cpp (290543 => 290544)
--- trunk/Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.cpp 2022-02-26 05:38:48 UTC (rev 290543)
+++ trunk/Source/WebKit/NetworkProcess/storage/SQLiteStorageArea.cpp 2022-02-26 05:42:38 UTC (rev 290544)
@@ -62,6 +62,20 @@
return ""_s;
}
+static Lock allTransactionsLock;
+static HashSet<WebCore::SQLiteTransaction*>& allTransactions() WTF_REQUIRES_LOCK(allTransactionsLock)
+{
+ static NeverDestroyed<HashSet<WebCore::SQLiteTransaction*>> transactions;
+ return transactions;
+}
+
+static void commitTransactionsAtExit()
+{
+ Locker lock { allTransactionsLock };
+ for (auto* transaction : allTransactions())
+ transaction->commit();
+}
+
SQLiteStorageArea::SQLiteStorageArea(unsigned quota, const WebCore::ClientOrigin& origin, const String& path, Ref<WorkQueue>&& workQueue)
: StorageAreaBase(quota, origin)
, m_path(path)
@@ -68,7 +82,12 @@
, m_queue(WTFMove(workQueue))
, m_cachedStatements(static_cast<size_t>(StatementType::Invalid))
{
- ASSERT(!isMainRunLoop());
+ ASSERT(!isMainRunLoop());
+
+ static std::once_flag once;
+ std::call_once(once, [] {
+ std::atexit(commitTransactionsAtExit);
+ });
}
void SQLiteStorageArea::close()
@@ -186,16 +205,18 @@
if (!m_transaction)
m_transaction = makeUnique<WebCore::SQLiteTransaction>(*m_database);
- if (m_transaction->inProgress())
- return;
+ {
+ Locker lock { allTransactionsLock };
+ if (m_transaction->inProgress())
+ return;
- m_transaction->begin();
+ m_transaction->begin();
+ allTransactions().add(m_transaction.get());
+ }
+
m_queue->dispatchAfter(transactionDuration, [weakThis = WeakPtr { *this }] {
- if (!weakThis || !weakThis->m_transaction)
- return;
-
- auto transaction = std::exchange(weakThis->m_transaction, nullptr);
- transaction->commit();
+ if (weakThis)
+ weakThis->commitTransactionIfNecessary();
});
}
@@ -398,8 +419,13 @@
void SQLiteStorageArea::commitTransactionIfNecessary()
{
- if (auto transaction = std::exchange(m_transaction, nullptr))
- transaction->commit();
+ auto transaction = std::exchange(m_transaction, nullptr);
+ if (!transaction)
+ return;
+
+ Locker lock { allTransactionsLock };
+ transaction->commit();
+ allTransactions().remove(transaction.get());
}
void SQLiteStorageArea::handleLowMemoryWarning()
Modified: trunk/Tools/ChangeLog (290543 => 290544)
--- trunk/Tools/ChangeLog 2022-02-26 05:38:48 UTC (rev 290543)
+++ trunk/Tools/ChangeLog 2022-02-26 05:42:38 UTC (rev 290544)
@@ -1,3 +1,14 @@
+2022-02-25 Sihui Liu <[email protected]>
+
+ [macOS] TestWebKitAPI.WebKit.MigrateLocalStorageDataToGeneralStorageDirectory is a flaky failure
+ https://bugs.webkit.org/show_bug.cgi?id=237065
+ <rdar://problem/89324250>
+
+ Reviewed by Alexey Proskuryakov.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+ (TEST):
+
2022-02-25 Wenson Hsieh <[email protected]>
Adjust -[WKContentView _requiresKeyboardWhenFirstResponder] to account for editable web views
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (290543 => 290544)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm 2022-02-26 05:38:48 UTC (rev 290543)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm 2022-02-26 05:42:38 UTC (rev 290544)
@@ -850,6 +850,7 @@
TestWebKitAPI::Util::run(&receivedScriptMessage);
EXPECT_WK_STREQ("testvalue", getNextMessage().body);
EXPECT_TRUE([fileManager fileExistsAtPath:localStorageFile.path]);
+ EXPECT_FALSE([fileManager fileExistsAtPath:newLocalStorageFile.path]);
}
// Create a new WebsiteDataStore that performs migration.
@@ -862,7 +863,7 @@
[thirdWebView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"https://webkit.org/"]];
TestWebKitAPI::Util::run(&receivedScriptMessage);
EXPECT_WK_STREQ("testvalue", getNextMessage().body);
- EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:localStorageFile.path]);
+ EXPECT_FALSE([fileManager fileExistsAtPath:localStorageFile.path]);
EXPECT_TRUE([fileManager fileExistsAtPath:newLocalStorageFile.path]);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes