Skip to content

macOS: target thumbnail screenshot can hang, leaving the screen-recording indicator (and "Your screen is being observed") stuck — even after Cap quits #2339

Open

Description

@segfaultlab

Summary

On launch (no recording started), Cap captures display/window thumbnails with SCScreenshotManager. One of those screenshot requests never completed. While it was pending, macOS kept a screen-capture session open for Cap, so the purple screen-recording indicator stayed on and the lock screen showed "Your screen is being observed".

After Cap quit, replayd ran its per-client cleanup (stopAllStreamsWithError), but the stuck screenshot stream was not released. The indicator kept attributing screen capture to so.cap.desktop until I force-restarted replayd.

The hang itself looks like a ScreenCaptureKit/macOS issue, and so does the missing cleanup on exit. On Cap's side, the Tauri app awaits each thumbnail with no timeout. Once a request hangs, nothing on Cap's side can end it.

Environment

  • Cap desktop 0.6.0 (Tauri app, /Applications/Cap.app, bundle id so.cap.desktop)
  • macOS 27.0 (build 26A428)
  • MacBookPro18,3 (Apple Silicon), single built-in display

Steps to reproduce

  1. Make sure Cap is not running and no screen-recording indicator is shown.
  2. In Terminal, start watching the indicator and capture sessions:
    log stream --style compact --predicate '(process == "ControlCenter" AND category == "sensor-indicators") OR (process == "replayd" AND eventMessage CONTAINS "SLContentStream")'
    
  3. Launch Cap. Do not start a recording.
  4. Count SLContentStream start: against SLContentStream stop: lines, and watch whether Active activity attributions stays at ["scr:so.cap.desktop"].
  5. Quit Cap and check whether the indicator clears.

This reproduced on my first attempt. I have not measured how often it happens.

What I observed

Clean launch at 08:06:18, no recording:

08:06:18.441  SLContentStream start   -> 08:06:18.459 stop   (ok)
08:06:18.566  SLContentStream start   -> 08:06:18.567 stop   (ok)
08:06:18.679  SLContentStream start   -> 08:06:18.681 stop   (ok)
08:06:18.743  SLContentStream start   -> never stopped        <-- hung
08:06:46.545  SLContentStream start   -> 08:06:46.550 stop   (ok)
08:07:10.690  SLContentStream start   -> 08:07:10.702 stop   (ok)

Every start came from +[SCScreenShotSession captureSLContentStreamScreenshot:withCompletionHandler:], so these are screenshot sessions, not recording streams. From 08:06:18.743 on, ControlCenter reported:

Active activity attributions changed to ["scr:so.cap.desktop"]

Quit at 08:07:39:

08:07:39.443 replayd  invalidated because the client process (pid 23425) either cancelled the connection or exited
08:07:39.444 replayd  -[RPClient stopAllStreamsWithError:stopReason:] stopReason=0
08:08:06.150 ControlCenter  Sorted active attributions from SystemStatus update: [[scr] Cap (so.cap.desktop)]   <-- Cap is gone, indicator still on

The indicator only cleared after replayd was killed. launchd then restarted it.

Earlier, in normal use (before I knew the cause)

  • ControlCenter attributed 2–3 concurrent scr sessions to Cap for about 17 hours. Cap's own log (~/Library/Logs/so.cap.desktop) shows only two short studio recordings (5–6 s each) in that period, and both pipelines shut down cleanly.
  • The long-lived sessions started shortly after a sleep/wake. Cap logged System woke from sleep; scheduling recovery refresh at that point.
  • Cap exited normally (Exit cleanup completed elapsed_ms=11). One scr attribution then stayed for more than 3 hours until replayd was restarted.

My guess is that each thumbnail refresh (for example after wake) can leak one more hung session. I could not confirm this because the detailed logs from that period had already rotated.

Relevant code (tag cap-v0.6.0)

What I don't know

  • Which display or window the hung request was for. replayd logs the filter as <private>.
  • Whether this reproduces on macOS 26.x, or only on 27.0.

Possible mitigations

  1. Put a per-thumbnail timeout around capture_sample_buf (for example 2 s) and skip that target on timeout. This keeps the picker from blocking. It probably does not clear the indicator, because SCScreenshotManager has no cancel API and dropping the future leaves the system session open.
  2. For thumbnails, use a short-lived SCStream (the existing scap_screencapturekit::Capturer): take the first frame, then call stopCapture explicitly, including on timeout. Cap then owns the session's lifetime. I have not verified that stopCapture releases a stream that never delivered a frame.
  3. The missing cleanup on exit (the screenshot session survives the client's stopAllStreams) looks like a macOS bug. It is probably worth a Feedback Assistant report to Apple as well.

Workaround for affected users: quit Cap, then reboot, or run killall -9 replayd (launchd restarts it).

Activity

  1. linear commented on Sep 23, 2026

    @linear
  2. richiemcilroy commented on Nov 4, 2026

    @richiemcilroy
    Member

    Thanks for the thorough investigation! The native app in 0.6.2 now times out a hung thumbnail capture instead of waiting on it forever. Could you check whether the indicator still gets stuck on the latest version?

  3. akira63 commented on Nov 17, 2026

    @akira63

    Testing on the latest release: yes, it still gets stuck on 0.6.3, and the 5 s timeout from 0.6.2 does not clear it (which matches your own prediction in the report that mitigation #1 wouldn't release the session).

    Re-test on 0.6.3 (latest)

    • Cap: 0.6.3 (build 0.6.3, so.cap.desktop) — latest release
    • macOS: 27.2.1 (build 26B131)
    • Hardware: Mac mini (Mac16,10), Apple M4, 16 GB, single display
    • Screen recording permission: granted

    The timeout is definitely active — Cap's own log shows it firing:

    2026-11-17T01:00:47.612Z  WARN cap_gpui::target_thumbnails:
    thumbnail capture did not answer; pausing thumbnail captures
    what="window thumbnail" timeout_ms=5000 pause_secs=300
    

    So the future now returns control after 5 s instead of blocking the picker forever, but the underlying capture session is still left registered — isScreenShared stays 1 and the indicator stays attributed to Cap.

    Timeline of the stuck state

    00:58:52.574  WindowServer  Process creation: (Cap) pid 3992
    00:58:53.287  Cap[3992] (ScreenCaptureKit)  -[SCStream initWithFilter:configuration:delegate:]
    00:58:53.287  Cap[3992] (ScreenCaptureKit)  -[SCStreamManager registerStream:]
    00:58:53.383  Cap[3992] (ScreenCaptureKit)  -[SCStream dealloc] 0x799ccd5f80          # first stream released
    00:58:53.424  Cap[3992] (ScreenCaptureKit)  -[SCStream initWithFilter:configuration:delegate:]   # second stream, no dealloc follows
    00:58:53      NotificationCenter  Set auxiliary state; isScreenShared: 0 -> 1        # flips ON here
    00:59:21.297  WindowServer  Process death: (Cap) pid 3992                            # Cap exits ~28 s later
    

    From 00:58:53 onward isScreenShared never returned to 0 — it was still 1 more than 8 hours later, across multiple sleep/wake cycles and a screen lock:

    09:01:22  donotdisturbd  Resolution modified: isScreenMirrored=0 isScreenShared=1 isPresentationModeEnabled=0
    

    Additional user-visible symptom: Apple Watch auto-unlock is disabled

    This is the part that made it noticeable. While the flag is stuck, macOS refuses Apple Watch unlock and tells the user the screen is being observed. From loginwindow at the moment of a failed unlock:

    AutoUnlock state:2 - Inactive, message:'共享屏幕时,无法使用Apple Watch解锁'
    

    ("Cannot use Apple Watch to unlock while the screen is being shared.")

    The Watch itself was fine — same second, rapportd/coreauthd discovered the paired device with AutoUnlockEnabled:

    08:41:20  coreauthd  Device found: ... AutoUnlockEnabled, PairedBT, DF 0x29 < MyMe MyiCloud >
    

    So the only thing blocking unlock is the leaked capture session. Users get locked into typing their password with no way to clear it, and the lock screen shows a "your screen is being observed" warning that is, at that point, untrue.

    Verified there is no real capture at that time

    While the flag was stuck, nothing was capturing:

    Cap process             : not running (process death at 00:59:21)
    CGDisplayIsCaptured     : False
    com.apple.screensharing : not running
    TCP 5900 (VNC)          : no listener
    AirPlay mirroring       : off
    

    Only a reboot / logout clears the flag. I did not try killall -9 replayd because it tears down every in-flight capture session on the machine, but I expect it would work as you described.

    Two notes that may narrow the fix

    1. This is a second leak path, not only the SCScreenshotManager one. The leaked object here is a real SCStream (-[SCStream initWithFilter:configuration:delegate:] + -[SCStreamManager registerStream:]), created from the app's capture path — the first stream got a clean -[SCStream dealloc], the second never did. Timeout around capture_sample_buf / SCScreenshotManager won't cover it.
    2. The leak survives process death. Cap exited normally ~28 s after creating the stream (no crash report was written), and macOS still kept the attribution. So even a perfect stopCapture on the quit path would not help in this case; if a stream can be orphaned while the process is alive, the fix likely needs to cover "stream created, never delivered a frame, never stopped" rather than only the quit path.

    Happy to attach a sysdiagnose or run the log stream predicate from your report on this machine if that helps.

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions