win32: fix multi-window redraw starvation - #4653
Open
Niketion wants to merge 5 commits into
Open
Conversation
Resume a redraw-interrupted message dispatch before entering the next wait phase. This prevents another `AboutToWait` from issuing redraw requests before other pending window paints are dispatched, while preserving `pump_app_events`' one-redraw return behavior.
Niketion
force-pushed
the
fix/win32-multi-window-redraw-3648
branch
from
July 31, 2026 09:42
0c06743 to
bcc3130
Compare
Deliver explicit redraw requests through a posted window message instead of low-priority WM_PAINT. This prevents a continuously populated message queue from starving RedrawRequested while preserving coalescing, system paints, re-entrant callbacks, and source-drag behavior.
Niketion
force-pushed
the
fix/win32-multi-window-redraw-3648
branch
from
August 5, 2026 12:00
f7373b9 to
846ea56
Compare
Contributor
|
I believe this PR currently has a problem where it will schedule a redraw for every single input event if the handler every event requests redraw, with no coalescing at all. I think we need some kind of middle ground where input events are processed in a batch up until some deadline or similar. |
Author
|
Thanks, this is a valid concern. Addressing this correctly would require a more deliberate batching or deadline policy, together with broader testing across run_app, pump_app_events, multiple windows, and native modal loops. I think that goes beyond the original scope of this PR. I’m going to revert the continuous-input/posted-message changes for now and keep this PR focused on the original multi-window starvation issue in #3648 |
…' into fix/win32-multi-window-redraw-3648
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
changelogmodule if knowledge of this change could be valuable to usersFixes #3648.
Multi-window redraw starvation
Dispatching a
RedrawRequestedinterrupts Win32 message processing so thatpump_app_eventscan promptly return control to its external event loop.Previously, the next iteration could enter the wait phase and emit another
AboutToWaitbefore dispatching the remaining queued window messages. Applications requesting redraws again fromAboutToWaitcould therefore repeatedly service one window while starving the others.This change preserves the interrupted-dispatch state across
pump_app_eventscalls and resumes pending message dispatch before entering another wait phase.run_app_on_demandlikewise checks the interrupted state before preparing to wait. This restores fairness between windows while preservingpump_app_eventsbehavior of returning after oneRedrawRequested.Testing
Tested on Windows across:
ControlFlow::WaitandControlFlow::Poll;run_app,run_app_on_demand, andpump_app_events;RedrawRequested;With equal request counts, the original five-window reproducer produced:
With this change: