Skip to content

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

Merged
rokm merged 1 commit into
pyinstaller:developfrom
rokm:windows-spinning-cursor
Mar 15, 2024
Merged

rokm merged 1 commit into
pyinstaller:developfrom
rokm:windows-spinning-cursor

Conversation

@rokm

@rokm rokm commented Mar 15, 2024

Copy link
Copy Markdown
Member

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
rokm force-pushed the windows-spinning-cursor branch from 54b81c5 to 1a9d91e Compare March 15, 2024 17:41
@rokm

rokm commented Mar 15, 2024

Copy link
Copy Markdown
Member Author

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
@rokm
rokm deleted the windows-spinning-cursor branch March 15, 2024 22:42
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants