[iOS] Web process gets suspended while holding locked database files
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Apr 2019 01:02:44 +0000 (01:02 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Apr 2019 01:02:44 +0000 (01:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196519
<rdar://problem/49531797>

Reviewed by Chris Dumez.

Source/WebCore:

Don't use DatabaseTracker singleton before it is initialized.

* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::isInitialized):
* Modules/webdatabase/DatabaseTracker.h:

Source/WebKit:

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::actualPrepareToSuspend):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243957 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebProcess.cpp

index 53828bd..fe639d9 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-05  Sihui Liu  <sihui_liu@apple.com>
+
+        [iOS] Web process gets suspended while holding locked database files
+        https://bugs.webkit.org/show_bug.cgi?id=196519
+        <rdar://problem/49531797>
+
+        Reviewed by Chris Dumez.
+
+        Don't use DatabaseTracker singleton before it is initialized.
+
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::isInitialized):
+        * Modules/webdatabase/DatabaseTracker.h:
+
 2019-04-05  Ryosuke Niwa  <rniwa@webkit.org>
 
         Make WeakPtr<Element> possible and deploy it in form associated elements code
index 437d56a..d8ddcc5 100644 (file)
@@ -80,6 +80,11 @@ void DatabaseTracker::initializeTracker(const String& databasePath)
     staticTracker = new DatabaseTracker(databasePath);
 }
 
+bool DatabaseTracker::isInitialized()
+{
+    return !!staticTracker;
+}
+
 DatabaseTracker& DatabaseTracker::singleton()
 {
     if (!staticTracker)
index 1a3b12d..4219089 100644 (file)
@@ -59,6 +59,7 @@ public:
     static void initializeTracker(const String& databasePath);
 
     WEBCORE_EXPORT static DatabaseTracker& singleton();
+    WEBCORE_EXPORT static bool isInitialized();
     // This singleton will potentially be used from multiple worker threads and the page's context thread simultaneously.  To keep this safe, it's
     // currently using 4 locks.  In order to avoid deadlock when taking multiple locks, you must take them in the correct order:
     // m_databaseGuard before quotaManager if both locks are needed.
index 756328e..b3ec43a 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-05  Sihui Liu  <sihui_liu@apple.com>
+
+        [iOS] Web process gets suspended while holding locked database files
+        https://bugs.webkit.org/show_bug.cgi?id=196519
+        <rdar://problem/49531797>
+
+        Reviewed by Chris Dumez.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::actualPrepareToSuspend):
+
 2019-04-05  Alex Christensen  <achristensen@webkit.org>
 
         Clicking "Go Back" from a safe browsing warning from an iframe should navigate the WKWebView back to the previous page
index 2add5a7..61c161f 100644 (file)
@@ -1467,7 +1467,8 @@ void WebProcess::actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend shou
 #if PLATFORM(IOS_FAMILY)
     m_webSQLiteDatabaseTracker = nullptr;
     SQLiteDatabase::setIsDatabaseOpeningForbidden(true);
-    DatabaseTracker::singleton().closeAllDatabases(CurrentQueryBehavior::Interrupt);
+    if (DatabaseTracker::isInitialized())
+        DatabaseTracker::singleton().closeAllDatabases(CurrentQueryBehavior::Interrupt);
     accessibilityProcessSuspendedNotification(true);
     updateFreezerStatus();
 #endif