Repository navigation
desktop: stop CleanShot/Shottr/macOS screenshots from stalling 20-60s - #6819
Conversation
The 2s TTL always expired before the next 3s Rewind capture tick, so every capture hit WindowServer to re-enumerate windows. A 5s TTL lets consecutive captures reuse the snapshot; force-refresh on window miss still handles switches. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Omi's 3s capture loop uses ScreenCaptureKit every tick, which contends with third-party screenshot apps (CleanShot X, Shottr, macOS screenshot UI, Loom, OBS, Snagit, Monosnap, etc.) for WindowServer locks. That contention can stall the user's capture UI for 20-60s. Skip capture while a known screenshot app is frontmost, and hold the pause for 10s after it resigns so the app's post-capture flow (save, encode, editor window) doesn't get interrupted. Trade-off: ~10s Rewind blind spot around each screenshot. Acceptable because user isn't actively focused on other apps during that window. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Greptile SummaryAdds a screenshot-app yield mechanism to Confidence Score: 5/5Safe to merge — all remaining findings are P2 style/cleanup suggestions with no impact on correctness in the normal path. The core logic (bundle-ID set lookup, early-return in captureFrame, backoff date management, TTL change) is correct and well-motivated by measured data. Both open findings are minor: year-specific Snagit IDs are a future maintenance concern, and the missing state reset in stopMonitoring() produces at most a silent ~10 s capture skip after an unusual stop/start sequence. Neither blocks safe deployment. ProactiveAssistantsPlugin.swift — Snagit bundle ID list will need annual updates and backoff state should be reset in stopMonitoring(). Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([captureFrame tick]) --> B{Permission\ncheck due?}
B -- Yes --> C[checkPermission]
C -- revoked --> D([stopMonitoring])
C -- granted --> E
B -- No --> E
E{isInSpecialSystemMode?}
E -- Yes --> F([return — skip frame])
E -- No --> G{isScreenshotAppFrontmost?}
G -- Yes --> H[log pause\nwasScreenshotAppFrontmost = true\nbackoffUntil = now + 10s]
H --> F
G -- No --> I{wasScreenshotAppFrontmost?}
I -- Yes --> J[log resume\nwasScreenshotAppFrontmost = false]
J --> K
I -- No --> K
K{Date < backoffUntil?}
K -- Yes --> F
K -- No --> L[Resolve active window\nSCShareableContent cache TTL ≤5 s\nCapture via SCK / CLI fallback]
L --> M([Distribute to assistants\nand RewindIndexer])
|
| "com.techsmith.snagit2025", // Snagit (current) | ||
| "com.techsmith.snagit2024", // Snagit (prior) | ||
| "com.techsmith.snagit2023", // Snagit (older) | ||
| "com.obsproject.obs-studio", // OBS Studio |
There was a problem hiding this comment.
Snagit year-suffix IDs will become stale
Only snagit2023, snagit2024, and snagit2025 are listed. TechSmith ships a new bundle ID every calendar year (e.g. com.techsmith.snagit2026), so the next major Snagit release won't be caught by this guard. Consider either adding a prefix-match fallback (e.g. checking bundleID.hasPrefix("com.techsmith.snagit")) or noting this in a TODO so the list gets updated with each Snagit release.
…BasedHardware#6819) ## Summary - Rewind pauses capture while a screenshot/recording app is frontmost so its capture UI no longer stalls 20–60s on WindowServer contention (CleanShot X, Shottr, macOS screenshot UI, Loom, OBS, Snagit, Monosnap, …) - 10s post-resign backoff protects the screenshot app's save/editor flow - SCShareableContent cache TTL 2s → 5s so the cache actually survives a 3s capture cycle (previous TTL was always expired by the next tick) ## Why Measured with `screencapture -x` while Omi was active: **avg 0.87s with Omi running vs 0.35s with Omi + CleanShot paused** — ~0.5s of WindowServer contention added per capture. In the worst case, `SCScreenshotManager.captureImage()` and CleanShot's own SCK session serialize on the WindowServer, producing the 20–60s lockups users report. Log analysis showed 11,279 `"Failed to start stream due to audio/video capture failure"` entries, confirming chronic SC contention. ## Trade-offs - **~10s Rewind blind spot around each screenshot**: acceptable because the user isn't focused on other apps during that window. - **5s stale window metadata** between captures: SCK still grabs live pixels — only the output config dimensions can briefly lag on rapid resize. Imperceptible in practice. - **Menu-bar-only recorders** (e.g. OBS recording without being frontmost) won't trigger the pause. Known limitation; add a generic SC-activity heuristic in a follow-up if needed. ## Test plan - [ ] Install named bundle and grant Screen Recording: `/Applications/omi-cleanshot-pause.app` - [ ] Trigger CleanShot hotkey → verify overlay appears within <1s (previously 20–60s) - [ ] Tail `/private/tmp/omi-dev.log | grep "Screenshot app"` — expect pause/resume log lines - [ ] Take 5 screenshots in 1 minute → Rewind timeline has ~10s gaps, no full-app hangs - [ ] Resize a window repeatedly → capture still works, window metadata eventually catches up 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…creen (#10204) Fixes #10143 — an active screen share in a call (Zoom/Teams/Meet) stops at the moment Omi takes its periodic Rewind screenshot. ## Root cause The Rewind capture path issues one-shot `SCScreenshotManager.captureImage` requests every ~1s. When another app is streaming the screen (an outgoing call share), the concurrent ScreenCaptureKit request contends in WindowServer capture arbitration; this is the same cause family as the CleanShot/Shottr 20–60s stall fixed by #6819, but the observed outcome — the user's share terminating — is worse. Apple documents no contract for concurrent capture (checked SCScreenshotManager/SCStream docs), so the mitigation is to not capture at all while a share is active. ## Fix - `ConferencingApps.isShareIndicatorWindow(ownerName:title:)` + `activeScreenSharePresent()`: detect the share-only chrome windows conferencing apps create while the user is presenting (Zoom "zoom share statusbar/toolbar window" floating controls, Teams "Screen sharing toolbar", the browser "<site> is sharing your screen/a tab/a window" stop-sharing bubble — this covers Google Meet and Teams web). Adding another app is a 2-line signature + test. - New `ProactiveExternalCaptureYield` (Core): one seam that runs both "yield to an external capture" gates — the existing screenshot-app gate (#6819) and the new share gate — each a `ProactiveScreenshotCaptureGate` with its own 10s post-condition backoff. The share check is an autoclosure so its CGWindowList enumeration is skipped when the screenshot gate already pauses the tick. Extracted (rather than grown in place) because `ProactiveAssistantsPlugin.swift` is frozen by the product file line-count ratchet; the plugin now makes a single `shouldYield` call. - Declares a new failure class, `FC-concurrent-capture-contention` (definition added in this PR, as `Failure-Class: new` requires): second instance of this cause after #6819; the reusable guard surface is the shared gate state machine + the new yield seam. Failure-Class: new ## Why per-app window signatures instead of a native "screen is being shared" API macOS has **no public API** that reports another app capturing/sharing the screen. `UIScreen.isCaptured` is iOS/Catalyst-only; the only macOS equivalent is the private SkyLight call `CGSIsScreenWatcherPresent()`. Even if we accepted a private API, any generic "screen watcher present" signal is self-confounded: **Omi itself is a screen watcher every ~1s**, so the signal would read true because of our own capture, not the call app's share. **Follow-up worth validating live** (needs a GUI session): whether one-shot `SCScreenshotManager` captures do *not* light the macOS 15 system capture indicator while persistent `SCStream` shares do. If that holds, enumerating the system indicator window becomes an app-agnostic signal covering Discord/Slack/any social app — qualified by a persistence threshold (N consecutive ticks) so a short-lived capture (a screenshot tool, a one-shot grab) is never misread as a video share. The `ProactiveExternalCaptureYield` seam is where that signal would plug in. ## Carried CI repair `4a8244742d` (#10181) removed floating-bar typing but left source-inspection tripwires anchored on the deleted composer (AgentPillLifecycleTests, FloatingBarTimingSignalTests), so the desktop Swift test target fails on every merge with main. This branch carries the tripwire re-anchor commit; the same repair rides in #10210, and #10211 carries an equivalent one — whichever merges first repairs main and the later copies merge as no-ops. The branch previously also carried a beta production-identity restore for INV-DATA-1; main has since been repaired canonically (beta is a channel on the production bundle id, #10219) and the updated `production-data-plane-routing` guard rejects the divergent identity, so that commit is reverted here — the branch no longer touches AppBuild/DesktopBackendEnvironment/OmiApp. (The single Failure-Class declaration above stays `new` for this PR's own FC-concurrent-capture-contention definition.) ## Verification - `xcrun swift build -c debug --package-path Desktop` — clean build. - `xcrun swift test --filter "ConferencingAppsTests|ProactiveAssistantOrchestrationPolicyTests"` — 23/23 pass: new share-indicator classification tests (positive Zoom/Teams/browser signatures; negatives for ordinary call windows, a Teams chat titled about screen sharing, non-conferencing owners) and new `ProactiveExternalCaptureYield` behavioral tests (pause across a share then backoff then resume; screenshot gate short-circuits the share check; reset clears both gates). - Full desktop Swift suite (`scripts/swift-test-suites.sh`, 344 suites): same result as pristine `origin/main` on this machine — 3 suites fail identically on both (AgentPillLifecycleTests, FloatingBarTimingSignalTests, ScreenRecordingPermissionPolicyTests; headless-environment failures, no GUI session), i.e. no regression from this change. - `make preflight` — 19/19 checks pass. - **Live verification (named bundle + real Google Meet share)**: built this branch as a named test bundle and ran a real Meet screen share against it. Log shows `Active screen share detected — pausing capture until the share ends` at share start, zero capture activity for the full ~2.5-minute share, `Screen share ended` on stop, and the encoder/indexer resuming frames ~9s later. The Meet share survived the entire session — the #10143 failure mode did not reproduce. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10204?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
…creen An active Zoom/Teams/Meet screen share stopped at the moment Omi took its periodic Rewind screenshot: the one-shot SCScreenshotManager.captureImage request contends with the share stream in WindowServer capture arbitration (same cause family as the CleanShot stall fixed in BasedHardware#6819, worse outcome). Pause the capture loop while a share-indicator window is present, plus a 10s backoff after the share ends. Both external-capture yield gates (screenshot app from BasedHardware#6819 + the new screen-share gate) now live in ProactiveExternalCaptureYield, extracted from the ratchet-frozen plugin file; the plugin makes a single shouldYield call and the ratchet baseline ratchets down (1641 -> 1628). The share check is an autoclosure so its CGWindowList enumeration is skipped when the screenshot gate already pauses the tick. Verification: xcrun swift build clean; swift test --filter 'ConferencingAppsTests|ProactiveAssistantOrchestrationPolicyTests' 23/23 pass (share-indicator signature tests + yield-gate behavioral tests: pause across a share then backoff then resume, screenshot gate short-circuits the share check, reset clears both gates). Live share repro NOT yet exercised - no GUI session on this machine; live validation plan documented in the PR body. Failure-Class: new Fixes BasedHardware#10143
Two fixes share this cause: BasedHardware#6819 (CleanShot/Shottr 20-60s stall while Omi's capture loop contends in WindowServer) and the BasedHardware#10143 fix in this PR (active call screen share stopping when Omi captures). Register the class so future concurrent-capture fixes declare it and reuse the ProactiveScreenshotCaptureGate / ProactiveExternalCaptureYield guard surface instead of adding one-off pauses.
…creen An active Zoom/Teams/Meet screen share stopped at the moment Omi took its periodic Rewind screenshot: the one-shot SCScreenshotManager.captureImage request contends with the share stream in WindowServer capture arbitration (same cause family as the CleanShot stall fixed in BasedHardware#6819, worse outcome). Pause the capture loop while a share-indicator window is present, plus a 10s backoff after the share ends. Both external-capture yield gates (screenshot app from BasedHardware#6819 + the new screen-share gate) now live in ProactiveExternalCaptureYield, extracted from the ratchet-frozen plugin file; the plugin makes a single shouldYield call and the ratchet baseline ratchets down (1641 -> 1628). The share check is an autoclosure so its CGWindowList enumeration is skipped when the screenshot gate already pauses the tick. Verification: xcrun swift build clean; swift test --filter 'ConferencingAppsTests|ProactiveAssistantOrchestrationPolicyTests' 23/23 pass (share-indicator signature tests + yield-gate behavioral tests: pause across a share then backoff then resume, screenshot gate short-circuits the share check, reset clears both gates). Live share repro NOT yet exercised - no GUI session on this machine; live validation plan documented in the PR body. Failure-Class: new Fixes BasedHardware#10143
Two fixes share this cause: BasedHardware#6819 (CleanShot/Shottr 20-60s stall while Omi's capture loop contends in WindowServer) and the BasedHardware#10143 fix in this PR (active call screen share stopping when Omi captures). Register the class so future concurrent-capture fixes declare it and reuse the ProactiveScreenshotCaptureGate / ProactiveExternalCaptureYield guard surface instead of adding one-off pauses.
…creen (BasedHardware#10204) Fixes BasedHardware#10143 — an active screen share in a call (Zoom/Teams/Meet) stops at the moment Omi takes its periodic Rewind screenshot. ## Root cause The Rewind capture path issues one-shot `SCScreenshotManager.captureImage` requests every ~1s. When another app is streaming the screen (an outgoing call share), the concurrent ScreenCaptureKit request contends in WindowServer capture arbitration; this is the same cause family as the CleanShot/Shottr 20–60s stall fixed by BasedHardware#6819, but the observed outcome — the user's share terminating — is worse. Apple documents no contract for concurrent capture (checked SCScreenshotManager/SCStream docs), so the mitigation is to not capture at all while a share is active. ## Fix - `ConferencingApps.isShareIndicatorWindow(ownerName:title:)` + `activeScreenSharePresent()`: detect the share-only chrome windows conferencing apps create while the user is presenting (Zoom "zoom share statusbar/toolbar window" floating controls, Teams "Screen sharing toolbar", the browser "<site> is sharing your screen/a tab/a window" stop-sharing bubble — this covers Google Meet and Teams web). Adding another app is a 2-line signature + test. - New `ProactiveExternalCaptureYield` (Core): one seam that runs both "yield to an external capture" gates — the existing screenshot-app gate (BasedHardware#6819) and the new share gate — each a `ProactiveScreenshotCaptureGate` with its own 10s post-condition backoff. The share check is an autoclosure so its CGWindowList enumeration is skipped when the screenshot gate already pauses the tick. Extracted (rather than grown in place) because `ProactiveAssistantsPlugin.swift` is frozen by the product file line-count ratchet; the plugin now makes a single `shouldYield` call. - Declares a new failure class, `FC-concurrent-capture-contention` (definition added in this PR, as `Failure-Class: new` requires): second instance of this cause after BasedHardware#6819; the reusable guard surface is the shared gate state machine + the new yield seam. Failure-Class: new ## Why per-app window signatures instead of a native "screen is being shared" API macOS has **no public API** that reports another app capturing/sharing the screen. `UIScreen.isCaptured` is iOS/Catalyst-only; the only macOS equivalent is the private SkyLight call `CGSIsScreenWatcherPresent()`. Even if we accepted a private API, any generic "screen watcher present" signal is self-confounded: **Omi itself is a screen watcher every ~1s**, so the signal would read true because of our own capture, not the call app's share. **Follow-up worth validating live** (needs a GUI session): whether one-shot `SCScreenshotManager` captures do *not* light the macOS 15 system capture indicator while persistent `SCStream` shares do. If that holds, enumerating the system indicator window becomes an app-agnostic signal covering Discord/Slack/any social app — qualified by a persistence threshold (N consecutive ticks) so a short-lived capture (a screenshot tool, a one-shot grab) is never misread as a video share. The `ProactiveExternalCaptureYield` seam is where that signal would plug in. ## Carried CI repair `4a8244742d` (BasedHardware#10181) removed floating-bar typing but left source-inspection tripwires anchored on the deleted composer (AgentPillLifecycleTests, FloatingBarTimingSignalTests), so the desktop Swift test target fails on every merge with main. This branch carries the tripwire re-anchor commit; the same repair rides in BasedHardware#10210, and BasedHardware#10211 carries an equivalent one — whichever merges first repairs main and the later copies merge as no-ops. The branch previously also carried a beta production-identity restore for INV-DATA-1; main has since been repaired canonically (beta is a channel on the production bundle id, BasedHardware#10219) and the updated `production-data-plane-routing` guard rejects the divergent identity, so that commit is reverted here — the branch no longer touches AppBuild/DesktopBackendEnvironment/OmiApp. (The single Failure-Class declaration above stays `new` for this PR's own FC-concurrent-capture-contention definition.) ## Verification - `xcrun swift build -c debug --package-path Desktop` — clean build. - `xcrun swift test --filter "ConferencingAppsTests|ProactiveAssistantOrchestrationPolicyTests"` — 23/23 pass: new share-indicator classification tests (positive Zoom/Teams/browser signatures; negatives for ordinary call windows, a Teams chat titled about screen sharing, non-conferencing owners) and new `ProactiveExternalCaptureYield` behavioral tests (pause across a share then backoff then resume; screenshot gate short-circuits the share check; reset clears both gates). - Full desktop Swift suite (`scripts/swift-test-suites.sh`, 344 suites): same result as pristine `origin/main` on this machine — 3 suites fail identically on both (AgentPillLifecycleTests, FloatingBarTimingSignalTests, ScreenRecordingPermissionPolicyTests; headless-environment failures, no GUI session), i.e. no regression from this change. - `make preflight` — 19/19 checks pass. - **Live verification (named bundle + real Google Meet share)**: built this branch as a named test bundle and ran a real Meet screen share against it. Log shows `Active screen share detected — pausing capture until the share ends` at share start, zero capture activity for the full ~2.5-minute share, `Screen share ended` on stop, and the encoder/indexer resuming frames ~9s later. The Meet share survived the entire session — the BasedHardware#10143 failure mode did not reproduce. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10204?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Summary
Why
Measured with
screencapture -xwhile Omi was active: avg 0.87s with Omi running vs 0.35s with Omi + CleanShot paused — ~0.5s of WindowServer contention added per capture. In the worst case,SCScreenshotManager.captureImage()and CleanShot's own SCK session serialize on the WindowServer, producing the 20–60s lockups users report. Log analysis showed 11,279"Failed to start stream due to audio/video capture failure"entries, confirming chronic SC contention.Trade-offs
Test plan
/Applications/omi-cleanshot-pause.app/private/tmp/omi-dev.log | grep "Screenshot app"— expect pause/resume log lines🤖 Generated with Claude Code