Archive: Delay between INSTFILES and FINISHPAGE


Delay between INSTFILES and FINISHPAGE
Hello,
I wrote a simple install script with no custom pages and no custom .ini files.
This is the problem: immediately after all the files have been copied by the INSTFILES page, the "Finish" button becomes available but it takes another 3-4 seconds before the FINISHPAGE appears. This is troublesome because the users may click the Finish button before having a chance to choose whether they want to run the application or not by (un)checking a checkbox I put in the finish page. I also put a secondary checkbox in the finish page that lets the users decide if they want a desktop shortcut or not.

I tried messing with these two lines of code putting them here and there but with no results:


ReserveFile "${NSISDIR}\Contrib\Modern UI\ioSpecial.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS



Here is some code inside my install script:

; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Create a shortcut"
!define MUI_FINISHPAGE_RUN_FUNCTION "lnkdesktop"
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Run ${PRODUCT_NAME}"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION "runfile"
Function "runfile"
Exec "$INSTDIR\${PRODUCT_EXECUTABLE}"
FunctionEnd
Function "lnkdesktop"
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}" "" "$INSTDIR\${PRODUCT_EXECUTABLE}" 0
FunctionEnd
!insertmacro MUI_PAGE_FINISH

Does it work if you don't use solid compression? Could you attach a complete script reproducing this problem?


Originally posted by kichik
Does it work if you don't use solid compression?
I tried different compression algorithms, both solid and non-solid but the delay is always there.

Originally posted by kichik
Could you attach a complete script reproducing this problem?
It's not script-dependant since I experience the delay even with the example script Examples\Modern UI\WelcomeFinish.nsi
If I build that example as-is, I get 1 second delay. When I add these two lines to make the checkboxes appear:


!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_RUN


the delay increases to 2-3 seconds.
I attach my script file but please note that the delay occurs even with the example scripts provided with the NSIS installation. You may not be able to notice the delay if you have a fast CPU. Mine is a 1 Ghz AMD Duron and the delay is pretty evident.

If I can give my opinion, this is all due to the fact that the Finish button is set to "enabled" on the "INSTFILES Page Unload" event rather than on the "FINISHPAGE Page Loaded" event.

Here's a recap of what's going on.

Step #1: Files are being copied. Note that all the buttons are disabled during this phase.
http://www.doppioslash.it/misc/nsis/step1.gif

Step #2: All files have been copied. Immediately, the Finish button becomes enabled. The Cancel button is still disabled!! The finish page won't appear for another 2-4 seconds.
http://www.doppioslash.it/misc/nsis/step2.gif

Step #3: The finish page finally appears. This is the moment when the Cancel button becomes enabled. The whole problem would be solved if you also enabled the Finish button at this time, not earlier.
http://www.doppioslash.it/misc/nsis/step3.gif

Thanks for support.

The Installer Attributes AutoCloseWindow doesn't help?
Nor User Interface Instructions SetAutoClose?


Originally posted by Red Wine
The Installer Attributes AutoCloseWindow doesn't help?
Nor User Interface Instructions SetAutoClose?
Nope, none of them is helping :(
Also tried to set them to false but that didn't solve the problem either. After all the files have been installed, the user clicks "Next >" and the history repeats. The finish button appears immediately, the finish page after 2-3 seconds.

Custom pages use INI files, which are not the fastest method of data management available. However, 2-3 seconds even in the simplest case is not normal. I'd take a wild guess and say you have an anti-virus that's getting in your way.


It is true that my PC is slow and seriously needs a format C:, but the point is:

- I can't predict the computer specs my users will run the installer on;
- The Cancel button gets enabled at the right time, why the Finish button doesn't?


I'd like to point out that, of course, this is just a minor problem. In the end, if there is no solution, It won't really matter :)


Hmm... what about setting up a custom page just before the InstFiles page in order to collect info about shortcuts (see image below about what I mean) and leave the finish page only with run 'myapp.exe'? As you noticed above, that'd decrease the delay to 1 sec...


I'm gonna try that soon, thanks for the advice.


- I can't predict the computer specs my users will run the installer on;
- The Cancel button gets enabled at the right time, why the Finish button doesn't?
The cancel button is already disabled by the instfiles page and enabled by InstallOptions (the plug-in behind the finish page) itself. The Next button, on the other hand, is enabled by the paging system before InstallOptions is even called. You should submit a bug report about it, so it can be fixed some day.

I added 2 custom functions (PRE and SHOW) on Finish Page.
As I'm not able to reproduce the refered problem in my machine,
I added a sleep in the PRE function in order to simulate the problem.
When there is only the sleep command in the PRE function the next button appears
while the FInish Page does not appear.
Then I added code to disable the button and enable it again in SHOW function.
Could these 2 functions solve the refered by BrightSoul problem?

  !insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_CUSTOMFUNCTION_PRE btndisable
!define MUI_PAGE_CUSTOMFUNCTION_SHOW btnenable
!insertmacro MUI_PAGE_FINISH


the functions (sleep serves the simulation purpose)
;Finish Page functions
function btndisable
getdlgitem $R0 $HWNDPARENT 1
enablewindow $R0 0
sleep 6000
functionend

function btnenable
getdlgitem $R0 $HWNDPARENT 1
enablewindow $R0 1
functionend

Awesome!
Thank you Red Wine, that did the trick.
Also, I submitted a bug report as suggested by kichik.

Happy new year everyone! :)
Thanks for the great support-


You're welcome! Nothing impossible when you're NSIS-ing :-)
Happy new year to you too!
Happy new year amici Italiani!