Skip to content

Rewind screenshots are stored with a ~21% black band baked in (SCK scalesToFit + point-derived size) #11207

Closed

Description

@Archit-lal

Rewind screenshots are stored with a wide black band baked into the image. Measured on a real captured frame: the band runs from x 1007 to x 1213.5 of the frame — 21% of the image width. Useful pixels end up 773×541 inside a 1382×541 player stage, about 30% of the surface displaying it.

It is in the stored image, not the layout. The band sits inside the app-coloured border, which RewindPage.swift:711–725 draws at the photo's exact computed bounds. Nothing in RewindPage, RewindStorage.loadScreenshotImage, or the frame loader composites onto a canvas. No display-side change can remove it — the pixels are on disk that way.

Leading suspect (desktop/macos/Desktop/Sources/Rewind/Services/ScreenCaptureService.swift:888-892):

let config = SCStreamConfiguration()
config.scalesToFit = true
config.showsCursor = false
config.width = size.width
config.height = size.height

With scalesToFit = true, ScreenCaptureKit letterboxes with black whenever the requested output aspect differs from the source's. config.width/height are set from a size derived from window geometry in points, while SCK captures in pixels — on a Retina display that is a 2× factor, and any resulting aspect mismatch is filled with black rather than cropped or rescaled.

A second candidate worth ruling out: VideoChunkEncoder's aspect-change debounce retaining a wider chunk canvas across a resize, so frames captured after a window narrows are padded to the older, wider canvas.

Not investigated: whether this affects every captured window or only some (e.g. only windows whose aspect differs from the display's), and whether the same padding reaches the video chunks as well as the stills. Both are worth establishing before fixing, since they point at different lines.

Filed rather than fixed because it surfaced during layout work on the Rewind page and is a capture-path defect, not a display one.

Activity

  1. kodjima33 commented on Aug 10, 2026

    @kodjima33
    Collaborator

    Investigated at 685d896b4b. The leading suspect in the report is ruled out — but I could not capture a frame on this machine, so the replacement hypothesis is unverified and I did not open a PR.

    1. scalesToFit + point-derived size cannot letterbox here

    First, the path moved: it is desktop/macos/Desktop/Sources/ScreenCaptureService.swift, not .../Rewind/Services/.... The cited config is captureConfiguration(for:maxSize:) (ScreenCaptureService.swift:885-899), and it does not set width/height straight from window geometry — it goes through ScreenCaptureService.captureDimensions (:869-882):

    let aspectRatio = width / height
    var configWidth = min(width, maxSize)
    var configHeight = configWidth / aspectRatio

    That has been the shape since 1bc1327994 (2026-07-14), i.e. already in place when this was filed. The requested aspect is derived from window.frame's own ratio, so it equals the source aspect by construction and scalesToFit has nothing to pad. Points-vs-pixels is a resolution factor, not an aspect factor — a 2x Retina source scaled into a 1x-sized destination of the same ratio comes back downscaled, not letterboxed. The only mismatch left is Int() truncation, which is sub-pixel.

    Both capture entry points share that config (captureWithScreenCaptureKit :915, captureWindowCGImage :972), so neither can produce a 21% band this way.

    2. The second candidate (video-chunk canvas) also does not letterbox

    VideoChunkEncoder.createPixelBuffer draws into the full canvas rect (VideoChunkEncoder.swift:1028):

    context.draw(image, in: CGRect(x: 0, y: 0, width: width, height: height))

    A frame that differs from the retained chunk canvas is therefore stretched, not padded. (Frames beyond the 20% threshold are dropped during the 2s debounce, :293-333.) So the aspect-debounce path can distort a frame by up to 20% but cannot bake in black.

    3. What fits the evidence instead: transparent margin flattened to black

    A one-sided, non-centred band is wrong for scalesToFit (it centres). It is the right shape for alpha becoming black:

    • SCContentFilter(desktopIndependentWindow:) includes the window's shadow/transparent margin unless config.ignoreShadowsSingleWindow = true, and SCStreamConfiguration.backgroundColor defaults to clear. Neither is set in captureConfiguration.
    • Those transparent pixels then hit two lossy-to-black sinks: JPEG has no alpha (encodeJPEG / jpegData(from:)), and createPixelBuffer draws onto a zeroed BGRA buffer with premultipliedFirst — untouched pixels stay 0,0,0.

    That predicts black exactly where the window is transparent, in the stored bytes, on whichever side the transparent region sits — which is what the report measured.

    Why no PR

    The check is one capture, but this process is denied Screen Recording TCC (SCStreamErrorDomain Code=-3801), so I can neither reproduce the band nor confirm the fix. The experiment for whoever picks this up: capture one window with the current config, then re-capture with config.ignoreShadowsSingleWindow = true and config.backgroundColor = .black/.white, and diff the black-column count. If it drops to zero, the fix is those two lines in captureConfiguration (plus an opaque fill before context.draw for the video path). Ruling that in also answers the report's open question about whether it hits every window — it would hit only windows with transparent margins.

    🤖 hourly desktop bug watchdog — analysis only, no code change.

  2. moved this from Someday to In progress in omi TODO / bountieson Sep 8, 2026
  3. moved this from In progress to In review in omi TODO / bountieson Sep 8, 2026
  4. added a commit that references this issue on Sep 8, 2026
    5fc7d79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions