Commit 8b6d20c
Fix hyperion-project#1921: replace per-frame SCScreenshotManager with persistent SCStream
Previously capture15() called getShareableContentWithCompletionHandler on
every single frame grab (10-60 times/second), causing WindowServer to spike
in CPU usage and occasional frame-rate drops on macOS Tahoe.
Replace with a persistent SCStream (started once in setDisplayIndex):
- getShareableContentWithCompletionHandler is called only once at setup
- HyperionStreamOutput (SCStreamOutput delegate) receives frames on a
high-priority dispatch queue and stores the latest CVPixelBuffer
- grabFrame() reads directly from the CVPixelBuffer — no CIImage/CIContext
overhead, no per-frame system enumeration
- Stream pixel format kCVPixelFormatType_32BGRA maps directly to BGR32,
eliminating an extra copy/conversion step
- Falls back to single-shot screenshot if the stream fails to start or
no frame has been delivered yet
Additional fixes in the same file:
- Fix missing braces in setupDisplay() that caused early return even when
CGRequestScreenCaptureAccess() succeeded
- Fix CGDisplayModeRef leak in capture15() (missing CGDisplayModeRelease)
- Fix CGColorSpaceRef leak in capture15() (CGColorSpaceCreateDeviceRGB
result was never released)
- Reduce queueDepth from 5 to 3 for lower latency
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 71c9d3a commit 8b6d20c
2 files changed
Lines changed: 447 additions & 167 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
61 | 75 | | |
0 commit comments