Type: Bug Report
Description:
The capture scheduler uses a lock to prevent concurrent capture operations. However, if a capture operation hangs indefinitely (e.g., due to system permission issues, display driver problems, or OCR processing stalls), the lock is never released, causing all subsequent scheduled and manual captures to be skipped silently.
Steps to Reproduce:
- Start screencap with the scheduler running
- Trigger a condition where the capture pipeline stalls (e.g., disconnect external display during capture)
- Observe that all subsequent captures are skipped with "Capture already in progress"
Expected Behavior:
The scheduler should detect stale locks and recover automatically, continuing to capture after a reasonable timeout.
Proposed Solution:
Add a timeout mechanism (e.g., 60 seconds) that force-releases stale capture locks:
const CAPTURE_TIMEOUT_MS = 60 * 1000; // 60 seconds max
let captureLockAcquiredAt: number | null = null;
function checkAndReleaseStaleLock(): boolean {
if (captureLock && captureLockAcquiredAt) {
const heldFor = Date.now() - captureLockAcquiredAt;
if (heldFor > CAPTURE_TIMEOUT_MS) {
logger.warn("Capture lock held too long, force releasing", {
heldForMs: heldFor,
timeoutMs: CAPTURE_TIMEOUT_MS,
});
captureLock = null;
captureLockAcquiredAt = null;
return true;
}
}
return false;
}
Environment:
- macOS 14.x
- screencap v1.17.x
Type: Bug Report
Description:
The capture scheduler uses a lock to prevent concurrent capture operations. However, if a capture operation hangs indefinitely (e.g., due to system permission issues, display driver problems, or OCR processing stalls), the lock is never released, causing all subsequent scheduled and manual captures to be skipped silently.
Steps to Reproduce:
Expected Behavior:
The scheduler should detect stale locks and recover automatically, continuing to capture after a reasonable timeout.
Proposed Solution:
Add a timeout mechanism (e.g., 60 seconds) that force-releases stale capture locks:
Environment: