macOS: resample deferred surface resize events - #4625
Open
yay wants to merge 3 commits into
Open
Conversation
yay
force-pushed
the
codex/macos-current-size-after-scale-change
branch
from
July 20, 2026 23:49
060fe7b to
68fbe78
Compare
yay
marked this pull request as ready for review
July 21, 2026 09:47
Contributor
Author
|
Any thoughts on this fix? It's only a few lines of code and straightforward in nature, so hopefully should be easy to review. |
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.
Issue
Notice 20pt-wide black bars. These can show up on egui app launch, if the app was previously open on a bigger screen, got closed, and is now launching on a smaller screen, where the app window has to size down to fit.
Summary
Re-sample an AppKit view's backing size when a deferred
SurfaceResizedcallback is delivered,rather than emitting the size captured when the callback was queued.
This remains a draft while the fix undergoes a downstream soak.
Root cause
AppKit can synchronously resize a view while Winit is already handling an application event. Winit
cannot re-enter the application handler, so
WinitView::surface_resizeddefers its callback to thedefault run-loop mode.
AppKit may then continue a live-resize transition in event-tracking mode. Those newer resize events
can be delivered before the default-mode callback resumes. Because the deferred callback captured
its size eagerly, it could subsequently emit an older size and overwrite the renderer's correct
surface configuration.
In the reproduced failure:
4096x2254resize was deferred while the window became visible.4056x2214.4056x2214.4096x2254.2028x1107points at a 2x backing scale, leaving20-point black bars at the right and bottom edges.
Repainting or changing appearance did not reconfigure the surface, while a manual window resize
did and immediately removed the bars.
Reproduction
2560x1440 (Default).2048x1152.The failure is timing-sensitive, but this sequence makes it substantially easier to reproduce.
Fix
WinitViewin the deferred callback and readsurface_size()when that callback isactually delivered.
ScaleFactorChangedthrough the same helper, preservingSurfaceSizeWriterrequests while reporting AppKit's authoritative final backing size.