Repository navigation
Agent: redraw macOS windows after display wake or change - #1641
Open
AnthonyRonning wants to merge 1 commit into
Open
AnthonyRonning wants to merge 1 commit into
AnthonyRonning wants to merge 1 commit into
Conversation
Since the gpui update, macOS 14+ windows are paced by a CAMetalDisplayLink. After a lid close, undock or sleep, a window can stop painting while input and state keep working, until a restart (#1640, zed-industries/zed#67004). On display wake, system wake and screen-parameter changes, ask each window's view to redisplay: gpui then draws one frame synchronously and attaches a new display link. A second pass runs once displays settle. If a visible window still gets no frame request within 2 s, log a warning for diagnosis. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Mitigation for #1640: Maple Work's window can stop painting after a lid close, undock or display change, while input and app state keep working, until the app restarts.
Cause (likely, not reproduced)
The gpui update in #1571 brought Zed's move of macOS 14+ frame pacing to a
CAMetalDisplayLinkon the window's layer (zed-industries/zed#65472). gpui wakes that link only when a window first becomes dirty, so a link that has gone silent, or is missing, is never woken again. Zed has an open report with the same signature: zed-industries/zed#67004 (process idle, no frames, only a restart helps). We are leaving the real fix to Zed. This is a small app-side recovery until then.Change
New macOS-only
desktop/native_redraw.rs, installed at startup (a failure only logs a warning):NSWorkspaceScreensDidWakeNotification,NSWorkspaceDidWakeNotificationandNSApplicationDidChangeScreenParametersNotification.setNeedsDisplay:on its view. gpui'sdisplayLayer:then draws one frame synchronously and attaches a new display link. A second pass runs 1 s later, once displays settle; bursts share that pass.no frame request within 2s of a display change; the window may have stopped painting. If this recurs, the log shows whether the recovery ran and failed.Cost: one extra synchronous frame per window per wake or display change.
Limits
Testing
just ci-lintand the pre-commitci-testpass.DYLD_INSERT_LIBRARIES(not committed):CAMetalDisplayLink(unpause ignored), as in the frozen window. After the notifications, each pass made gpui create a new link (Public Release #2, teeny fix for nav spacing #3), and no warning followed, so frame requests resumed.GPUIView displayLayer:also turned into a no-op. Both passes logged the warning, which confirms the link really was dead and the detection works.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.