Skip to content

[Win32] Adapt to a zoom change without exhausting native callbacks - #3897

Draft
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:win32-zoom-change-single-timer
Draft

HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:win32-zoom-change-single-timer

Conversation

@HeikoKlare

Copy link
Copy Markdown
Contributor

Problem

When a shell moves to a monitor with another scaling, every control is adapted to the new zoom in a task of its own, scheduled as an OS timer with a native callback of its own. Native callbacks come from a small fixed pool shared by the whole application. A shell with more than about 250 controls, such as the Eclipse IDE workbench window, uses all of them up until the zoom change has been processed. Meanwhile, any code that needs a new native callback fails with "No more callbacks", for example creating an editable Combo, opening a MessageBox or ColorDialog, or the font fallback of a TextLayout.

Solution

A zoom change now queues the adaptation of its controls and processes the queue with a single timer of the Display, which takes no native callback at all. The queue is processed in slices of at most 50 ms, between which the event loop handles other messages, as it did between the per-control timers. The controls are still adapted breadth-first, and the shell is still laid out once all of them have been adapted. If the timer cannot be started, the queue is processed right away, so the zoom change still completes.

Users should notice no difference, other than that other code no longer fails while a zoom change is processed. Moving an IDE-like shell with about 850 controls between a 100% and a 150% monitor took as long as before within the run-to-run spread, as the synchronous parts of a monitor change (Windows' own DPI handling, resizing the shell, the final layout) dominate.

The new tests adapt a shell with 1200 controls to a new zoom and create a native callback from the zoom changed listener of the last control, which fails on master with "No more callbacks", and simulate a timer that cannot be started to check that the zoom change still completes.

🤖 Generated with Claude Code

When a shell moves to a monitor with another scaling, every control is
adapted to the new zoom in a task of its own, scheduled as an OS timer with
a native callback of its own. Native callbacks come from a small fixed pool
shared by the whole application. A shell with more than about 250 controls,
such as the Eclipse IDE, uses all of them up until the zoom change has been
processed. Meanwhile, any code that needs a new native callback fails with
"No more callbacks", for example creating an editable Combo, opening a
MessageBox or ColorDialog, or the font fallback of a TextLayout.

A zoom change now queues the adaptation of its controls and processes the
queue with a single timer of the Display, which takes no native callback at
all. The queue is processed in slices of at most 50 ms, between which the
event loop handles other messages, as it did between the per-control
timers. The controls are still adapted breadth-first, and the shell is
still laid out once all of them have been adapted, also when the timer
cannot be started, in which case the queue is processed right away. The
time until a shell has settled after a monitor change is unchanged.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Test Results (win32)

  179 files  ±0    179 suites  ±0   21m 27s ⏱️ + 4m 35s
5 190 tests +2  5 104 ✅ +2   86 💤 ±0  0 ❌ ±0 
5 387 runs  +4  5 130 ✅ +2  257 💤 +2  0 ❌ ±0 

Results for commit d4f25e1. ± Comparison against base commit 16080ee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant