perf: SCStream configuration hygiene (queue depth, sRGB, opaque)#11
Open
divanshu-go wants to merge 1 commit into
Open
perf: SCStream configuration hygiene (queue depth, sRGB, opaque)#11divanshu-go wants to merge 1 commit into
divanshu-go wants to merge 1 commit into
Conversation
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>
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.
What
Three
SCStreamConfigurationsettings for every stream this crate creates (persistent screenshot + high-fps HD).queue_depth(3)should_be_opaque(true), gatedmacos_available("14.0")set_show_mouse_clickspattern).