Skip to content

fix: remove extra 'suspend'/'resume' handling from powerMonitor - #47162

Merged
ckerr merged 1 commit into
mainfrom
remove-suspend-duplicate
May 21, 2025
Merged

ckerr merged 1 commit into
mainfrom
remove-suspend-duplicate

Conversation

@codebytere

@codebytere codebytere commented May 20, 2025 •

Copy link
Copy Markdown
Member

Description of Change

Closes #44252.

'suspend'/'resume' handling was added initially to electron_api_power_monitor_{win|mac} prior to base::PowerSuspendObserver being added upstream - these events are now emitted via OnSuspend and OnResume and the extra handling causes them to be emitted twice. On Windows, for example, resuming after sleeping shows:

The system is resuming
The system is resuming

Checklist

Release Notes

Notes: Fixed an issue where the 'suspend' and 'resume' events could be emitted in duplicate.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label May 20, 2025
@codebytere codebytere changed the title refactor: remove extra suspend/resume handling from power monitor refactor: remove extra 'suspend'/'resume' handling from powerMonitor May 20, 2025
@codebytere codebytere changed the title refactor: remove extra 'suspend'/'resume' handling from powerMonitor fix: remove extra 'suspend'/'resume' handling from powerMonitor May 20, 2025
@codebytere
codebytere force-pushed the remove-suspend-duplicate branch from 9df3f1e to 0402c36 Compare May 20, 2025 13:54
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/35-x-y PR should also be added to the "35-x-y" branch. target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. labels May 20, 2025

@ckerr ckerr 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.

This is great. Nice catch!

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label May 21, 2025
@ckerr
ckerr merged commit 7b77a24 into main May 21, 2025
@ckerr
ckerr deleted the remove-suspend-duplicate branch May 21, 2025 15:00
@release-clerk

release-clerk Bot commented May 21, 2025

Copy link
Copy Markdown

Release Notes Persisted

Fixed an issue where the 'suspend' and 'resume' events could be emitted in duplicate.

@trop

trop Bot commented May 21, 2025

Copy link
Copy Markdown
Contributor

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

@trop trop Bot removed the target/37-x-y PR should also be added to the "37-x-y" branch. label May 21, 2025
@trop

trop Bot commented May 21, 2025

Copy link
Copy Markdown
Contributor

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

@trop

trop Bot commented May 21, 2025

Copy link
Copy Markdown
Contributor

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

@trop trop Bot added in-flight/36-x-y in-flight/35-x-y and removed target/36-x-y PR should also be added to the "36-x-y" branch. target/35-x-y PR should also be added to the "35-x-y" branch. in-flight/37-x-y labels May 21, 2025
@trop trop Bot added merged/37-x-y PR was merged to the "37-x-y" branch. merged/36-x-y PR was merged to the "36-x-y" branch. merged/35-x-y PR was merged to the "35-x-y" branch. and removed in-flight/36-x-y in-flight/35-x-y labels May 22, 2025
kigh-ota pushed a commit to kigh-ota/electron that referenced this pull request Sep 30, 2025
…ectron#47162)

fix: remove extra 'suspend'/'resume' handling from powerMonitor
MarshallOfSound added a commit that referenced this pull request 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.
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…it ignores (#54352)

* fix: stop registering powerMonitor for Windows suspend notifications 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.

* 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.
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…it ignores (#54384)

* fix: stop registering powerMonitor for Windows suspend notifications 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.

Co-authored-by: Sam Attard <[email protected]>

* 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.

Co-authored-by: Sam Attard <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Sam Attard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/35-x-y PR was merged to the "35-x-y" branch. merged/36-x-y PR was merged to the "36-x-y" branch. merged/37-x-y PR was merged to the "37-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: powerMonitor on resume event fires twice

2 participants