Repository navigation
Conversation
Chromium silently resets webContents zoom when the display topology
changes — monitors going to sleep, waking with stagger, or being
connected/disconnected. These events fire on Electron's
module, not on the BrowserWindow, so the existing window-level reassert
in installZoomReassertOnWindowEvents never runs.
On multi-monitor setups with staggered wake (common on Windows),
window-level resized/moved events may also arrive before all displays
have settled, causing the persisted zoom to be applied and immediately
overwritten by a later display change.
Add installZoomReassertOnDisplayEvents in zoom.ts that subscribes to
screen.on('display-metrics-changed'), display-added, and
display-removed with a 300ms debounce (vs 100ms for window resize) to
absorb the stagger. Listeners are cleaned up on window close to avoid
leaks across session windows.
Follows the existing pattern already used by the wake indicator
(main.ts:11835-11839) for the same three screen events.
Closes NousResearch#60693
Collaborator
|
Thanks for isolating the remaining display-topology path. Current main restores persisted zoom only through the BrowserWindow lifecycle hook and PR commit Automated hermes-sweeper review. |
8 tasks done
This branch has not been deployed
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.
What does this PR do?
Fixes a remaining trigger for the long-standing zoom reset bug (#60693): Chromium silently resets
webContentszoom when the display topology changes — monitors going to sleep, waking with stagger, or being connected/disconnected.These events fire on Electron's
screenmodule, not on theBrowserWindow, so the existing window-level reassert ininstallZoomReassertOnWindowEvents(added in #66988) never runs. On multi-monitor setups with staggered wake (common on Windows), window-levelresized/movedevents may also arrive before all displays have settled, causing the persisted zoom to be applied and immediately overwritten by a later display change.Root Cause
The existing zoom reassert covers three trigger categories:
BrowserWindoweventsinstallZoomReassertOnWindowEvents(#66988)webContents.did-finish-loadscreenmodule eventsThe codebase already uses this exact
screen.on()pattern for the macOS wake indicator repositioning (main.ts:11835-11839), so this PR follows an established precedent.Changes Made
apps/desktop/electron/zoom.ts: AddinstallZoomReassertOnDisplayEvents(screen, win, reassert)— subscribes todisplay-metrics-changed,display-added, anddisplay-removedon thescreenmodule with a 300ms debounce (vs 100ms for window resize) to absorb staggered multi-monitor wake. Cleans up all listeners on window close.apps/desktop/electron/main.ts: Call the new function inwireCommonWindowHandlersalongside the existing window-level reassert, passing the already-importedscreenfrom Electron.apps/desktop/electron/zoom.test.ts: 5 new tests covering: event wiring, debounce coalescing, destroyed-window skip, listener cleanup on close, and no-op guards.How to Test
vitest run apps/desktop/electron/zoom.test.ts— all zoom tests passVerified on Windows 11 with a 3-monitor setup over 3 days of daily monitor sleep/wake cycles — zoom persisted correctly after the fix where it previously reset ~50% of the time.
Checklist
Code
Documentation & Housekeeping
Technical Details
Why 300ms debounce (not 100ms)? Multi-monitor wake is staggered: display 1 wakes at T+0, display 2 at T+150ms, display 3 at T+250ms. Each wake fires
display-metrics-changed. The existing 100ms window-event debounce is too short — a reassert at T+100ms gets overwritten by the display-2 wake at T+150ms. 300ms lets all monitors settle before re-applying the persisted zoom.Why pass
screenas a parameter instead of importing it? Matches the existinginstallZoomReassertOnWindowEventspattern whereplatformis passed in rather than read from globals — keeps the function pure and testable without booting Electron.Listener cleanup. Each call to
wireCommonWindowHandlers(main window + each session window) registers 3screen.on()listeners. Without cleanup onwin.on('closed'), these would accumulate across session windows and leak stale window references. Theclosedhandler callsscreen.off()for all three events.