[macOS] Label "prewarmed" WebContent processes in Activity Monitor
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Nov 2018 01:34:04 +0000 (01:34 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Nov 2018 01:34:04 +0000 (01:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191765
<rdar://problem/45953463>

Reviewed by Geoffrey Garen.

Source/WebCore:

* en.lproj/Localizable.strings:

Source/WebKit:

Label "prewarmed" WebContent processes in Activity Monitor to facilitate debugging.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getLaunchOptions):
(WebKit::WebProcessProxy::markIsNoLongerInPrewarmedPool):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::markIsNoLongerPrewarmed):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::initializeProcessName):
(WebKit::WebProcess::updateProcessName):
(WebKit::WebProcess::platformInitializeProcess):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/en.lproj/Localizable.strings
Source/WebKit/ChangeLog
Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/WebProcess.messages.in
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

index 3ed583d..3067111 100644 (file)
@@ -1,3 +1,13 @@
+2018-11-16  Chris Dumez  <cdumez@apple.com>
+
+        [macOS] Label "prewarmed" WebContent processes in Activity Monitor
+        https://bugs.webkit.org/show_bug.cgi?id=191765
+        <rdar://problem/45953463>
+
+        Reviewed by Geoffrey Garen.
+
+        * en.lproj/Localizable.strings:
+
 2018-11-16  Jeremy Jones  <jeremyj@apple.com>
 
         Enable external playback for video in element fullscreen.
index 10ab204..d2809d0 100644 (file)
@@ -46,6 +46,9 @@
 /* Visible name of the web process. The argument is the application name. */
 "%@ Web Content" = "%@ Web Content";
 
+/* Visible name of the web process. The argument is the application name. */
+"%@ Web Content (Prewarmed)" = "%@ Web Content (Prewarmed)";
+
 /* Visible name of Web Inspector's web process. The argument is the application name. */
 "%@ Web Inspector" = "%@ Web Inspector";
 
 /* Media Controls context menu item */
 "Controls" = "Controls";
 
+/* Convert to ordered list action name */
+"Convert to Ordered List (Undo action name)" = "Convert to Ordered List";
+
+/* Convert to unordered list action name */
+"Convert to Unordered List (Undo action name)" = "Convert to Unordered List";
+
 /* Copy context menu item */
 "Copy" = "Copy";
 
index 8107aa8..2547cd1 100644 (file)
@@ -1,3 +1,27 @@
+2018-11-16  Chris Dumez  <cdumez@apple.com>
+
+        [macOS] Label "prewarmed" WebContent processes in Activity Monitor
+        https://bugs.webkit.org/show_bug.cgi?id=191765
+        <rdar://problem/45953463>
+
+        Reviewed by Geoffrey Garen.
+
+        Label "prewarmed" WebContent processes in Activity Monitor to facilitate debugging.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+        (WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::getLaunchOptions):
+        (WebKit::WebProcessProxy::markIsNoLongerInPrewarmedPool):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::markIsNoLongerPrewarmed):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::initializeProcessName):
+        (WebKit::WebProcess::updateProcessName):
+        (WebKit::WebProcess::platformInitializeProcess):
+
 2018-11-16  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Keep Web Inspector window alive across process swaps (PSON) (Local Inspector)
index f92a0c9..4472748 100644 (file)
@@ -121,6 +121,10 @@ bool XPCServiceInitializerDelegate::getExtraInitializationData(HashMap<String, S
         extraInitializationData.add("service-worker-process"_s, serviceWorkerProcess);
 #endif
 
+    String isPrewarmedProcess = xpc_dictionary_get_string(extraDataInitializationDataObject, "is-prewarmed");
+    if (!isPrewarmedProcess.isEmpty())
+        extraInitializationData.add("is-prewarmed"_s, isPrewarmedProcess);
+
     String securityOrigin = xpc_dictionary_get_string(extraDataInitializationDataObject, "security-origin");
     if (!securityOrigin.isEmpty())
         extraInitializationData.add("security-origin"_s, securityOrigin);
index 1c05f34..34b034a 100644 (file)
@@ -199,6 +199,9 @@ void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOpt
 
     launchOptions.nonValidInjectedCodeAllowed = shouldAllowNonValidInjectedCode();
 
+    if (isPrewarmed())
+        launchOptions.extraInitializationData.add("is-prewarmed"_s, "1"_s);
+
     if (processPool().shouldMakeNextWebProcessLaunchFailForTesting()) {
         processPool().setShouldMakeNextWebProcessLaunchFailForTesting(false);
         launchOptions.shouldMakeProcessLaunchFailForTesting = true;
@@ -450,6 +453,8 @@ void WebProcessProxy::markIsNoLongerInPrewarmedPool()
     m_isPrewarmed = false;
     RELEASE_ASSERT(m_processPool);
     m_processPool.setIsWeak(IsWeak::No);
+
+    send(Messages::WebProcess::MarkIsNoLongerPrewarmed(), 0);
 }
 
 void WebProcessProxy::removeWebPage(WebPageProxy& webPage, uint64_t pageID)
index 70ce8ea..e9abdd0 100644 (file)
@@ -429,6 +429,16 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
     RELEASE_LOG(Process, "%p - WebProcess::initializeWebProcess: Presenting process = %d", this, WebCore::presentingApplicationPID());
 }
 
+void WebProcess::markIsNoLongerPrewarmed()
+{
+#if PLATFORM(MAC)
+    ASSERT(m_processType == ProcessType::PrewarmedWebContent);
+    m_processType = ProcessType::WebContent;
+
+    updateProcessName();
+#endif
+}
+
 void WebProcess::prewarmGlobally()
 {
     WebCore::ProcessWarming::prewarmGlobally();
index 187ea40..ab580a4 100644 (file)
@@ -265,6 +265,8 @@ private:
 
     void platformTerminate();
 
+    void markIsNoLongerPrewarmed();
+
     void registerURLSchemeAsEmptyDocument(const String&);
     void registerURLSchemeAsSecure(const String&) const;
     void registerURLSchemeAsBypassingContentSecurityPolicy(const String&) const;
@@ -381,6 +383,7 @@ private:
     void didReceiveSyncWebProcessMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
 
 #if PLATFORM(MAC)
+    void updateProcessName();
     void setScreenProperties(const WebCore::ScreenProperties&);
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     void scrollerStylePreferenceChanged(bool useOverlayScrollbars);
@@ -456,6 +459,11 @@ private:
 #if PLATFORM(MAC)
     std::unique_ptr<WebCore::CPUMonitor> m_cpuMonitor;
     std::optional<double> m_cpuLimit;
+
+    enum class ProcessType { Inspector, ServiceWorker, PrewarmedWebContent, WebContent };
+    ProcessType m_processType { ProcessType::WebContent };
+    String m_uiProcessName;
+    String m_securityOrigin;
 #endif
 
     HashMap<WebCore::UserGestureToken *, uint64_t> m_userGestureTokens;
index 9b134b3..f77e879 100644 (file)
@@ -128,6 +128,7 @@ messages -> WebProcess LegacyReceiver {
     CheckProcessLocalPortForActivity(struct WebCore::MessagePortIdentifier port, uint64_t callbackIdentifier)
     MessagesAvailableForPort(struct WebCore::MessagePortIdentifier port)
 
+    MarkIsNoLongerPrewarmed()
     UpdateActivePages()
     GetActivePagesOriginsForTesting() -> (Vector<String> activeOrigins) LegacySync
 
index ce2e48e..195c41a 100644 (file)
@@ -211,18 +211,31 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
 #endif
 }
 
-void WebProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
+void WebProcess::initializeProcessName(const ChildProcessInitializationParameters&)
 {
-#if !PLATFORM(IOS_FAMILY)
-    NSString *applicationName;
-    if (parameters.extraInitializationData.get("inspector-process"_s) == "1")
-        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Inspector", "Visible name of Web Inspector's web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
-#if ENABLE(SERVICE_WORKER)
-    else if (parameters.extraInitializationData.get("service-worker-process"_s) == "1")
-        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Service Worker (%@)", "Visible name of Service Worker process. The argument is the application name."), (NSString *)parameters.uiProcessName, (NSString *)parameters.extraInitializationData.get("security-origin"_s)];
+#if PLATFORM(MAC)
+    updateProcessName();
 #endif
-    else
-        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
+}
+
+#if PLATFORM(MAC)
+void WebProcess::updateProcessName()
+{
+    NSString *applicationName;
+    switch (m_processType) {
+    case ProcessType::Inspector:
+        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Inspector", "Visible name of Web Inspector's web process. The argument is the application name."), (NSString *)m_uiProcessName];
+        break;
+    case ProcessType::ServiceWorker:
+        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Service Worker (%@)", "Visible name of Service Worker process. The argument is the application name."), (NSString *)m_uiProcessName, (NSString *)m_securityOrigin];
+        break;
+    case ProcessType::PrewarmedWebContent:
+        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content (Prewarmed)", "Visible name of the web process. The argument is the application name."), (NSString *)m_uiProcessName];
+        break;
+    case ProcessType::WebContent:
+        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)m_uiProcessName];
+        break;
+    }
 
     dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
         // Note that it is important for _RegisterApplication() to have been called before setting the display name.
@@ -238,8 +251,8 @@ void WebProcess::initializeProcessName(const ChildProcessInitializationParameter
         ASSERT(!actualApplicationName.isEmpty());
 #endif
     });
-#endif
 }
+#endif // PLATFORM(MAC)
 
 static void registerWithAccessibility()
 {
@@ -338,7 +351,7 @@ void WebProcess::registerWithStateDumper()
 }
 #endif
 
-void WebProcess::platformInitializeProcess(const ChildProcessInitializationParameters&)
+void WebProcess::platformInitializeProcess(const ChildProcessInitializationParameters& parameters)
 {
 #if PLATFORM(MAC)
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
@@ -362,6 +375,23 @@ void WebProcess::platformInitializeProcess(const ChildProcessInitializationParam
         launchServicesCheckIn();
     }
 #endif // ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+
+    if (parameters.extraInitializationData.get("inspector-process"_s) == "1")
+        m_processType = ProcessType::Inspector;
+#if ENABLE(SERVICE_WORKER)
+    else if (parameters.extraInitializationData.get("service-worker-process"_s) == "1") {
+        m_processType = ProcessType::ServiceWorker;
+        m_securityOrigin = parameters.extraInitializationData.get("security-origin"_s);
+    }
+#endif
+    else if (parameters.extraInitializationData.get("is-prewarmed"_s) == "1")
+        m_processType = ProcessType::PrewarmedWebContent;
+    else
+        m_processType = ProcessType::WebContent;
+
+    m_uiProcessName = parameters.uiProcessName;
+#else
+    UNUSED_PARAM(parameters);
 #endif // PLATFORM(MAC)
 
     registerWithAccessibility();