Bug 1011225: Improve e10s process naming on OS X. Patch started by Benoit Girard, completed by Josh Aas. r=njn,benwa
authorJosh Aas <joshmoz@gmail.com>
Tue, 26 Aug 2014 12:03:09 -0500
changeset 223348 a7966a108af1a090fa1fbd04fb003104438b5b03
parent 223347 536aaaee3ea865a302bb46b32a9fdc8678cf0a73
child 223349 0556ceb562e32ae5fe2b2778244a6df2dc35c6c3
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn, benwa
bugs1011225
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1011225: Improve e10s process naming on OS X. Patch started by Benoit Girard, completed by Josh Aas. r=njn,benwa
dom/ipc/ContentChild.cpp
dom/plugins/ipc/PluginModuleChild.cpp
dom/plugins/ipc/PluginUtilsOSX.mm
ipc/app/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in
ipc/glue/ProcessUtils_mac.mm
ipc/glue/moz.build
toolkit/components/aboutmemory/tests/test_aboutmemory5.xul
toolkit/components/aboutmemory/tests/test_memoryReporters2.xul
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -587,28 +587,31 @@ ContentChild::Init(MessageLoop* aIOLoop,
     InitProcessAttributes();
 
     return true;
 }
 
 void
 ContentChild::InitProcessAttributes()
 {
+#ifdef MOZ_WIDGET_GONK
 #ifdef MOZ_NUWA_PROCESS
     if (IsNuwaProcess()) {
         SetProcessName(NS_LITERAL_STRING("(Nuwa)"), false);
         return;
     }
 #endif
     if (mIsForApp && !mIsForBrowser) {
         SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false);
     } else {
         SetProcessName(NS_LITERAL_STRING("Browser"), false);
     }
-
+#else
+    SetProcessName(NS_LITERAL_STRING("Web Content"), true);
+#endif
 }
 
 void
 ContentChild::SetProcessName(const nsAString& aName, bool aDontOverride)
 {
     if (!mCanOverrideProcessName) {
         return;
     }
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -179,17 +179,20 @@ PluginModuleChild::Init(const std::strin
     }
 
 #if defined(MOZ_X11)
     NS_NAMED_LITERAL_CSTRING(flash10Head, "Shockwave Flash 10.");
     if (StringBeginsWith(nsDependentCString(info.fDescription), flash10Head)) {
         AddQuirk(QUIRK_FLASH_EXPOSE_COORD_TRANSLATION);
     }
 #else // defined(OS_MACOSX)
-    mozilla::plugins::PluginUtilsOSX::SetProcessName(info.fName);
+    const char* namePrefix = "Plugin Content";
+    char nameBuffer[80];
+    snprintf(nameBuffer, sizeof(nameBuffer), "%s (%s)", namePrefix, info.fName);
+    mozilla::plugins::PluginUtilsOSX::SetProcessName(nameBuffer);
 #endif
 
     pluginFile.FreePluginInfo(info);
 
     if (!mLibrary)
 #endif
     {
         nsresult rv = pluginFile.LoadPlugin(&mLibrary);
--- a/dom/plugins/ipc/PluginUtilsOSX.mm
+++ b/dom/plugins/ipc/PluginUtilsOSX.mm
@@ -272,17 +272,17 @@ bool mozilla::plugins::PluginUtilsOSX::S
     return false;
   }
 
   NSString *currentName = [[[NSBundle mainBundle] localizedInfoDictionary] 
                               objectForKey:(NSString *)kCFBundleNameKey];
 
   char formattedName[1024];
   snprintf(formattedName, sizeof(formattedName), 
-      "%s (%s)", [currentName UTF8String], aProcessName);
+      "%s %s", [currentName UTF8String], aProcessName);
 
   aProcessName = formattedName;
 
   // This function is based on Chrome/Webkit's and relies on potentially dangerous SPI.
   typedef CFTypeRef (*LSGetASNType)();
   typedef OSStatus (*LSSetInformationItemType)(int, CFTypeRef,
                                                CFStringRef, 
                                                CFStringRef,
--- a/ipc/app/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in
+++ b/ipc/app/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in
@@ -1,7 +1,7 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Localized versions of Info.plist keys */
 
-CFBundleName = "%APP_NAME% Plugin Process";
+CFBundleName = "%APP_NAME%";
new file mode 100644
--- /dev/null
+++ b/ipc/glue/ProcessUtils_mac.mm
@@ -0,0 +1,20 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "ProcessUtils.h"
+
+#include "nsString.h"
+
+#include "mozilla/plugins/PluginUtilsOSX.h"
+
+namespace mozilla {
+namespace ipc {
+
+void SetThisProcessName(const char *aName)
+{
+  mozilla::plugins::PluginUtilsOSX::SetProcessName(aName);
+}
+
+} // namespace ipc
+} // namespace mozilla
--- a/ipc/glue/moz.build
+++ b/ipc/glue/moz.build
@@ -80,16 +80,20 @@ else:
 if CONFIG['OS_ARCH'] == 'Linux':
     UNIFIED_SOURCES += [
         'ProcessUtils_linux.cpp',
     ]
 elif CONFIG['OS_ARCH'] in ('DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD'):
     UNIFIED_SOURCES += [
         'ProcessUtils_bsd.cpp'
     ]
+elif CONFIG['OS_ARCH'] in ('Darwin'):
+    UNIFIED_SOURCES += [
+        'ProcessUtils_mac.mm'
+    ]
 else:
     UNIFIED_SOURCES += [
         'ProcessUtils_none.cpp',
     ]
 
 EXPORTS.ipc += [
     'IPCMessageUtils.h',
 ]
--- a/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul
+++ b/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul
@@ -121,17 +121,20 @@
             let m1 = actual.match("anonymous") &&
                      actual.match("shared-libraries");
             ok(m1, "system-wide reporter")
             good = good && !!m1;
           }
 
           // Note: Match "vsize" but not "vsize-max-contiguous".
           let vsizes = actual.match(/vsize[^-]/g);
-          let endOfBrowsers  = actual.match(/End of Browser/g);
+          let endOfBrowsers = actual.match(/End of Browser/g);
+          if (endOfBrowsers == null) {
+            endOfBrowsers = actual.match(/End of Web Content/g);
+          }
           let m2 = (vsizes.length == 4 && endOfBrowsers.length == 3);
           ok(m2, "three child processes present in loaded data");
           good = good && !!m2;
 
           if (!good) {
             dump("*******ACTUAL*******\n");
             dump(actual);
             dump("********************\n");
--- a/toolkit/components/aboutmemory/tests/test_memoryReporters2.xul
+++ b/toolkit/components/aboutmemory/tests/test_memoryReporters2.xul
@@ -80,18 +80,18 @@
       let processes = Object.keys(residents);
       ok(processes.length == numRemotes + 1, "correct resident count");
 
       let numEmptyProcesses = 0, numNonEmptyProcesses = 0;
       for (let i = 0; i < processes.length; i++) {
         if (processes[i] == "") {
           numEmptyProcesses++;
         } else {
-          ok(processes[i].startsWith("Browser ("),
-             "correct non-empty process name prefix");
+          ok(processes[i].startsWith("Browser (") || processes[i].startsWith("Web Content ("),
+             "correct non-empty process name prefix: " + processes[i]);
           numNonEmptyProcesses++;
         }
       }
       ok(numEmptyProcesses == 1, "correct empty process name count");
       ok(numNonEmptyProcesses == numRemotes,
                                  "correct non-empty process name count");
 
       SimpleTest.finish();