Skip to content

fix: stop registering powerMonitor for Windows suspend notifications it ignores - #54352

Merged
MarshallOfSound merged 2 commits into
mainfrom
refactor/win-power-monitor-session-observer
Sep 25, 2026
Merged

MarshallOfSound merged 2 commits into
mainfrom
refactor/win-power-monitor-session-observer

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Description of Change

#47162 removed the WM_POWERBROADCAST handling from powerMonitor's private message window (suspend/resume come from base::PowerMonitor), but the RegisterSuspendResumeNotification() call stayed. It no longer feeds anything, and its unregistration is the ARM64 shutdown crash that #50045, #50878 and #51198 have been chasing.

  • Drop the private message window and the suspend/resume registration.
  • Take lock-screen / unlock-screen from ui::SessionChangeObserver, which registers WTS notifications on the UI thread's singleton window and filters to the current session, and emit directly from that callback instead of re-posting an Unretained task.

Checklist

Release Notes

Notes: Fixed a possible crash on Windows on ARM when powerMonitor is torn down.

@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 25, 2026
@MarshallOfSound MarshallOfSound self-assigned this Sep 25, 2026
…it ignores

#47162 removed the WM_POWERBROADCAST handling from powerMonitor's message
window (suspend/resume come from base::PowerMonitor), but left the
RegisterSuspendResumeNotification() call behind. That registration no
longer fed anything and its unregistration is the ARM64 shutdown crash
that #50045, #50878 and #51198 have been chasing.

Drop the private message window entirely and take session lock/unlock
from ui::SessionChangeObserver, which registers WTS notifications on the
UI thread's singleton window and already filters to the current session.
…ed and emit directly

~PowerMonitor() is defined in electron_api_power_monitor.cc, which only saw
the forward declaration, so the unique_ptr member did not compile on
Windows. The session change callback already runs on the UI thread, so emit
there instead of posting an Unretained task that nothing can cancel.
@MarshallOfSound
MarshallOfSound force-pushed the refactor/win-power-monitor-session-observer branch from 3708efd to 0b3278f Compare September 25, 2026 10:30

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never know why the handle crash happened, but also didn't realize this was an unused registration 🤦‍♂️

Thanks for catching this!

@MarshallOfSound
MarshallOfSound merged commit 98704f6 into main Sep 25, 2026
73 checks passed
@MarshallOfSound
MarshallOfSound deleted the refactor/win-power-monitor-session-observer branch September 25, 2026 16:07
@release-clerk

release-clerk Bot commented Sep 25, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed a possible crash on Windows on ARM when powerMonitor is torn down.

@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "44-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/44-x-y and removed target/44-x-y PR should also be added to the "44-x-y" branch. labels Sep 25, 2026
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #54384

@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "44-x-y", please check out #54408

@trop trop Bot added in-flight/44-x-y merged/45-x-y PR was merged to the "45-x-y" branch. and removed needs-manual-bp/44-x-y in-flight/45-x-y labels Sep 25, 2026
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…it ignores (44-x-y) (#54408)

fix: stop registering powerMonitor for Windows suspend notifications it ignores (#54352)

* fix: stop registering powerMonitor for Windows suspend notifications it ignores

window (suspend/resume come from base::PowerMonitor), but left the
RegisterSuspendResumeNotification() call behind. That registration no
longer fed anything and its unregistration is the ARM64 shutdown crash
that #50045, #50878 and #51198 have been chasing.

Drop the private message window entirely and take session lock/unlock
from ui::SessionChangeObserver, which registers WTS notifications on the
UI thread's singleton window and already filters to the current session.

* fix: complete ui::SessionChangeObserver where PowerMonitor is destroyed and emit directly

~PowerMonitor() is defined in electron_api_power_monitor.cc, which only saw
the forward declaration, so the unique_ptr member did not compile on
Windows. The session change callback already runs on the UI thread, so emit
there instead of posting an Unretained task that nothing can cancel.

(cherry picked from commit 98704f6)
@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. and removed in-flight/44-x-y labels Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants