Bug 1366860 - Require a minimum amount of RAM to get a 64-bit build from the stub installer. r?rstrong
MozReview-Commit-ID: 4lR9pjafnTq
--- a/browser/installer/windows/nsis/stub.nsi
+++ b/browser/installer/windows/nsis/stub.nsi
@@ -176,16 +176,24 @@ Var PreviousInstallArch
; with a 100 millisecond timer and a first step of 20 as defined by
; InstallProgressFirstStep .
!define /math InstallPaveOverTotalSteps ${InstallProgressFirstStep} + 1800
; Blurb duty cycle
!define BlurbDisplayMS 19500
!define BlurbBlankMS 500
+; Amount of physical memory required for the 64-bit build to be selected.
+; Machines with less RAM than this get the 32-bit build, even with a 64-bit OS.
+; The value 1800 MB was chosen based on an initial requirement of 2 GB, reduced
+; to allow for hardware such as integrated graphics that reserves some of the
+; installed RAM for its own use.
+; 1800 MB * 1024 KB/MB * 1024 B/KB = 1887436800 bytes
+!define RAM_NEEDED_FOR_64BIT 1887436800
+
; Attempt to elevate Standard Users in addition to users that
; are a member of the Administrators group.
!define NONADMIN_ELEVATE
!define CONFIG_INI "config.ini"
!ifndef FILE_SHARE_READ
!define FILE_SHARE_READ 1
@@ -307,19 +315,28 @@ Function .onInit
; SSE2 CPU support
${If} "$R7" == "0"
MessageBox MB_OKCANCEL|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_CPU_MSG)" IDCANCEL +2
ExecShell "open" "${URLSystemRequirements}"
Quit
${EndIf}
+ ; Check if we meet the RAM requirement for the 64-bit build.
+ System::Call "*(i 64, i, l 0, l, l, l, l, l, l)p.r0"
+ System::Call "Kernel32::GlobalMemoryStatusEx(p r0)"
+ System::Call "*$0(i, i, l.r1, l, l, l, l, l, l)"
+ System::Free $0
+
${If} ${RunningX64}
+ ${AndIf} $1 L>= ${RAM_NEEDED_FOR_64BIT}
+ StrCpy $DroplistArch "$(VERSION_64BIT)"
StrCpy $INSTDIR "${DefaultInstDir64bit}"
${Else}
+ StrCpy $DroplistArch "$(VERSION_32BIT)"
StrCpy $INSTDIR "${DefaultInstDir32bit}"
${EndIf}
; Require elevation if the user can elevate
${ElevateUAC}
; If we have any existing installation, use its location as the default
; path for this install, even if it's not the same architecture.
@@ -418,21 +435,16 @@ Function .onInit
${If} "$0" == "true"
StrCpy $CheckboxInstallMaintSvc "1"
${Else}
StrCpy $CheckboxInstallMaintSvc "0"
${EndIf}
!else
StrCpy $CheckboxInstallMaintSvc "0"
!endif
- ${If} ${RunningX64}
- StrCpy $DroplistArch "$(VERSION_64BIT)"
- ${Else}
- StrCpy $DroplistArch "$(VERSION_32BIT)"
- ${EndIf}
StrCpy $0 ""
!ifdef FONT_FILE1
${If} ${FileExists} "$FONTS\${FONT_FILE1}"
StrCpy $0 "${FONT_NAME1}"
${EndIf}
!endif