Bug 899352 - Increase the installation timeout for the stub installer. r=bbondy, a=lsblakk
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 28 Mar 2014 11:54:33 -0700
changeset 192400 84dbc0d6ae9048c98ea1bd7896c5694ff044bca3
parent 192399 24a8debccf5eef0b2f79f91334b42b06a10fee77
child 192401 1e065473e9c806ddeaf181166e534c577d474c99
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy, lsblakk
bugs899352
milestone30.0a2
Bug 899352 - Increase the installation timeout for the stub installer. r=bbondy, a=lsblakk
browser/installer/windows/nsis/stub.nsi
toolkit/mozapps/installer/windows/nsis/common.nsh
--- a/browser/installer/windows/nsis/stub.nsi
+++ b/browser/installer/windows/nsis/stub.nsi
@@ -56,16 +56,17 @@ Var HalfOfDownload
 Var DownloadReset
 Var ExistingTopDir
 Var SpaceAvailableBytes
 Var InitialInstallDir
 Var HandleDownload
 Var CanSetAsDefault
 Var InstallCounterStep
 Var InstallStepSize
+Var InstallTotalSteps
 Var TmpVal
 
 Var ExitCode
 Var FirefoxLaunchCode
 
 ; The first three tick counts are for the start of a phase and equate equate to
 ; the display of individual installer pages.
 Var StartIntroPhaseTickCount
@@ -137,17 +138,17 @@ Var ControlRightPX
 ; The downloaded file's certificate is not trusted by the certificate store and
 ; certificate attribute values were incorrect.
 !define ERR_PREINSTALL_CERT_UNTRUSTED_AND_ATTRIBUTES 23
 
 /**
  * The following errors prefixed with ERR_INSTALL apply to the install phase.
  */
 ; The installation timed out. The installation timeout is defined by the number
-; of progress steps defined in InstallProgresSteps and the install timer
+; of progress steps defined in InstallTotalSteps and the install timer
 ; interval defined in InstallIntervalMS
 !define ERR_INSTALL_TIMEOUT 30
 
 ; Maximum times to retry the download before displaying an error
 !define DownloadMaxRetries 9
 
 ; Minimum size expected to download in bytes
 !define DownloadMinSizeBytes 15728640 ; 15 MB
@@ -161,28 +162,35 @@ Var ControlRightPX
 !define DownloadRetryIntervalMS 3000
 
 ; Interval for the download timer
 !define DownloadIntervalMS 200
 
 ; Interval for the install timer
 !define InstallIntervalMS 100
 
-; Number of steps for the install progress.
-; This is 120 seconds with a 100 millisecond timer and a first step of 20 as
-; defined by InstallProgressFirstStep. This might not be enough when installing
-; on a slow network drive so it will fallback to downloading the full installer
-; if it reaches this number. The size of the install progress step increases
-; when the full installer finishes instead of waiting the entire 120 seconds.
-!define InstallProgresSteps 1220
-
 ; The first step for the install progress bar. By starting with a large step
 ; immediate feedback is given to the user.
 !define InstallProgressFirstStep 20
 
+; Number of steps for the install progress.
+; This might not be enough when installing on a slow network drive so it will
+; fallback to downloading the full installer if it reaches this number. The size
+; of the install progress step is increased when the full installer finishes
+; instead of waiting.
+
+; Approximately 150 seconds with a 100 millisecond timer and a first step of 20
+; as defined by InstallProgressFirstStep.
+!define /math InstallCleanTotalSteps ${InstallProgressFirstStep} + 1500
+
+; Approximately 165 seconds (minus 0.2 seconds for each file that is removed)
+; with a 100 millisecond timer and a first step of 20 as defined by
+; InstallProgressFirstStep .
+!define /math InstallPaveOverTotalSteps ${InstallProgressFirstStep} + 1800
+
 ; The interval in MS used for the progress bars set as marquee.
 !define ProgressbarMarqueeIntervalMS 10
 
 ; On Vista and above 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"
@@ -1184,16 +1192,22 @@ Function createInstall
     StrCpy $ExistingProfile "0"
   ${EndIf}
 
   StrCpy $DownloadServerIP ""
 
   System::Call "kernel32::GetTickCount()l .s"
   Pop $StartDownloadPhaseTickCount
 
+  ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.log"
+    StrCpy $InstallTotalSteps ${InstallPaveOverTotalSteps}
+  ${Else}
+    StrCpy $InstallTotalSteps ${InstallCleanTotalSteps}
+  ${EndIf}
+
   ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS}
 
   LockWindow off
   nsDialogs::Show
 
   ${NSD_FreeImage} $0
   ${NSD_FreeImage} $1
   ${NSD_FreeImage} $HwndBitmapBlurb1
@@ -1277,17 +1291,17 @@ Function OnDownload
         ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS}
       ${EndIf}
       Return
     ${EndIf}
 
     StrCpy $DownloadSizeBytes "$4"
     System::Int64Op $4 / 2
     Pop $HalfOfDownload
-    System::Int64Op $HalfOfDownload / ${InstallProgresSteps}
+    System::Int64Op $HalfOfDownload / $InstallTotalSteps
     Pop $InstallStepSize
     SendMessage $Progressbar ${PBM_SETMARQUEE} 0 0 ; start=1|stop=0 interval(ms)=+N
     ${RemoveStyle} $Progressbar ${PBS_MARQUEE}
     System::Int64Op $HalfOfDownload + $DownloadSizeBytes
     Pop $R9
     SendMessage $Progressbar ${PBM_SETRANGE32} 0 $R9
   ${EndIf}
 
@@ -1432,17 +1446,17 @@ Function OnDownload
       ; from creating a taskbar shortcut (Bug 791613).
       ${GetShortcutsLogPath} $0
       Delete "$0"
       ; Workaround to prevent pinning to the taskbar.
       ${If} $CheckboxShortcutOnBar == 0
         WriteIniStr "$0" "TASKBAR" "Migrated" "true"
       ${EndIf}
 
-      ${OnStubInstallUninstall}
+      ${OnStubInstallUninstall} $Progressbar $InstallCounterStep
 
       ; Delete the install.log and let the full installer create it. When the
       ; installer closes it we can detect that it has completed.
       Delete "$INSTDIR\install.log"
 
       ; Delete firefox.exe.moz-upgrade if it exists since it being present will
       ; require an OS restart for the full installer.
       Delete "$INSTDIR\${FileMainEXE}.moz-upgrade"
@@ -1501,17 +1515,17 @@ Function StartInstall
   LockWindow off
 
   Exec "$\"$PLUGINSDIR\download.exe$\" /INI=$PLUGINSDIR\${CONFIG_INI}"
   ${NSD_CreateTimer} CheckInstall ${InstallIntervalMS}
 FunctionEnd
 
 Function CheckInstall
   IntOp $InstallCounterStep $InstallCounterStep + 1
-  ${If} $InstallCounterStep >= ${InstallProgresSteps}
+  ${If} $InstallCounterStep >= $InstallTotalSteps
     ${NSD_KillTimer} CheckInstall
     ; Close the handle that prevents modification of the full installer
     System::Call 'kernel32::CloseHandle(i $HandleDownload)'
     StrCpy $ExitCode "${ERR_INSTALL_TIMEOUT}"
     ; Use a timer so the UI has a chance to update
     ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
     Return
   ${EndIf}
@@ -1541,22 +1555,22 @@ Function CheckInstall
       ${NSD_CreateTimer} FinishInstall ${InstallIntervalMS}
     ${EndUnless}
   ${EndIf}
 FunctionEnd
 
 Function FinishInstall
   ; The full installer has completed but the progress bar still needs to finish
   ; so increase the size of the step.
-  IntOp $InstallCounterStep $InstallCounterStep + 20
-  ${If} ${InstallProgresSteps} < $InstallCounterStep
-    StrCpy $InstallCounterStep "${InstallProgresSteps}"
+  IntOp $InstallCounterStep $InstallCounterStep + 40
+  ${If} $InstallTotalSteps < $InstallCounterStep
+    StrCpy $InstallCounterStep "$InstallTotalSteps"
   ${EndIf}
 
-  ${If} ${InstallProgresSteps} != $InstallCounterStep
+  ${If} $InstallTotalSteps != $InstallCounterStep
     SendMessage $Progressbar ${PBM_STEPIT} 0 0
     Return
   ${EndIf}
 
   ${NSD_KillTimer} FinishInstall
 
   SendMessage $Progressbar ${PBM_GETRANGE} 0 0 $R9
   SendMessage $Progressbar ${PBM_SETPOS} $R9 0
--- a/toolkit/mozapps/installer/windows/nsis/common.nsh
+++ b/toolkit/mozapps/installer/windows/nsis/common.nsh
@@ -4332,37 +4332,47 @@
 !macroend
 
 /**
  * Parses the uninstall.log for the stub installer on install to first remove a
  * previous installation's files prior to installing.
  *
  * When modifying this macro be aware that LineFind uses all registers except
  * $R0-$R3 so be cautious. Callers of this macro are not affected.
+ *
+ * @param   _PROGRESSBAR
+ *          The progress bar to update using PBM_STEPIT.
+ * @param   _INSTALL_STEP_COUNTER
+ *          The install step counter to increment. The variable specified in
+ *          this parameter is also updated.
+ *
+ * $R2 = _INSTALL_STEP_COUNTER
+ * $R3 = _PROGRESSBAR
  */
 !macro OnStubInstallUninstall
 
   !ifndef OnStubInstallUninstall
     !insertmacro GetParent
     !insertmacro LineFind
     !insertmacro TrimNewLines
 
     !verbose push
     !verbose ${_MOZFUNC_VERBOSE}
     !define OnStubInstallUninstall "!insertmacro OnStubInstallUninstallCall"
 
     Function OnStubInstallUninstall
+      Exch $R2
+      Exch 1
+      Exch $R3
       Push $R9
       Push $R8
       Push $R7
       Push $R6
       Push $R5
       Push $R4
-      Push $R3
-      Push $R2
       Push $R1
       Push $R0
       Push $TmpVal
 
       IfFileExists "$INSTDIR\uninstall\uninstall.log" +1 end
 
       ; Copy the uninstall log file to a temporary file
       GetTempFileName $TmpVal
@@ -4379,24 +4389,25 @@
       RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
 
       end:
       ClearErrors
 
       Pop $TmpVal
       Pop $R0
       Pop $R1
-      Pop $R2
-      Pop $R3
       Pop $R4
       Pop $R5
       Pop $R6
       Pop $R7
       Pop $R8
       Pop $R9
+      Exch $R3
+      Exch 1
+      Exch $R2
     FunctionEnd
 
     Function StubRemoveFilesCallback
       ${TrimNewLines} "$R9" $R9
       StrCpy $R1 "$R9" 5       ; Copy the first five chars
 
       StrCmp "$R1" "File:" +1 end
       StrCpy $R9 "$R9" "" 6    ; Copy string starting after the 6th char
@@ -4404,44 +4415,51 @@
 
       StrCmp "$R0" "\" +1 end  ; If this isn't a relative path goto end
       StrCmp "$R9" "\MapiProxy_InUse.dll" end +1 ; Skip the MapiProxy_InUse.dll
       StrCmp "$R9" "\mozMapi32_InUse.dll" end +1 ; Skip the mozMapi32_InUse.dll
 
       StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
       IfFileExists "$R1" +1 end
 
+      IntOp $R2 $R2 + 2
+      SendMessage $R3 ${PBM_STEPIT} 0 0
+      SendMessage $R3 ${PBM_STEPIT} 0 0
+
       ClearErrors
       Delete "$R1"
       ${Unless} ${Errors}
         Goto end
       ${EndUnless}
 
-      GetTempFileName $R2 "$INSTDIR\${TO_BE_DELETED}"
-      Delete "$R2"
+      GetTempFileName $R0 "$INSTDIR\${TO_BE_DELETED}"
+      Delete "$R0"
       ClearErrors
-      Rename "$R1" "$R2"
+      Rename "$R1" "$R0"
       ${If} ${Errors}
         Delete /REBOOTOK "$R1"
       ${EndUnless}
 
       end:
       ClearErrors
 
       Push 0
     FunctionEnd
 
     !verbose pop
   !endif
 !macroend
 
-!macro OnStubInstallUninstallCall
+!macro OnStubInstallUninstallCall _PROGRESSBAR _INSTALL_STEP_COUNTER
   !verbose push
+  Push "${_PROGRESSBAR}"
+  Push "${_INSTALL_STEP_COUNTER}"
   !verbose ${_MOZFUNC_VERBOSE}
   Call OnStubInstallUninstall
+  Pop ${_INSTALL_STEP_COUNTER}
   !verbose pop
 !macroend
 
 /**
  * Parses the uninstall.log to unregister dll's, remove files, and remove
  * empty directories for this installation.
  *
  * When modifying this macro be aware that LineFind uses all registers except