Bug 694039. Work around OpenGL quirks in the plugin process. r=bgirard
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Fri, 14 Oct 2011 15:22:11 -0400
changeset 79024 17ef2ebb8ef98c90d3df71025cd896c000fd17bf
parent 79023 ca6cd3b13ea3e24955ed7c119f34d60f04123029
child 79025 986f31890872449ffbaa9043cb00f25f18236ab3
push id434
push userclegnitto@mozilla.com
push dateWed, 21 Dec 2011 12:10:54 +0000
treeherdermozilla-esr52@54bfd8bf682e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard
bugs694039
milestone10.0a1
Bug 694039. Work around OpenGL quirks in the plugin process. r=bgirard We do the same in the main process so that we get the right bundle id on in Nightly and Aurora
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsAppRunner.h
toolkit/xre/nsEmbedFunctions.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -66,16 +66,19 @@
 #ifdef MOZ_INSTRUMENT_EVENT_LOOP
 #include "EventTracer.h"
 #endif
 
 #ifdef XP_MACOSX
 #include "MacLaunchHelper.h"
 #include "MacApplicationDelegate.h"
 #include "MacAutoreleasePool.h"
+// these are needed for sysctl
+#include <sys/types.h>
+#include <sys/sysctl.h>
 #endif
 
 #ifdef XP_OS2
 #include "private/pprthred.h"
 #endif
 #include "prmem.h"
 #include "prnetdb.h"
 #include "prprf.h"
@@ -2650,16 +2653,18 @@ XRE_main(int argc, char* argv[], const n
   nsresult rv;
   ArgResult ar;
 
 #ifdef DEBUG
   if (PR_GetEnv("XRE_MAIN_BREAK"))
     NS_BREAK();
 #endif
 
+  TriggerQuirks();
+
   // see bug 639842
   // it's very important to fire this process BEFORE we set up error handling.
   // indeed, this process is expected to be crashy, and we don't want the user to see its crashes.
   // That's the whole reason for doing this in a separate process.
 #ifdef MOZ_X11
 #ifndef MOZ_PLATFORM_MAEMO
   if (fire_glxtest_process())
     return 0;
@@ -3782,8 +3787,53 @@ SetupErrorHandling(const char* progname)
 
 #if defined(FREEBSD)
   // Disable all SIGFPE's on FreeBSD, as it has non-IEEE-conformant fp
   // trap behavior that trips up on floating-point tests performed by
   // the JS engine.  See bugzilla bug 9967 details.
   fpsetmask(0);
 #endif
 }
+
+void
+TriggerQuirks()
+{
+#if defined(XP_MACOSX)
+  int mib[2];
+
+  mib[0] = CTL_KERN;
+  mib[1] = KERN_OSRELEASE;
+  // we won't support versions greater than 10.7.99
+  char release[sizeof("10.7.99")];
+  size_t len = sizeof(release);
+  // sysctl will return ENOMEM if the release string is longer than sizeof(release)
+  int ret = sysctl(mib, 2, release, &len, NULL, 0);
+  // we only want to trigger this on OS X 10.6, on versions 10.6.8 or newer
+  // Darwin version 10 corresponds to OS X version 10.6, version 11 is 10.7
+  // http://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history
+  if (ret == 0 && NS_CompareVersions(release, "10.8.0") >= 0 && NS_CompareVersions(release, "11") < 0) {
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    if (mainBundle) {
+      CFRetain(mainBundle);
+
+      CFStringRef bundleID = CFBundleGetIdentifier(mainBundle);
+      if (bundleID) {
+        CFRetain(bundleID);
+
+        CFMutableDictionaryRef dict = (CFMutableDictionaryRef)CFBundleGetInfoDictionary(mainBundle);
+        CFDictionarySetValue(dict, CFSTR("CFBundleIdentifier"), CFSTR("org.mozilla.firefox"));
+
+        // Calling Gestalt will trigger a load of the quirks table for org.mozilla.firefox
+        SInt32 major;
+        ::Gestalt(gestaltSystemVersionMajor, &major);
+
+        // restore the original id
+        dict = (CFMutableDictionaryRef)CFBundleGetInfoDictionary(mainBundle);
+        CFDictionarySetValue(dict, CFSTR("CFBundleIdentifier"), bundleID);
+
+        CFRelease(bundleID);
+      }
+      CFRelease(mainBundle);
+    }
+  }
+#endif
+}
+
--- a/toolkit/xre/nsAppRunner.h
+++ b/toolkit/xre/nsAppRunner.h
@@ -189,9 +189,10 @@ extern GeckoProcessType sChildProcessTyp
 }
 
 /**
  * Set up platform specific error handling such as suppressing DLL load dialog
  * and the JIT debugger on Windows, and install unix signal handlers.
  */
 void SetupErrorHandling(const char* progname);
 
+void TriggerQuirks();
 #endif // nsAppRunner_h__
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -309,16 +309,18 @@ nsresult
 XRE_InitChildProcess(int aArgc,
                      char* aArgv[],
                      GeckoProcessType aProcess)
 {
   NS_ENSURE_ARG_MIN(aArgc, 2);
   NS_ENSURE_ARG_POINTER(aArgv);
   NS_ENSURE_ARG_POINTER(aArgv[0]);
 
+  TriggerQuirks();
+
   sChildProcessType = aProcess;
 
   // Complete 'task_t' exchange for Mac OS X. This structure has the same size
   // regardless of architecture so we don't have any cross-arch issues here.
 #ifdef XP_MACOSX
   if (aArgc < 1)
     return 1;
   const char* const mach_port_name = aArgv[--aArgc];