Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3c147a65020032532b2d3e4440846e80727b1f86
      
https://github.com/WebKit/WebKit/commit/3c147a65020032532b2d3e4440846e80727b1f86
  Author: Brandon Stewart <[email protected]>
  Date:   2026-03-10 (Tue, 10 Mar 2026)

  Changed paths:
    A 
LayoutTests/storage/indexeddb/modern/idb-operations-during-network-process-crash-expected.txt
    A 
LayoutTests/storage/indexeddb/modern/idb-operations-during-network-process-crash.html
    M 
LayoutTests/storage/indexeddb/modern/opendatabase-after-storage-crash-expected.txt
    M LayoutTests/storage/indexeddb/modern/opendatabase-after-storage-crash.html
    A 
LayoutTests/storage/indexeddb/modern/resources/worker-idb-after-network-crash.js
    A 
LayoutTests/storage/indexeddb/modern/worker-idb-after-network-crash-expected.txt
    A LayoutTests/storage/indexeddb/modern/worker-idb-after-network-crash.html
    M Source/WebCore/Modules/indexeddb/IDBFactory.cpp
    M Source/WebCore/Modules/indexeddb/IDBFactory.h
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebCore/workers/WorkerGlobalScope.cpp
    M Source/WebCore/workers/WorkerGlobalScope.h
    M Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
    M Source/WebKit/WebProcess/WebProcess.cpp
    M Source/WebKit/WebProcess/WebProcess.h

  Log Message:
  -----------
  [IndexedDB] Recover IndexedDB connections after network process crash without 
page reload
https://bugs.webkit.org/show_bug.cgi?id=309386
rdar://171932720

Reviewed by Sihui Liu.

When the network process crashes, all IDB connections become invalid. Previously
this required a page reload to re-establish IndexedDB access. This change makes
recovery automatic by clearing and lazily recreating the IDB connection proxy at
each layer of the stack.

On crash, networkProcessConnectionClosed now calls 
clearIDBConnectionOnAllDocuments
(replacing clearIDBConnection) so each Document's cached m_idbConnectionProxy is
nulled out alongside the Page's own connection. On the next indexedDB access,
Document::idbConnectionProxy() lazily recreates the proxy from the Page's 
freshly
established IDB connection.

IDBFactory (window.indexedDB) stays alive across crashes to satisfy the spec
requirement that it always returns the same object. Each IDBFactory entry point
calls ensureConnectionProxy(), which detects when the ScriptExecutionContext's
proxy has changed (because the Document re-derived it from a new Page 
connection)
and swaps in the new proxy.

Worker proxy refresh is deferred: NetworkProcessConnection::didClose sets a
m_needsIDBConnectionRefreshForWorkers flag on WebProcess rather than refreshing
immediately, to avoid relaunching the network process just for workers. When the
network process is relaunched for another reason (e.g. a document calling
indexedDB.open()), ensureNetworkProcessConnection drains the flag and pushes the
new proxy to all workers via replaceIDBConnectionProxyOnAllWorkers.

Open IDBDatabase connections receive an onclose event when the network process
terminates, which tests use as a reliable signal that crash processing is 
complete.

Tests: storage/indexeddb/modern/idb-operations-during-network-process-crash.html
       storage/indexeddb/modern/worker-idb-after-network-crash.html

* 
LayoutTests/storage/indexeddb/modern/idb-operations-during-network-process-crash-expected.txt:
 Added.
* 
LayoutTests/storage/indexeddb/modern/idb-operations-during-network-process-crash.html:
 Added.
* 
LayoutTests/storage/indexeddb/modern/opendatabase-after-storage-crash-expected.txt:
* LayoutTests/storage/indexeddb/modern/opendatabase-after-storage-crash.html:
* 
LayoutTests/storage/indexeddb/modern/resources/worker-idb-after-network-crash.js:
 Added.
(self.onmessage):
(openInitialDatabase.request.onupgradeneeded):
(openInitialDatabase.tx.oncomplete):
(openInitialDatabase.tx.onerror):
(openInitialDatabase.request.onsuccess):
(openInitialDatabase.request.onerror):
(openInitialDatabase):
(attemptRecoveryOpen.request.onupgradeneeded):
(attemptRecoveryOpen.tx.oncomplete):
(attemptRecoveryOpen.tx.onerror):
(attemptRecoveryOpen.request.onsuccess):
(attemptRecoveryOpen.request.onerror):
(attemptRecoveryOpen):
* 
LayoutTests/storage/indexeddb/modern/worker-idb-after-network-crash-expected.txt:
 Added.
* LayoutTests/storage/indexeddb/modern/worker-idb-after-network-crash.html: 
Added.
* Source/WebCore/Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::ensureConnectionProxy):
(WebCore::IDBFactory::openInternal):
(WebCore::IDBFactory::deleteDatabase):
(WebCore::IDBFactory::databases):
(WebCore::IDBFactory::getAllDatabaseNames):
* Source/WebCore/Modules/indexeddb/IDBFactory.h:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::clearIDBConnectionProxy):
* Source/WebCore/dom/Document.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::clearIDBConnectionOnAllDocuments):
(WebCore::Page::refreshIDBConnectionForWorkers):
* Source/WebCore/page/Page.h:
* Source/WebCore/workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::prepareForDestruction):
(WebCore::WorkerGlobalScope::replaceIDBConnectionProxy):
(WebCore::WorkerGlobalScope::replaceIDBConnectionProxyOnAllWorkers):
(WebCore::WorkerGlobalScope::suspend):
(WebCore::WorkerGlobalScope::resume):
* Source/WebCore/workers/WorkerGlobalScope.h:
* Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp:
(WebKit::NetworkProcessConnection::didClose):
* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::ensureNetworkProcessConnection):
(WebKit::WebProcess::networkProcessConnectionClosed):
(WebKit::WebProcess::refreshIDBConnectionForWorkers):
* Source/WebKit/WebProcess/WebProcess.h:

Canonical link: https://commits.webkit.org/309032@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to