Title: [256882] trunk/Source/WebKit
Revision
256882
Author
cdu...@apple.com
Date
2020-02-18 16:21:49 -0800 (Tue, 18 Feb 2020)

Log Message

Do not eagerly launch WebProcess when WKPagePostMessageToInjectedBundle() is called
https://bugs.webkit.org/show_bug.cgi?id=207905

Reviewed by Alex Christensen.

Do not eagerly launch WebProcess when WKPagePostMessageToInjectedBundle() is called. It is bad for
performance as we cannot leverage the process cache if we don't know the domain of the site that
will be loaded.

Instead we now queue those injected bundle messages until we really need to launch the process.

No new tests, WebKitTestRunner extensively relies on this private API already, and was the
reason we did the eager process launch in the first place (https://trac.webkit.org/changeset/243156).

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::launchProcess):
* UIProcess/WebPageProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (256881 => 256882)


--- trunk/Source/WebKit/ChangeLog	2020-02-19 00:13:59 UTC (rev 256881)
+++ trunk/Source/WebKit/ChangeLog	2020-02-19 00:21:49 UTC (rev 256882)
@@ -1,5 +1,25 @@
 2020-02-18  Chris Dumez  <cdu...@apple.com>
 
+        Do not eagerly launch WebProcess when WKPagePostMessageToInjectedBundle() is called
+        https://bugs.webkit.org/show_bug.cgi?id=207905
+
+        Reviewed by Alex Christensen.
+
+        Do not eagerly launch WebProcess when WKPagePostMessageToInjectedBundle() is called. It is bad for
+        performance as we cannot leverage the process cache if we don't know the domain of the site that
+        will be loaded.
+
+        Instead we now queue those injected bundle messages until we really need to launch the process.
+
+        No new tests, WebKitTestRunner extensively relies on this private API already, and was the
+        reason we did the eager process launch in the first place (https://trac.webkit.org/changeset/243156).
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::launchProcess):
+        * UIProcess/WebPageProxy.h:
+
+2020-02-18  Chris Dumez  <cdu...@apple.com>
+
         Drop getSandboxExtensionsForBlobFiles() as it is dead code
         https://bugs.webkit.org/show_bug.cgi?id=207909
         <rdar://problem/59562180>

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (256881 => 256882)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-02-19 00:13:59 UTC (rev 256881)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-02-19 00:21:49 UTC (rev 256882)
@@ -776,6 +776,10 @@
     m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_webPageID, *this);
 
     finishAttachingToWebProcess(reason);
+
+    auto pendingInjectedBundleMessage = WTFMove(m_pendingInjectedBundleMessages);
+    for (auto& message : pendingInjectedBundleMessage)
+        send(Messages::WebPage::PostInjectedBundleMessage(message.messageName, UserData(process().transformObjectsToHandles(message.messageBody.get()).get())));
 }
 
 bool WebPageProxy::suspendCurrentPageIfPossible(API::Navigation& navigation, Optional<FrameIdentifier> mainFrameID, ProcessSwapRequestedByClient processSwapRequestedByClient, ShouldDelayClosingUntilEnteringAcceleratedCompositingMode shouldDelayClosingUntilEnteringAcceleratedCompositingMode)
@@ -6282,8 +6286,10 @@
 
 void WebPageProxy::postMessageToInjectedBundle(const String& messageName, API::Object* messageBody)
 {
-    // For backward-compatibility, make sure we launch the initial process if the client asks to post a message to its injected bundle before doing a load.
-    launchInitialProcessIfNecessary();
+    if (!hasRunningProcess()) {
+        m_pendingInjectedBundleMessages.append(InjectedBundleMessage { messageName, messageBody });
+        return;
+    }
 
     send(Messages::WebPage::PostInjectedBundleMessage(messageName, UserData(process().transformObjectsToHandles(messageBody).get())));
 }
@@ -9601,7 +9607,8 @@
             return;
         }
         networkProcess->sendWithAsyncReply(Messages::NetworkProcess::ClearAdClickAttribution(m_websiteDataStore->sessionID()), WTFMove(completionHandler));
-    }
+    } else
+        completionHandler();
 }
 
 void WebPageProxy::setAdClickAttributionOverrideTimerForTesting(bool value, CompletionHandler<void()>&& completionHandler)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (256881 => 256882)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-02-19 00:13:59 UTC (rev 256881)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-02-19 00:21:49 UTC (rev 256882)
@@ -2721,6 +2721,12 @@
     bool m_isLayerTreeFrozenDueToSwipeAnimation { false };
     
     String m_overriddenMediaType;
+
+    struct InjectedBundleMessage {
+        String messageName;
+        RefPtr<API::Object> messageBody;
+    };
+    Vector<InjectedBundleMessage> m_pendingInjectedBundleMessages;
         
 #if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
     std::unique_ptr<WebDeviceOrientationUpdateProviderProxy> m_webDeviceOrientationUpdateProviderProxy;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to