Title: [265433] trunk/Source/WebKit
Revision
265433
Author
[email protected]
Date
2020-08-10 09:51:17 -0700 (Mon, 10 Aug 2020)

Log Message

Always suspend IDB work when network process is prepared to suspend
https://bugs.webkit.org/show_bug.cgi?id=215239
<rdar://problem/65690450>

Reviewed by Geoffrey Garen.

We do not suspend IDB work in the network process when there is an ongoing transaction because the network
process is going to ask the UI process to hold a background process assertion for it. However, it is possible
that the request from the network process does not reach the UI process in time: RunningBoard may already decide
to suspend the network process after app is backgrounded and UI process drops the foreground assertion for the
network process.

In this case, IDB in the network process would continue its transaction and the network process will be killed
when it becomes suspened for holding database file locks. A network process crash can lead to a worse result
than suspending IDB work, which aborts ongoing transactions, because it will destroy all database connections
and transaction. Therefore, let's just suspend IDB work when the network process receives prepareToSuspend
message.

* NetworkProcess/IndexedDB/WebIDBServer.cpp:
(WebKit::WebIDBServer::suspend):
* NetworkProcess/IndexedDB/WebIDBServer.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::prepareToSuspend):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (265432 => 265433)


--- trunk/Source/WebKit/ChangeLog	2020-08-10 16:41:47 UTC (rev 265432)
+++ trunk/Source/WebKit/ChangeLog	2020-08-10 16:51:17 UTC (rev 265433)
@@ -1,3 +1,29 @@
+2020-08-10  Sihui Liu  <[email protected]>
+
+        Always suspend IDB work when network process is prepared to suspend
+        https://bugs.webkit.org/show_bug.cgi?id=215239
+        <rdar://problem/65690450>
+
+        Reviewed by Geoffrey Garen.
+
+        We do not suspend IDB work in the network process when there is an ongoing transaction because the network 
+        process is going to ask the UI process to hold a background process assertion for it. However, it is possible 
+        that the request from the network process does not reach the UI process in time: RunningBoard may already decide
+        to suspend the network process after app is backgrounded and UI process drops the foreground assertion for the 
+        network process. 
+
+        In this case, IDB in the network process would continue its transaction and the network process will be killed 
+        when it becomes suspened for holding database file locks. A network process crash can lead to a worse result 
+        than suspending IDB work, which aborts ongoing transactions, because it will destroy all database connections 
+        and transaction. Therefore, let's just suspend IDB work when the network process receives prepareToSuspend 
+        message.
+
+        * NetworkProcess/IndexedDB/WebIDBServer.cpp:
+        (WebKit::WebIDBServer::suspend):
+        * NetworkProcess/IndexedDB/WebIDBServer.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::prepareToSuspend):
+
 2020-08-10  Per Arne Vollan  <[email protected]>
 
         Add required entitlement for Catalyst

Modified: trunk/Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.cpp (265432 => 265433)


--- trunk/Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.cpp	2020-08-10 16:41:47 UTC (rev 265432)
+++ trunk/Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.cpp	2020-08-10 16:51:17 UTC (rev 265433)
@@ -102,13 +102,10 @@
     });
 }
 
-void WebIDBServer::suspend(ShouldForceStop shouldForceStop)
+void WebIDBServer::suspend()
 {
     ASSERT(RunLoop::isMain());
 
-    if (shouldForceStop == ShouldForceStop::No && WebCore::SQLiteDatabaseTracker::hasTransactionInProgress())
-        return;
-
     if (m_isSuspended)
         return;
 

Modified: trunk/Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.h (265432 => 265433)


--- trunk/Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.h	2020-08-10 16:41:47 UTC (rev 265432)
+++ trunk/Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.h	2020-08-10 16:51:17 UTC (rev 265433)
@@ -51,8 +51,7 @@
     void closeAndDeleteDatabasesForOrigins(const Vector<WebCore::SecurityOriginData>&, CompletionHandler<void()>&& callback);
     void renameOrigin(const WebCore::SecurityOriginData&, const WebCore::SecurityOriginData&, CompletionHandler<void()>&&);
 
-    enum class ShouldForceStop : bool { No, Yes };
-    void suspend(ShouldForceStop);
+    void suspend();
     void resume();
 
     // Message handlers.

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (265432 => 265433)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2020-08-10 16:41:47 UTC (rev 265432)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2020-08-10 16:51:17 UTC (rev 265433)
@@ -2288,7 +2288,7 @@
 
 #if PLATFORM(IOS_FAMILY) && ENABLE(INDEXED_DATABASE)
     for (auto& server : m_webIDBServers.values())
-        server->suspend(isSuspensionImminent ? WebIDBServer::ShouldForceStop::Yes : WebIDBServer::ShouldForceStop::No);
+        server->suspend();
 #endif
 
 #if PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to