Skip to content

perf: SCStream configuration hygiene (queue depth, sRGB, opaque)#11

Open
divanshu-go wants to merge 1 commit into
screenpipe:mainfrom
divanshu-go:feat/stream-config-hygiene
Open

perf: SCStream configuration hygiene (queue depth, sRGB, opaque)#11
divanshu-go wants to merge 1 commit into
screenpipe:mainfrom
divanshu-go:feat/stream-config-hygiene

Conversation

@divanshu-go

@divanshu-go divanshu-go commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What

Three SCStreamConfiguration settings for every stream this crate creates (persistent screenshot + high-fps HD).

Setting Why
queue_depth(3) Each retained queue slot pins an IOSurface, and both the latch and push consumers only ever want the newest frame. 3 is the OS minimum/recommended floor — set explicitly so a future SDK default change can't silently grow resident memory.
explicit sRGB color space Without it, frames arrive in the display's native color space (Display P3 on modern Macs): every consumer pays an implicit conversion, and untagged JPEGs written downstream (assumed sRGB by viewers) render subtly wrong. sRGB at the source means WindowServer converts once, on the GPU.
should_be_opaque(true), gated macos_available("14.0") Display captures have no meaningful alpha, so the compositor can skip alpha premultiply work per frame. The property is macOS 14.0+ — unguarded, the selector throws unrecognized-selector on 12.3–13.x (guard follows the existing set_show_mouse_clicks pattern).

Three SCStreamConfiguration settings for every stream this crate
creates (persistent screenshot + high-fps HD), each with an
independent motivation:

- queue_depth(3): each retained queue slot pins an IOSurface, and both
  the latch and push consumers only ever want the newest frame. 3 is
  the OS minimum/recommended floor — set it explicitly so a future SDK
  default change can't silently grow resident memory.

- Explicit sRGB color space: without it, frames arrive in the
  display's native color space (Display P3 on modern Macs), every
  consumer pays an implicit conversion, and untagged JPEGs written
  downstream (assumed sRGB by viewers) render subtly wrong. sRGB at
  the source means WindowServer converts once, on the GPU.

- should_be_opaque(true), gated behind macos_available("14.0") where
  the property exists (unguarded, the selector throws
  unrecognized-selector on 12.3–13.x — same pattern as the existing
  set_show_mouse_clicks guard): display captures have no meaningful
  alpha, so the compositor can skip alpha premultiply work per frame.

Behavior note: on P3 displays captured pixel values change slightly
(they were previously P3 values in untagged buffers). Grayscale-based
consumers (Vision OCR) are unaffected; stored JPEGs now render more
accurately in viewers that assume sRGB.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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