Title: [150597] branches/safari-537.43-branch/Source/WebKit2

Diff

Modified: branches/safari-537.43-branch/Source/WebKit2/ChangeLog (150596 => 150597)


--- branches/safari-537.43-branch/Source/WebKit2/ChangeLog	2013-05-23 18:30:34 UTC (rev 150596)
+++ branches/safari-537.43-branch/Source/WebKit2/ChangeLog	2013-05-23 18:44:57 UTC (rev 150597)
@@ -1,3 +1,45 @@
+2013-05-23  Lucas Forschler  <[email protected]>
+
+        Merge r150537
+
+    2013-05-22  Alexey Proskuryakov  <[email protected]>
+
+            Crashes in NetworkProcess due to incorrect private browsing session tracking
+            https://bugs.webkit.org/show_bug.cgi?id=116628
+
+            Reviewed by Brady Eidson.
+
+            The current API for private browsing makes it extremely difficult to track sessions.
+            Private browsing is enabled via WKPreferences, but the session is shared, so it
+            has to be maintained while there is any chance that any page group anywhere still
+            needs it.
+
+            This patch fixes some of the issues, but ultimately, I think that we'll just need
+            to deprecate and replace the API.
+
+            * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::storageSession):
+            There are valid scenarios where privateBrowsingEnabled is true, but there is no
+            private browsing session. Handle that without crashing, although this unfortunately
+            means that it will be harder to spot logic errors when using a wrong session.
+            (WebKit::NetworkConnectionToWebProcess::registerBlobURL): Removed an obsolete FIXME.
+
+            * NetworkProcess/mac/RemoteNetworkingContext.h: Changed privateBrowsingSession()
+            to return a pointer, as no caller could know when it was safe to call it.
+
+            * NetworkProcess/mac/RemoteNetworkingContext.mm:
+            (WebKit::RemoteNetworkingContext::storageSession): Handle the case where private
+            browsing session is unexpectedly missing without crashing.
+            (WebKit::RemoteNetworkingContext::privateBrowsingSession): Changed to return a pointer.
+
+            * UIProcess/WebContext.cpp: (WebKit::WebContext::ensureNetworkProcess):
+            Actually initialize privateBrowsingEnabled creation parameter. It would be very
+            difficult to figure out 100% reliably whether NetworkProcess needs a private browsing
+            session with the current API, but for existing clients, looking at
+            m_privateBrowsingEnterCount is good enough. Certainly better than not initializing.
+
+            * WebProcess/InjectedBundle/InjectedBundle.cpp:
+            (WebKit::InjectedBundle::setPrivateBrowsingEnabled): Added a FIXME.
+
 2013-05-22  Lucas Forschler  <[email protected]>
 
         Merge r150495

Modified: branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (150596 => 150597)


--- branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp	2013-05-23 18:30:34 UTC (rev 150596)
+++ branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp	2013-05-23 18:44:57 UTC (rev 150597)
@@ -156,7 +156,15 @@
 
 static NetworkStorageSession& storageSession(bool privateBrowsingEnabled)
 {
-    return privateBrowsingEnabled ? RemoteNetworkingContext::privateBrowsingSession() : NetworkStorageSession::defaultStorageSession();
+    if (privateBrowsingEnabled) {
+        NetworkStorageSession* privateSession = RemoteNetworkingContext::privateBrowsingSession();
+        if (privateSession)
+            return *privateSession;
+        // Some requests with private browsing mode requested may still be coming shortly after NetworkProcess was told to destroy its session.
+        // FIXME: Find a way to track private browsing sessions more rigorously.
+        LOG_ERROR("Private browsing was requested, but there was no session for it. Please file a bug unless you just disabled private browsing, in which case it's an expected race.");
+    }
+    return NetworkStorageSession::defaultStorageSession();
 }
 
 void NetworkConnectionToWebProcess::startDownload(bool privateBrowsingEnabled, uint64_t downloadID, const ResourceRequest& request)
@@ -208,8 +216,6 @@
 
 void NetworkConnectionToWebProcess::registerBlobURL(const KURL& url, const BlobRegistrationData& data)
 {
-    // FIXME: unregister all URLs when process connection closes.
-
     Vector<RefPtr<SandboxExtension>> extensions;
     for (size_t i = 0, count = data.sandboxExtensions().size(); i < count; ++i) {
         if (RefPtr<SandboxExtension> extension = SandboxExtension::create(data.sandboxExtensions()[i]))

Modified: branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.h (150596 => 150597)


--- branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.h	2013-05-23 18:30:34 UTC (rev 150596)
+++ branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.h	2013-05-23 18:44:57 UTC (rev 150597)
@@ -42,7 +42,7 @@
     static void ensurePrivateBrowsingSession();
     static void destroyPrivateBrowsingSession();
 
-    static WebCore::NetworkStorageSession& privateBrowsingSession(); // Can only be called when the session exists.
+    static WebCore::NetworkStorageSession* privateBrowsingSession();
 
     virtual bool shouldClearReferrerOnHTTPSToHTTPRedirect() const OVERRIDE;
 

Modified: branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm (150596 => 150597)


--- branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm	2013-05-23 18:30:34 UTC (rev 150596)
+++ branches/safari-537.43-branch/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm	2013-05-23 18:44:57 UTC (rev 150597)
@@ -78,17 +78,20 @@
 NetworkStorageSession& RemoteNetworkingContext::storageSession() const
 {
     if (m_privateBrowsingEnabled) {
-        ASSERT(privateBrowsingStorageSession());
-        return *privateBrowsingStorageSession();
+        NetworkStorageSession* privateSession = privateBrowsingStorageSession().get();
+        if (privateSession)
+            return *privateSession;
+        // Some requests with private browsing mode requested may still be coming shortly after NetworkProcess was told to destroy its session.
+        // FIXME: Find a way to track private browsing sessions more rigorously.
+        LOG_ERROR("Private browsing was requested, but there was no session for it. Please file a bug unless you just disabled private browsing, in which case it's an expected race.");
     }
 
     return NetworkStorageSession::defaultStorageSession();
 }
 
-NetworkStorageSession& RemoteNetworkingContext::privateBrowsingSession()
+NetworkStorageSession* RemoteNetworkingContext::privateBrowsingSession()
 {
-    ASSERT(privateBrowsingStorageSession());
-    return *privateBrowsingStorageSession();
+    return privateBrowsingStorageSession().get();
 }
 
 RetainPtr<CFDataRef> RemoteNetworkingContext::sourceApplicationAuditData() const

Modified: branches/safari-537.43-branch/Source/WebKit2/UIProcess/WebContext.cpp (150596 => 150597)


--- branches/safari-537.43-branch/Source/WebKit2/UIProcess/WebContext.cpp	2013-05-23 18:30:34 UTC (rev 150596)
+++ branches/safari-537.43-branch/Source/WebKit2/UIProcess/WebContext.cpp	2013-05-23 18:44:57 UTC (rev 150597)
@@ -373,6 +373,11 @@
     if (!parameters.diskCacheDirectory.isEmpty())
         SandboxExtension::createHandleForReadWriteDirectory(parameters.diskCacheDirectory, parameters.diskCacheDirectoryExtensionHandle);
 
+    // FIXME: We don't account for private browsing mode being enabled due to a persistent preference in any of active page groups.
+    // This means that clients must re-enable private browsing mode through API on each launch, not relying on preferences.
+    // If the client does not re-enable private browsing on next launch, NetworkProcess will crash.
+    parameters.privateBrowsingEnabled = m_privateBrowsingEnterCount;
+
     parameters.cacheModel = m_cacheModel;
 
     // Add any platform specific parameters

Modified: branches/safari-537.43-branch/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (150596 => 150597)


--- branches/safari-537.43-branch/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2013-05-23 18:30:34 UTC (rev 150596)
+++ branches/safari-537.43-branch/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2013-05-23 18:44:57 UTC (rev 150597)
@@ -303,6 +303,7 @@
 
 void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, bool enabled)
 {
+    // FIXME (NetworkProcess): This test-only function doesn't work with NetworkProcess, <https://bugs.webkit.org/show_bug.cgi?id=115274>.
 #if PLATFORM(MAC) || USE(CFNETWORK)
     if (enabled)
         WebFrameNetworkingContext::ensurePrivateBrowsingSession();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to