[Modules] Handle WM_ENDSESSION in run_message_loop daemons (GrabAndMove, AlwaysOnTop, FancyZones) - #48404
Merged
Boliang Zhang (LegendaryBlair) merged 2 commits intoAug 9, 2026
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates several PowerToys module daemons that run a top-level GetMessageW loop so they respond to WM_ENDSESSION and can unwind promptly during OS logoff/shutdown, avoiding the APPLICATION_HANG_QUIESCE_*_PowerToys.exe!run_message_loop WER bucket.
Changes:
- GrabAndMove: adds a
g_session_endingflag, routesWM_ENDSESSIONthroughWM_CLOSE, and skips tray-icon deletion inWM_DESTROYduring OS shutdown. - FancyZones: handles
WM_ENDSESSIONand postsWM_QUIT(only whenwparamindicates shutdown is proceeding). - AlwaysOnTop: handles
WM_ENDSESSIONand postsWM_QUIT(only whenwparamindicates shutdown is proceeding).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/modules/GrabAndMove/GrabAndMove/main.cpp |
Add WM_ENDSESSION handling + shutdown flag to avoid shutdown-time work in WM_DESTROY. |
src/modules/fancyzones/FancyZonesLib/FancyZones.cpp |
Post WM_QUIT on confirmed session end so the message loop exits. |
src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp |
Post WM_QUIT on confirmed session end so the message loop exits. |
Contributor
Author
|
/acp run |
Contributor
Author
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
4 tasks
Gordon Lam (yeelam-gordon)
added a commit
to yeelam-gordon/PowerToys
that referenced
this pull request
Aug 4, 2026
…fix-modules-quiesce [review-mirror] microsoft#48404
Gordon Lam (yeelam-gordon)
force-pushed
the
user/yeelam/fix-modules-quiesce
branch
from
August 4, 2026 01:54
cc35926 to
9ebd655
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Gordon Lam (yeelam-gordon)
force-pushed
the
user/yeelam/fix-modules-quiesce
branch
from
August 6, 2026 14:13
9ebd655 to
407ec4f
Compare
Muyuan Li (MuyuanMS)
approved these changes
Aug 7, 2026
Boliang Zhang (LegendaryBlair)
merged commit Aug 9, 2026
68a2a0d
into
microsoft:main
8 checks passed
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.
Summary
Companion PR to #48378 (runner). Fixes the same
APPLICATION_HANG_QUIESCE_*_PowerToys.exe!run_message_loopWER bucket in the other PowerToys daemons whose top-level windows ignoredWM_ENDSESSION.Root cause (same as #48378)
run_message_loop(src/common/utils/window.h) callsGetMessageWwhich only returns0onWM_QUIT. If a daemon's WndProc letsWM_ENDSESSIONfall through toDefWindowProc, noWM_QUITis ever posted on logoff/shutdown, the loop blocks, CSRSS hits the quiesce timeout (~5s),TerminateProcessfires, and Watson logsAPPLICATION_HANG_QUIESCE.run_message_loopcallsite audit8 production callsites. Persistent daemons that own a top-level window and were affected:
runnerGrabAndMovemain.cppAlwaysOnTopAlwaysOnTop.cppFancyZonesFancyZones.cppKeyboardManagerEngineZoomItPowerLauncherSessionEndingeventMeasureTool,NotificationsFix pattern
For
AlwaysOnTopandFancyZones(no tray icon to clean up) — minimal:For
GrabAndMove(hasShell_NotifyIconcleanup inWM_DESTROYthat must not run on shutdown) — use ag_session_endingflag and skip the tray-icon delete inWM_DESTROY, mirroring runner'stray_icon.cpppattern from #48378.No shared header: each module's
WM_DESTROYcleanup is module-specific; the abstraction would be too thin and would hide the variance in what to skip.Why no logging on the shutdown path
Same reasoning as #48378 review feedback —
spdlog::flush_on(info)synchronously flushes to disk; emitting log lines fromWM_ENDSESSION/WM_DESTROYburns the ~5s quiesce budget for no diagnostic value (Watson already records the bucket on failure).Verification
Related