Sender: GUI options for screensaver/wake handling, stable extended-display identity, diagnostic logging#69
Closed
DrDavidL wants to merge 2 commits into
Closed
Conversation
Adds three user-controllable options in the sender GUI to avoid the "stutter that needs an app restart" symptom after the screensaver or display sleep activates while streaming. - Settings toggle "Prevent screensaver / display sleep while streaming" (default on, persisted) gates passing `.idleDisplaySleepDisabled` to `ProcessInfo.beginActivity`, so the screensaver/display-sleep does not engage during an active session. - Settings toggle "Auto-restart capture after wake / unlock" (default on, persisted) enables observers on `screensDidWake`, `com.apple.screenIsUnlocked`, and `com.apple.screensaver.didstop`. When fired, the capture pipeline (SCStream/CGDisplayStream + VTCompressionSession + capture timers + activity) is torn down and rebuilt while keeping the network connection and the virtual display alive. The PTS sequence counter is reset so the receiver's pacing does not desync after the gap. - Per-session "Restart capture" button (enabled while streaming) runs the same soft-restart path on demand for any other stutter cause. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
|
Thank @DrDavidL I put the Pr in the new release. |
…t toggles off After field testing, the prior toggles did not address the long-running stutter (which is duration-driven, not screensaver-driven). Updates: - Default both "Prevent screensaver / display sleep" and "Auto-restart capture after wake" to OFF. Both remain available for users who find them useful; existing UserDefaults values are preserved. - Derive the extended-desktop virtual display productID/serialNumber deterministically from the receiver identity (name + panel dimensions) instead of randomizing each session. macOS keys window-position memory on these fields, so the random identity caused windows on the extended display to be forgotten on every reconnect. Same receiver now produces the same virtual display identity across reconnects, which lets the system restore prior window placement and matches the identity convention already used for the saved arrangement key. - Add an opt-in "Log virtual display events to Console (verbose)" toggle (default off). When enabled, registers a CGDisplayRegisterReconfigurationCallback that logs every add / remove / mirror / mode-change event affecting any display, and emits a periodic (60 s) stream snapshot to NSLog with streaming state, FPS, virtual display online status, pending packet count, in-flight encode count, and PTS sequence. Intended for diagnosing the long-duration stutter from Console.app without leaving heavy logging on for ordinary users. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 28, 2026
Contributor
Author
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.
Summary
Sender-side GUI options that address two separate observed issues — windows on the extended display being forgotten after each reconnect, and intermittent post-event stutter — plus diagnostic plumbing for a longer-duration stutter that is still being characterized.
After in-field testing of the original screensaver-focused commit, both screensaver-related toggles default to off in this update — they didn't fix the long-duration stutter reproduced by the user and the actual repro cause appears to be unrelated to display sleep. They remain available as options for setups where they help.
Changes
Stable extended-display identity (
ReceiverBackedVirtualDisplaySession.swift)extendedDesktop()call. macOS keys window-placement memory on those fields, so every reconnect looked like a brand-new display and windows on it were not restored.profile.receiverName + panelWidth + panelHeight— same fields the codebase already uses for the persisted extended-arrangement key. Same receiver → same virtual display identity across reconnects → window placement persists.TBDisplayCaptureSource.virtualDisplayIdentitynow takes aTBMonitorDisplayProfile.Settings card toggles (
TBDisplaySenderContentView.swift,TBDisplaySenderManager.swift,TBDisplaySenderService.swift).idleDisplaySleepDisabledtoProcessInfo.beginActivityso the screensaver cannot engage during a session.screensDidWakeNotification,com.apple.screenIsUnlocked, andcom.apple.screensaver.didstop, and soft-restarts the capture pipeline (SCStream/CGDisplayStream+VTCompressionSession+ capture timers + activity) while preserving theNWConnectionand the virtual display. PTS sequence is reset to avoid receiver-side pacing desync.CGDisplayRegisterReconfigurationCallbackto log every add/remove/mirror/mode-change event affecting any display, and emits a 60 s stream snapshot toNSLogcontaining streaming state, FPS, virtual display online status, pending packet count, in-flight encode count, and PTS sequence. Intended for diagnosing the long-duration stutter fromConsole.appwithout leaving heavy logging on for ordinary users.Per-session button
NWConnection; the long-duration stutter so far does not appear to be cleared by this and remains under investigation (see the verbose logging toggle).UserDefaults keys:
fd.tbdisplaysender.preventDisplaySleep,fd.tbdisplaysender.autoRestartOnWake,fd.tbdisplaysender.verboseDisplayLogging. Existing stored values are preserved across the default flip.Localized in IT / EN / DE.
Test plan
TBDisplaySenderscheme) — verified locally, builds clean.main.TargetBridge: system wake — soft restart of capture pipeline).NWConnectionand virtual display remain.Console.appshows reconfiguration events and the 60 s snapshot lines.🤖 Generated with Claude Code