SIGN IN SIGN UP

Remove stale assertion in NetworkProcess::destroySession

https://bugs.webkit.org/show_bug.cgi?id=319448
rdar://182258579

Reviewed by Alexey Proskuryakov.

TestWebKitAPI.NetworkProcess.TerminateWhenNoDefaultWebsiteDataStore hits this assertion on debug builds. The test calls
[WKWebsiteDataStore _deleteDefaultDataStoreForTesting] to release the last strong reference to the default
WebsiteDataStore, which runs WebsiteDataStore::~WebsiteDataStore() and unconditionally sends DestroySession for whatever
sessionID that WebsiteDataStore had, including the default one, to NetworkProcess.

This assertion was added in 205434@main, before _deleteDefaultDataStoreForTesting was repurposed by 251983@main to also
exercise NetworkProcess's session/process lifetime logic. At the time the assertion was introduced, the default
WebsiteDataStore held the last reference to NetworkProcessProxy for the whole lifetime of the process, so
destroySession() was never expected to run for the default session on Cocoa. That assumption no longer holds: it is
legitimate for the default session to be destroyed while NetworkProcessProxy stays alive, since all WebsiteDataStores
(default, ephemeral, custom persistent) share a single NetworkProcessProxy on Cocoa, so destroying the default session
does not necessarily mean the process is going away.

destroySession()'s cleanup itself (removing the session from m_networkSessions and m_networkStorageSessions) has no
special dependency on the sessionID not being the default one, so removing the assertion does not change behavior for
any port; it only stops a stale invariant from firing on a legitimate code path.

* Source/WebKit/NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::destroySession):

Canonical link: https://commits.webkit.org/317277@main
S
Sihui Liu committed
7461d46a642d423be04d82011c5c548322024672
Parent: fa01ab0