Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootloader: Windows: shorten the duration of spinning-wheel cursor #8359

Merged
merged 1 commit into from Mar 15, 2024

Conversation

rokm
Copy link
Member

@rokm rokm commented Mar 15, 2024

When using windowed/noconsole mode, attempt to shorten the duration of the spinning-wheel cursor that Windows uses to indicate that the process is starting.

For programs using /SUBSYSTEM:WINDOWS, Windows displays the spinning wheel cursor for a fixed amount of time, or until the process makes use of UI functions (creates a window, uses message queue).

In PyInstaller onefile applications, the parent process displays a window only if splash screen is used. Therefore, the spinning wheel cursor might be still shown well after the child process displays its UI. To prevent this, use PeekMessage to access the message queue, which apparently suffices to convince Windows that the process is alive. Do this right before we spawn the child process, i.e., after the parent process finishes unpacking the program; this is to ensure that the spinning-wheel cursor is displayed for the whole duration of unpacking.

In onedir applications, the spinning wheel should generally not be an issue (as there is only one process), except for background-style applications that do not display any UI. Such progams will appear to start faster if we have Windows hide the spinning-wheel cursor before we launch the python interpreter. So add a call to PeekMessage in that codepath as well.

When using windowed/noconsole mode, attempt to shorten the duration
of the spinning-wheel cursor that Windows uses to indicate that the
process is starting.

For programs using `/SUBSYSTEM:WINDOWS`, Windows displays the
spinning wheel cursor for a fixed amount of time, or until the
process makes use of UI functions (creates a window, uses message
queue).

In PyInstaller onefile applications, the parent process displays
a window only if splash screen is used. Therefore, the spinning
wheel cursor might be still shown well after the child process
displays its UI. To prevent this, post and receive a message
using message queue, which apparently suffices to convince Windows
that the process is alive. Do this right before we spawn the child
process, i.e., after the parent process finishes unpacking the
program; this is to ensure that the spinning-wheel cursor is
displayed for the whole duration of unpacking.

In onedir applications, the spinning wheel should generally not
be an issue (as there is only one process), except for
background-style applications that do not display any UI. Such
progams will appear to start faster if we have Windows hide
the spinning-wheel cursor before we launch the python
interpreter. So add calls using message queue in that codepath
as well.

We use the same combination of `PostMessage` and `GetMessage`
that can also be found in python executable:
https://github.com/python/cpython/blob/v3.12.2/PC/launcher.c#L765-L779
@rokm
Copy link
Member Author

rokm commented Mar 15, 2024

Updated to use PostMessageW and GetMessageW (same as used in python executable) instead of PeekMessageW, based on feedback in #8358.

@rokm rokm merged commit 29e29cd into pyinstaller:develop Mar 15, 2024
18 checks passed
@rokm rokm deleted the windows-spinning-cursor branch March 15, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants