Bug 1722833 - Add nsCocoaFeatures::OnMontereyOrLater(). r=mac-reviewers,spohl
authorMarkus Stange <mstange.moz@gmail.com>
Mon, 18 Oct 2021 21:29:42 +0000
changeset 596248 f718eaf8816e2fabd319aab507691fa829a2df88
parent 596247 de071c6d60a73a8a0267ad5b3acb44ed4e5d76e5
child 596249 40fe290c760459430ae64aca0df18477f1aff466
push id38892
push userctuns@mozilla.com
push dateTue, 19 Oct 2021 04:21:59 +0000
treeherdermozilla-central@1e37fc4a7f53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmac-reviewers, spohl
bugs1722833
milestone95.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 1722833 - Add nsCocoaFeatures::OnMontereyOrLater(). r=mac-reviewers,spohl Depends on D128616 Differential Revision: https://phabricator.services.mozilla.com/D128785
toolkit/xre/MacRunFromDmgUtils.mm
widget/cocoa/nsCocoaFeatures.h
widget/cocoa/nsCocoaFeatures.mm
--- a/toolkit/xre/MacRunFromDmgUtils.mm
+++ b/toolkit/xre/MacRunFromDmgUtils.mm
@@ -420,17 +420,17 @@ bool IsAppRunningFromDmg() {
   io_iterator_t iter;
   if (IORegistryEntryCreateIterator(media, kIOServicePlane,
                                     kIORegistryIterateRecursively | kIORegistryIterateParents,
                                     &iter) != KERN_SUCCESS) {
     IOObjectRelease(media);
     return false;
   }
   const char* imageClass =
-      nsCocoaFeatures::macOSVersionMajor() >= 12 ? "AppleDiskImageDevice" : "IOHDIXHDDrive";
+      nsCocoaFeatures::OnMontereyOrLater() ? "AppleDiskImageDevice" : "IOHDIXHDDrive";
   for (imageDrive = media; imageDrive; imageDrive = IOIteratorNext(iter)) {
     if (IOObjectConformsTo(imageDrive, imageClass)) {
       break;
     }
     IOObjectRelease(imageDrive);
   }
   IOObjectRelease(iter);
 
--- a/widget/cocoa/nsCocoaFeatures.h
+++ b/widget/cocoa/nsCocoaFeatures.h
@@ -18,16 +18,17 @@ class nsCocoaFeatures {
   static int32_t macOSVersionMajor();
   static int32_t macOSVersionMinor();
   static int32_t macOSVersionBugFix();
   static bool OnSierraExactly();
   static bool OnHighSierraOrLater();
   static bool OnMojaveOrLater();
   static bool OnCatalinaOrLater();
   static bool OnBigSurOrLater();
+  static bool OnMontereyOrLater();
 
   static bool IsAtLeastVersion(int32_t aMajor, int32_t aMinor,
                                int32_t aBugFix = 0);
 
   static bool ProcessIsRosettaTranslated();
 
   // These are utilities that do not change or depend on the value of
   // mOSVersion and instead just encapsulate the encoding algorithm. Note that
--- a/widget/cocoa/nsCocoaFeatures.mm
+++ b/widget/cocoa/nsCocoaFeatures.mm
@@ -19,16 +19,17 @@
 #define MACOS_VERSION_10_10_HEX 0x000A0A00
 #define MACOS_VERSION_10_11_HEX 0x000A0B00
 #define MACOS_VERSION_10_12_HEX 0x000A0C00
 #define MACOS_VERSION_10_13_HEX 0x000A0D00
 #define MACOS_VERSION_10_14_HEX 0x000A0E00
 #define MACOS_VERSION_10_15_HEX 0x000A0F00
 #define MACOS_VERSION_10_16_HEX 0x000A1000
 #define MACOS_VERSION_11_0_HEX 0x000B0000
+#define MACOS_VERSION_12_0_HEX 0x000C0000
 
 #include "nsCocoaFeatures.h"
 #include "nsCocoaUtils.h"
 #include "nsDebug.h"
 #include "nsObjCExceptions.h"
 
 #import <Cocoa/Cocoa.h>
 #include <sys/sysctl.h>
@@ -160,22 +161,39 @@ bool Gecko_OnSierraExactly() { return ns
   return (macOSVersion() >= MACOS_VERSION_10_14_HEX);
 }
 
 /* static */ bool nsCocoaFeatures::OnCatalinaOrLater() {
   return (macOSVersion() >= MACOS_VERSION_10_15_HEX);
 }
 
 /* static */ bool nsCocoaFeatures::OnBigSurOrLater() {
-  // Account for the version being 10.16 (which occurs when the
-  // application is linked with an older SDK) or 11.0 on Big Sur.
+  // Account for the version being 10.16 or 11.0 on Big Sur.
+  // The version is reported as 10.16 if SYSTEM_VERSION_COMPAT is set to 1,
+  // or if SYSTEM_VERSION_COMPAT is not set and the application is linked
+  // with a pre-Big Sur SDK.
+  // Firefox sets SYSTEM_VERSION_COMPAT to 0 in its Info.plist, so it'll
+  // usually see the correct 11.* version, despite being linked against an
+  // old SDK. However, it still sees the 10.16 compatibility version when
+  // launched from the command line, see bug 1727624. (This only applies to
+  // the Intel build - the arm64 build is linked against a Big Sur SDK and
+  // always sees the correct version.)
   return ((macOSVersion() >= MACOS_VERSION_10_16_HEX) ||
           (macOSVersion() >= MACOS_VERSION_11_0_HEX));
 }
 
+/* static */ bool nsCocoaFeatures::OnMontereyOrLater() {
+  // This check only works if SYSTEM_VERSION_COMPAT is off, otherwise
+  // Monterey pretends to be 10.16 and is indistinguishable from Big Sur.
+  // In practice, this means that an Intel Firefox build can return false
+  // from this function if it's launched from the command line, see bug 1727624.
+  // This will not be an issue anymore once we link against the Big Sur SDK.
+  return (macOSVersion() >= MACOS_VERSION_12_0_HEX);
+}
+
 /* static */ bool nsCocoaFeatures::IsAtLeastVersion(int32_t aMajor, int32_t aMinor,
                                                     int32_t aBugFix) {
   return macOSVersion() >= GetVersion(aMajor, aMinor, aBugFix);
 }
 
 /*
  * Returns true if the process is running under Rosetta translation. Returns
  * false if running natively or if an error was encountered. We use the