Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(windows): isolate OCR from shared COM apartments (#7420)

Louis Beaumont7f677aa3dc5e
diff --git a/crates/screenpipe-screen/src/lib.rs b/crates/screenpipe-screen/src/lib.rs
index 426c08206..833e862a0 100644
--- a/crates/screenpipe-screen/src/lib.rs
+++ b/crates/screenpipe-screen/src/lib.rs
@@ -141,3 +141,6 @@ pub mod stream_invalidation {
.is_ok()
}
}
+
+#[cfg(any(target_os = "windows", test))]
+mod ocr_worker;
diff --git a/crates/screenpipe-screen/src/microsoft.rs b/crates/screenpipe-screen/src/microsoft.rs
index c90519597..71199fba3 100644
--- a/crates/screenpipe-screen/src/microsoft.rs
+++ b/crates/screenpipe-screen/src/microsoft.rs
@@ -37,21 +37,98 @@ pub async fn perform_ocr_windows(
return Ok(("".to_string(), "[]".to_string(), None));
}
- let _permit = windows_ocr_semaphore()
+ let permit = windows_ocr_semaphore()
.acquire()
.await
.map_err(|_| anyhow!("Windows OCR semaphore closed"))?;
- // Convert while the image is borrowed, then move the owned pixels into the
- // blocking task. This replaces the old PNG encode -> stream -> decode path
- // with one uncompressed buffer copy into a SoftwareBitmap.
- let rgba = image.to_rgba8().into_raw();
- let languages = languages.to_vec();
-
- tokio::task::spawn_blocking(move || {
- perform_ocr_windows_blocking(rgba, width, height, &languages)
- })
- .await
- .map_err(|error| anyhow!("Windows OCR blocking task failed: {error}"))?
+ // Keep the admission permit with the actual job. Cancelling the awaiting
+ // future must not admit more work while native recognition is still running.
+ let (reply, result) = tokio::sync::oneshot::channel();
+ windows_ocr_worker()
+ .submit(OcrRequest {
+ rgba: image.to_rgba8().into_raw(),
+ width,
+ height,
+ languages: languages.to_vec(),
+ reply,
+ _permit: permit,
+ #[cfg(test)]
+ before_recognize: TEST_BEFORE_RECOGNIZE.with(|hook| hook.borrow_mut().take()),
+ })
+ .map_err(|error| anyhow!(error))?;
+ result
+ .await
+ .map_err(|_| anyhow!("Windows OCR worker stopped"))?
+}
+
+#[cfg(target_os = "windows")]
+struct OcrRequest {
+ rgba: Vec<u8>,
+ width: u32,
+ height: u32,
+ languages: Vec<Language>,
+ reply: tokio::sync::oneshot::Sender<Result<(String, String, Option<f64>)>>,
+ _permit: tokio::sync::SemaphorePermit<'static>,
+ #[cfg(test)]
+ before_recognize: Option<Box<dyn FnOnce() + Send>>,
+}
+
+// Per-caller injection keeps parallel tests from changing another request.
+// This field and hook do not exist in production builds.
+#[cfg(all(test, target_os = "windows"))]
+std::thread_local! {
+ static TEST_BEFORE_RECOGNIZE: std::cell::RefCell<Option<Box<dyn FnOnce() + Send>>> =
+ std::cell::RefCell::new(None);
+}
+
+#[cfg(target_os = "windows")]
+fn windows_ocr_worker() -> &'static crate::ocr_worker::OcrWorker<OcrRequest> {
+ static WORKER: crate::ocr_worker::OcrWorker<OcrRequest> =
+ crate::ocr_worker::OcrWorker::new(run_ocr_request);
+ &WORKER
+}
+
+#[cfg(target_os = "windows")]
+fn run_ocr_request(request: OcrRequest) {
+ #[cfg(not(test))]
+ finish_ocr_request(request, perform_ocr_windows_blocking);
+ #[cfg(test)]
+ {
+ let mut request = request;
+ let before_recognize = request.before_recognize.take();
+ finish_ocr_request(request, |rgba, width, height, languages| {
+ if let Some(hook) = before_recognize {
+ hook();
+ }
+ perform_ocr_windows_blocking(rgba, width, height, languages)
+ });
+ }
+}
+
+#[cfg(target_os = "windows")]
+fn finish_ocr_request(
+ request: OcrRequest,
+ recognize: impl FnOnce(Vec<u8>, u32, u32, &[Language]) -> Result<(String, String, Option<f64>)>,
+) {
+ let OcrRequest {
+ rgba,
+ width,
+ height,
+ languages,
+ reply,
+ _permit,
+ ..
+ } = request;
+ if reply.is_closed() {
+ return;
+ }
+ // Catch a request panic so subsequent captures can still use this worker.
+ // The permit is outside the closure and survives until native work returns.
+ let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
+ recognize(rgba, width, height, &languages)
+ }))
+ .unwrap_or_else(|_| Err(anyhow!("Windows OCR request panicked")));
+ let _ = reply.send(result);
}
#[cfg(target_os = "windows")]
@@ -175,7 +252,7 @@ struct WinRtApartment;
impl WinRtApartment {
fn initialize_mta() -> Result<Self> {
// SAFETY: every successful RoInitialize call is balanced by this
- // guard's Drop implementation on the same blocking-pool thread.
+ // guard's Drop implementation on the dedicated OCR thread.
unsafe { RoInitialize(RO_INIT_MULTITHREADED)? };
Ok(Self)
}
@@ -413,3 +490,210 @@ mod tests {
assert_eq!(pixels, vec![3, 2, 1, 4, 30, 20, 10, 40]);
}
}
+
+#[cfg(all(test, target_os = "windows"))]
+mod request_lifecycle_tests {
+ use super::*;
+ use std::{sync::mpsc, time::Duration};
+
+ fn fixture() -> DynamicImage {
+ image::load_from_memory(include_bytes!("../tests/testing_OCR.png")).unwrap()
+ }
+
+ #[tokio::test]
+ async fn public_api_abort_keeps_native_admission_until_completion() {
+ let (started, running) = tokio::sync::oneshot::channel();
+ let (release, released) = mpsc::channel();
+ let first = tokio::spawn(async move {
+ TEST_BEFORE_RECOGNIZE.with(|hook| {
+ *hook.borrow_mut() = Some(Box::new(move || {
+ started.send(()).unwrap();
+ released.recv_timeout(Duration::from_secs(30)).unwrap();
+ }));
+ });
+ perform_ocr_windows(&fixture(), &[Language::English]).await
+ });
+ tokio::time::timeout(Duration::from_secs(30), running)
+ .await
+ .unwrap()
+ .unwrap();
+ first.abort();
+ assert!(first.await.unwrap_err().is_cancelled());
+ assert!(
+ windows_ocr_semaphore().try_acquire().is_err(),
+ "aborting the public future released native admission early"
+ );
+
+ let image = fixture();
+ let languages = [Language::English];
+ let mut next = Box::pin(perform_ocr_windows(&image, &languages));
+ std::future::poll_fn(|cx| {
+ use std::{future::Future, task::Poll};
+ assert!(
+ matches!(next.as_mut().poll(cx), Poll::Pending),
+ "later OCR bypassed a running request"
+ );
+ Poll::Ready(())
+ })
+ .await;
+ release.send(()).unwrap();
+ let (text, _, _) = tokio::time::timeout(Duration::from_secs(30), next)
+ .await
+ .unwrap()
+ .unwrap();
+ assert!(text.to_lowercase().contains("capture"));
+ }
+
+ #[tokio::test]
+ async fn public_api_recovers_after_request_panic() {
+ TEST_BEFORE_RECOGNIZE.with(|hook| {
+ *hook.borrow_mut() = Some(Box::new(|| panic!("injected public request panic")));
+ });
+ let image = fixture();
+ let error = tokio::time::timeout(
+ Duration::from_secs(30),
+ perform_ocr_windows(&image, &[Language::English]),
+ )
+ .await
+ .unwrap()
+ .unwrap_err();
+ assert!(error.to_string().contains("panicked"));
+ let (text, _, _) = tokio::time::timeout(
+ Duration::from_secs(30),
+ perform_ocr_windows(&image, &[Language::English]),
+ )
+ .await
+ .unwrap()
+ .unwrap();
+ assert!(text.to_lowercase().contains("capture"));
+ }
+
+ #[tokio::test]
+ async fn public_api_recovers_after_native_dimension_error() {
+ // Keep this test thread's WinRT activation alive while the worker uses
+ // the same runtime class. Tearing it down immediately after querying
+ // the static limit can invalidate the cached activation factory.
+ let _apartment = WinRtApartment::initialize_mta().unwrap();
+ let maximum = WindowsOcrEngine::MaxImageDimension().unwrap();
+ let oversized = DynamicImage::new_rgba8(maximum.checked_add(1).unwrap(), 1);
+ let error = tokio::time::timeout(
+ Duration::from_secs(30),
+ perform_ocr_windows(&oversized, &[Language::English]),
+ )
+ .await
+ .unwrap();
+ assert!(
+ error.is_err(),
+ "oversized image must reach native validation"
+ );
+ let (text, _, _) = tokio::time::timeout(
+ Duration::from_secs(30),
+ perform_ocr_windows(&fixture(), &[Language::English]),
+ )
+ .await
+ .unwrap()
+ .unwrap();
+ assert!(text.to_lowercase().contains("capture"));
+ }
+
+ #[tokio::test]
+ async fn cancelled_running_ocr_keeps_permit_until_native_completion() {
+ // This helper bypasses the public entry point. Respect its admission
+ // gate so parallel tests cannot overlap on the cached native engine.
+ let native_admission = windows_ocr_semaphore().acquire().await.unwrap();
+ let image = fixture();
+ let semaphore = Box::leak(Box::new(tokio::sync::Semaphore::new(1)));
+ let (reply, result) = tokio::sync::oneshot::channel();
+ let request = OcrRequest {
+ rgba: image.to_rgba8().into_raw(),
+ width: image.width(),
+ height: image.height(),
+ languages: vec![Language::English],
+ reply,
+ _permit: semaphore.acquire().await.unwrap(),
+ before_recognize: None,
+ };
+ let (started, running) = mpsc::channel();
+ let (release, released) = mpsc::channel();
+ let (finished, completion) = mpsc::channel();
+ let worker = std::thread::spawn(move || {
+ finish_ocr_request(request, |rgba, width, height, languages| {
+ started.send(()).unwrap();
+ released.recv_timeout(Duration::from_secs(30)).unwrap();
+ let result = perform_ocr_windows_blocking(rgba, width, height, languages);
+ finished
+ .send(
+ result
+ .as_ref()
+ .map(|value| value.0.clone())
+ .map_err(ToString::to_string),
+ )
+ .unwrap();
+ result
+ });
+ });
+ running.recv_timeout(Duration::from_secs(30)).unwrap();
+ drop(result);
+ assert!(
+ semaphore.try_acquire().is_err(),
+ "cancellation released a running job's permit"
+ );
+ release.send(()).unwrap();
+ worker.join().unwrap();
+ let text = completion
+ .recv_timeout(Duration::from_secs(30))
+ .unwrap()
+ .unwrap();
+ assert!(text.to_lowercase().contains("capture"));
+ assert_eq!(semaphore.available_permits(), 1);
+ drop(native_admission);
+ let (text, _, _) = perform_ocr_windows(&image, &[Language::English])
+ .await
+ .unwrap();
+ assert!(
+ text.to_lowercase().contains("capture"),
+ "later OCR must recover"
+ );
+ }
+
+ #[tokio::test]
+ async fn abandoned_queued_request_skips_work_and_releases_permit() {
+ let semaphore = Box::leak(Box::new(tokio::sync::Semaphore::new(1)));
+ let (reply, result) = tokio::sync::oneshot::channel();
+ let request = OcrRequest {
+ rgba: Vec::new(),
+ width: 1,
+ height: 1,
+ languages: Vec::new(),
+ reply,
+ _permit: semaphore.acquire().await.unwrap(),
+ before_recognize: None,
+ };
+ drop(result);
+ finish_ocr_request(request, |_, _, _, _| panic!("cancelled queued request ran"));
+ assert_eq!(semaphore.available_permits(), 1);
+ }
+
+ #[tokio::test]
+ async fn request_panic_returns_error_and_releases_permit() {
+ let semaphore = Box::leak(Box::new(tokio::sync::Semaphore::new(1)));
+ let (reply, result) = tokio::sync::oneshot::channel();
+ let request = OcrRequest {
+ rgba: Vec::new(),
+ width: 1,
+ height: 1,
+ languages: Vec::new(),
+ reply,
+ _permit: semaphore.acquire().await.unwrap(),
+ before_recognize: None,
+ };
+ finish_ocr_request(request, |_, _, _, _| panic!("injected request panic"));
+ assert!(result
+ .await
+ .unwrap()
+ .unwrap_err()
+ .to_string()
+ .contains("panicked"));
+ assert_eq!(semaphore.available_permits(), 1);
+ }
+}
diff --git a/crates/screenpipe-screen/src/ocr_worker.rs b/crates/screenpipe-screen/src/ocr_worker.rs
new file mode 100644
index 000000000..8454b1e7d
--- /dev/null
+++ b/crates/screenpipe-screen/src/ocr_worker.rs
@@ -0,0 +1,121 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+
+//! A bounded, lazy OS thread for work that must not inherit a shared pool's COM mode.
+use std::sync::{mpsc, Mutex};
+
+pub(crate) struct OcrWorker<T> {
+ sender: Mutex<Option<mpsc::SyncSender<T>>>,
+ handle: fn(T),
+}
+
+impl<T: Send + 'static> OcrWorker<T> {
+ pub(crate) const fn new(handle: fn(T)) -> Self {
+ Self {
+ sender: Mutex::new(None),
+ handle,
+ }
+ }
+
+ pub(crate) fn submit(&self, mut request: T) -> Result<(), String> {
+ let mut sender = self.sender.lock().map_err(|_| "OCR worker lock poisoned")?;
+ // A dead worker may be replaced once. Never retry a job already accepted.
+ for _ in 0..2 {
+ if sender.is_none() {
+ let (tx, rx) = mpsc::sync_channel(1);
+ let handle = self.handle;
+ std::thread::Builder::new()
+ .name("screenpipe-windows-ocr".into())
+ .spawn(move || {
+ for request in rx {
+ handle(request);
+ }
+ })
+ .map_err(|error| format!("Could not start OCR worker: {error}"))?;
+ *sender = Some(tx);
+ }
+ match sender.as_ref().unwrap().try_send(request) {
+ Ok(()) => return Ok(()),
+ Err(mpsc::TrySendError::Full(_)) => return Err("OCR worker queue full".into()),
+ Err(mpsc::TrySendError::Disconnected(returned)) => {
+ *sender = None;
+ request = returned;
+ }
+ }
+ }
+ Err("OCR worker stopped before accepting the request".into())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::{thread, time::Duration};
+
+ #[test]
+ fn reuses_an_isolated_thread() {
+ let worker = OcrWorker::new(|reply: mpsc::Sender<thread::ThreadId>| {
+ reply.send(thread::current().id()).unwrap();
+ });
+ let (tx, rx) = mpsc::channel();
+ worker.submit(tx.clone()).unwrap();
+ let first = rx.recv_timeout(Duration::from_secs(5)).unwrap();
+ worker.submit(tx).unwrap();
+ assert_eq!(first, rx.recv_timeout(Duration::from_secs(5)).unwrap());
+ assert_ne!(first, thread::current().id());
+ }
+
+ struct Job {
+ started: mpsc::Sender<()>,
+ release: mpsc::Receiver<()>,
+ }
+
+ #[test]
+ fn queue_is_bounded_while_worker_is_busy() {
+ let worker = OcrWorker::new(|job: Job| {
+ job.started.send(()).unwrap();
+ job.release.recv_timeout(Duration::from_secs(5)).unwrap();
+ });
+ let (started, observed) = mpsc::channel();
+ let (release, wait) = mpsc::channel();
+ worker
+ .submit(Job {
+ started: started.clone(),
+ release: wait,
+ })
+ .unwrap();
+ observed.recv_timeout(Duration::from_secs(5)).unwrap();
+ let (release_next, wait_next) = mpsc::channel();
+ worker
+ .submit(Job {
+ started: started.clone(),
+ release: wait_next,
+ })
+ .unwrap();
+ let (_, wait_overflow) = mpsc::channel();
+ assert!(worker
+ .submit(Job {
+ started,
+ release: wait_overflow
+ })
+ .unwrap_err()
+ .contains("queue full"));
+ release.send(()).unwrap();
+ observed.recv_timeout(Duration::from_secs(5)).unwrap();
+ release_next.send(()).unwrap();
+ }
+
+ #[test]
+ fn replaces_disconnected_worker_without_losing_request() {
+ let worker = OcrWorker::new(|reply: mpsc::Sender<()>| {
+ reply.send(()).unwrap();
+ });
+ // Model a previous worker's receiver having gone away, without a sleep/race.
+ let (dead_sender, receiver) = mpsc::sync_channel(1);
+ drop(receiver);
+ *worker.sender.lock().unwrap() = Some(dead_sender);
+ let (tx, rx) = mpsc::channel();
+ worker.submit(tx).unwrap();
+ rx.recv_timeout(Duration::from_secs(5)).unwrap();
+ }
+}
diff --git a/crates/screenpipe-screen/tests/windows_vision_test.rs b/crates/screenpipe-screen/tests/windows_vision_test.rs
index 3f4f0d84f..ac9db9f2c 100644
--- a/crates/screenpipe-screen/tests/windows_vision_test.rs
+++ b/crates/screenpipe-screen/tests/windows_vision_test.rs
@@ -1,3 +1,5 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
#[cfg(target_os = "windows")]
#[cfg(test)]
mod tests {
@@ -118,3 +120,68 @@ mod tests {
// );
}
}
+
+#[cfg(all(test, target_os = "windows"))]
+mod apartment_regression {
+ use screenpipe_core::Language;
+ use screenpipe_screen::perform_ocr_windows;
+ use std::time::Duration;
+ use windows::Win32::System::WinRT::{
+ RoInitialize, RoUninitialize, RO_INIT_MULTITHREADED, RO_INIT_SINGLETHREADED,
+ };
+
+ #[test]
+ fn windows_ocr_survives_sta_blocking_pool() {
+ // The pool has exactly one thread, and its apartment stays STA until
+ // shutdown. Hooks balance successful initialization on that same thread.
+ let runtime = tokio::runtime::Builder::new_current_thread()
+ .enable_all()
+ .max_blocking_threads(1)
+ .on_thread_start(|| unsafe { RoInitialize(RO_INIT_SINGLETHREADED).unwrap() })
+ .on_thread_stop(|| unsafe { RoUninitialize() })
+ .build()
+ .unwrap();
+ runtime.block_on(async {
+ // Prove the precondition rather than assuming which pool thread ran.
+ let code = tokio::task::spawn_blocking(|| unsafe {
+ match RoInitialize(RO_INIT_MULTITHREADED) {
+ Err(error) => error.code().0 as u32,
+ Ok(()) => {
+ RoUninitialize();
+ 0
+ }
+ }
+ })
+ .await
+ .unwrap();
+ assert_eq!(code, 0x80010106, "pool must reject MTA initialization");
+ let image = image::load_from_memory(include_bytes!("testing_OCR.png")).unwrap();
+ for _ in 0..3 {
+ let (text, boxes, confidence) = tokio::time::timeout(
+ Duration::from_secs(30),
+ perform_ocr_windows(&image, &[Language::English]),
+ )
+ .await
+ .expect("OCR timed out")
+ .expect("OCR must not inherit pool STA");
+ assert!(
+ text.to_lowercase().contains("capture"),
+ "fixture text missing: {text}"
+ );
+ let words: Vec<serde_json::Value> = serde_json::from_str(&boxes).unwrap();
+ assert!(!words.is_empty());
+ assert_eq!(confidence, Some(1.0));
+ }
+ });
+ runtime.shutdown_timeout(Duration::from_secs(5));
+ }
+
+ #[tokio::test]
+ async fn windows_ocr_empty_image_stays_empty() {
+ let empty = image::DynamicImage::new_rgba8(0, 0);
+ assert_eq!(
+ perform_ocr_windows(&empty, &[]).await.unwrap(),
+ (String::new(), "[]".into(), None)
+ );
+ }
+}
diff --git a/docs/COVERAGE.md b/docs/COVERAGE.md
index 453a711ba..8408eccd6 100644
--- a/docs/COVERAGE.md
+++ b/docs/COVERAGE.md
@@ -37,14 +37,14 @@ results and `cargo llvm-cov` data on top when judging release confidence.
### Core Engine
- Mapped suites: 36
-- Mapped Rust files: 376
-- Active test blocks: 3709
+- Mapped Rust files: 377
+- Active test blocks: 3720
- Ignored/manual test blocks: 168
-- Weighted coverage points: 3060.8
+- Weighted coverage points: 3068.5
| Platform | Suites | Active tests | Ignored tests | Weighted points | Layers | Flows | Critical score |
| --- | --- | --- | --- | --- | --- | --- | --- |
-| windows | 32 | 3563 | 154 | 2994.6 | 21 | 11 | 100% |
+| windows | 32 | 3574 | 154 | 3002.3 | 21 | 11 | 100% |
| macos | 31 | 3602 | 129 | 2992.2 | 22 | 11 | 100% |
| linux | 28 | 3159 | 129 | 2627.0 | 20 | 11 | 100% |
diff --git a/docs/coverage/CORE.md b/docs/coverage/CORE.md
index 5866a481a..c18164cd7 100644
--- a/docs/coverage/CORE.md
+++ b/docs/coverage/CORE.md
@@ -8,11 +8,11 @@ confidence, and criticality.
- Manifest: `docs/coverage/core-engine-map.json`
- Tracked crates: screenpipe-engine, screenpipe-db, screenpipe-sqlite-coordinator, screenpipe-audio, screenpipe-screen, screenpipe-a11y, screenpipe-fs
- Mapped suites: 36
-- Mapped Rust files: 376
-- Active test blocks: 3709
+- Mapped Rust files: 377
+- Active test blocks: 3720
- Ignored/manual test blocks: 168
-- Declared test blocks: 3877
-- Weighted coverage points: 3060.8
+- Declared test blocks: 3888
+- Weighted coverage points: 3068.5
Confidence weights: strong=1.0, partial=0.7, conditional=0.4, smoke=0.3.
Criticality weights: high=1.0, medium=0.7, low=0.4.
@@ -23,7 +23,7 @@ are explicitly enabled in a runtime lane.
| Platform | Suites | Active tests | Ignored tests | Weighted points | Layers | Flows | Critical score |
| --- | --- | --- | --- | --- | --- | --- | --- |
-| windows | 32 | 3563 | 154 | 2994.6 | 21 | 11 | 100% |
+| windows | 32 | 3574 | 154 | 3002.3 | 21 | 11 | 100% |
| macos | 31 | 3602 | 129 | 2992.2 | 22 | 11 | 100% |
| linux | 28 | 3159 | 129 | 2627.0 | 20 | 11 | 100% |
@@ -35,7 +35,7 @@ are explicitly enabled in a runtime lane.
| screenpipe-db | 5 | 63 | 25 | 584 | 25 | 556.1 | 9 |
| screenpipe-sqlite-coordinator | 1 | 0 | 3 | 27 | 0 | 27.0 | 2 |
| screenpipe-audio | 7 | 25 | 53 | 672 | 48 | 588.8 | 5 |
-| screenpipe-screen | 6 | 9 | 18 | 261 | 9 | 234.6 | 4 |
+| screenpipe-screen | 6 | 9 | 19 | 272 | 9 | 242.3 | 4 |
| screenpipe-a11y | 4 | 2 | 31 | 376 | 34 | 277.3 | 3 |
| screenpipe-fs | 1 | 0 | 1 | 3 | 0 | 3.0 | 3 |
@@ -71,7 +71,7 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su
| engine-lifecycle | 6 suites / 247 active / 1 ignored / 222.0 pts | 6 suites / 247 active / 1 ignored / 222.0 pts | 6 suites / 243 active / 9 ignored / 221.1 pts |
| local-api | 3 suites / 470 active / 11 ignored / 331.4 pts | 3 suites / 470 active / 11 ignored / 331.4 pts | 3 suites / 470 active / 11 ignored / 331.4 pts |
| meeting | 6 suites / 1683 active / 24 ignored / 1374.3 pts | 6 suites / 1683 active / 24 ignored / 1374.3 pts | 4 suites / 1334 active / 20 ignored / 1049.0 pts |
-| ocr | 4 suites / 125 active / 7 ignored / 119.0 pts | 4 suites / 129 active / 7 ignored / 124.5 pts | 3 suites / 120 active / 6 ignored / 115.5 pts |
+| ocr | 4 suites / 136 active / 7 ignored / 126.7 pts | 4 suites / 129 active / 7 ignored / 124.5 pts | 3 suites / 120 active / 6 ignored / 115.5 pts |
| os-integration | 1 suites / 6 active / 0 ignored / 1.7 pts | 1 suites / 6 active / 0 ignored / 1.7 pts | - |
| performance | 13 suites / 1620 active / 78 ignored / 1433.3 pts | 14 suites / 1728 active / 82 ignored / 1476.5 pts | 13 suites / 1620 active / 78 ignored / 1433.3 pts |
| pipes | 1 suites / 522 active / 3 ignored / 365.4 pts | 1 suites / 522 active / 3 ignored / 365.4 pts | 1 suites / 522 active / 3 ignored / 365.4 pts |
@@ -83,7 +83,7 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su
| timeline | 4 suites / 1212 active / 44 ignored / 993.0 pts | 4 suites / 1212 active / 44 ignored / 993.0 pts | 4 suites / 1212 active / 44 ignored / 993.0 pts |
| transcription | 6 suites / 866 active / 47 ignored / 678.1 pts | 5 suites / 860 active / 47 ignored / 673.9 pts | 5 suites / 860 active / 47 ignored / 673.9 pts |
| ui-events | 4 suites / 790 active / 34 ignored / 599.5 pts | 3 suites / 723 active / 5 ignored / 552.6 pts | 3 suites / 723 active / 5 ignored / 552.6 pts |
-| vision-capture | 6 suites / 557 active / 32 ignored / 440.0 pts | 6 suites / 561 active / 32 ignored / 445.5 pts | 5 suites / 552 active / 31 ignored / 436.5 pts |
+| vision-capture | 6 suites / 568 active / 32 ignored / 447.7 pts | 6 suites / 561 active / 32 ignored / 445.5 pts | 5 suites / 552 active / 31 ignored / 436.5 pts |
## Critical Flow Matrix
@@ -91,7 +91,7 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su
| --- | --- | --- | --- | --- |
| Settings to engine recording config | configuration | covered (strong; engine-config-lifecycle, db-accessibility-ui-events) | covered (strong; engine-config-lifecycle, db-accessibility-ui-events) | covered (strong; engine-config-lifecycle, db-accessibility-ui-events) |
| Engine health, sleep, and lifecycle | engine-lifecycle | covered (strong; engine-config-lifecycle, engine-db-recovery-cli) | covered (strong; engine-config-lifecycle, engine-db-recovery-cli) | covered (strong; engine-config-lifecycle, engine-db-recovery-cli) |
-| Capture, OCR, and frame persistence | vision-capture, ocr | covered (partial; screen-capture-ocr-contract, screen-windows-ocr) | covered (strong; screen-capture-ocr-contract, screen-macos-ocr) | covered (partial; screen-capture-ocr-contract) |
+| Capture, OCR, and frame persistence | vision-capture, ocr | covered (partial; screen-windows-ocr, screen-capture-ocr-contract) | covered (strong; screen-capture-ocr-contract, screen-macos-ocr) | covered (partial; screen-capture-ocr-contract) |
| Timeline frame and stream delivery | timeline | covered (strong; engine-api-routes, db-timeline-frames) | covered (strong; engine-api-routes, db-timeline-frames) | covered (strong; engine-api-routes, db-timeline-frames) |
| Local API search and indexing | local-api, db-search | covered (strong; engine-local-api-search-integration) | covered (strong; engine-local-api-search-integration) | covered (strong; engine-local-api-search-integration) |
| Audio record, transcribe, and reconcile | audio, transcription | covered (strong; audio-meetings-speakers-dedup, audio-transcription-pipeline) | covered (strong; audio-meetings-speakers-dedup, audio-transcription-pipeline) | covered (strong; audio-meetings-speakers-dedup, audio-transcription-pipeline) |
@@ -153,7 +153,7 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su
| screen-custom-ocr | screenpipe-screen | windows, macos, linux | ocr | capture-ocr-pipeline | medium | conditional | manual | 1 | 0 | 2 | Custom OCR tests are ignored by default and only contribute when explicitly run. |
| screen-macos-ocr | screenpipe-screen | macos | ocr, vision-capture | capture-ocr-pipeline | high | strong | mixed | 2 | 9 | 1 | Apple Vision OCR source/unit coverage and fixture OCR assertions. |
| screen-monitor-platform | screenpipe-screen | windows, macos, linux | vision-capture | capture-ocr-pipeline | medium | partial | unit | 5 | 40 | 5 | Per-OS monitor enumeration (Windows, macOS, Wayland/portal on Linux) and the persistent Windows.Graphics.Capture session. Each file is cfg-gated and only executes on its target OS. |
-| screen-windows-ocr | screenpipe-screen | windows | ocr, vision-capture | capture-ocr-pipeline | high | partial | integration | 2 | 5 | 1 | Windows OCR fixture coverage plus an ignored continuous-capture probe that requires a live desktop. |
+| screen-windows-ocr | screenpipe-screen | windows | ocr, vision-capture | capture-ocr-pipeline | high | partial | integration | 3 | 16 | 1 | Windows OCR fixture and STA-pool regression tests, portable bounded-worker tests, plus an ignored continuous-capture probe that requires a live desktop. Native OCR tests require an installed English recognizer. |
| sqlite-coordinator-durable-quarantine | screenpipe-sqlite-coordinator | windows, macos, linux | database, engine-lifecycle | engine-health-lifecycle, performance-liveness | high | strong | unit | 3 | 27 | 0 | Process-wide single-writer gates and manager ownership, SQLite runtime pinning, pending incident markers, fresh integrity verification, confirmed-damage quarantine, file-identity guarded admission, and crash-journal recovery. |
## File Inventory
@@ -512,13 +512,14 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su
| screen-capture-ocr-contract | screenpipe-screen | src/core.rs | source | 1 | 0 | 1 |
| screen-capture-windowing | screenpipe-screen | src/frame_comparison.rs | source | 16 | 0 | 16 |
| screen-capture-windowing | screenpipe-screen | src/metrics.rs | source | 17 | 0 | 17 |
-| screen-windows-ocr | screenpipe-screen | src/microsoft.rs | source | 4 | 0 | 4 |
+| screen-windows-ocr | screenpipe-screen | src/microsoft.rs | source | 10 | 0 | 10 |
| screen-capture-windowing | screenpipe-screen | src/monitor.rs | source | 5 | 0 | 5 |
| screen-monitor-platform | screenpipe-screen | src/monitor/linux_portal.rs | source | 5 | 0 | 5 |
| screen-monitor-platform | screenpipe-screen | src/monitor/linux_wayland.rs | source | 5 | 0 | 5 |
| screen-monitor-platform | screenpipe-screen | src/monitor/macos.rs | source | 20 | 2 | 22 |
| screen-monitor-platform | screenpipe-screen | src/monitor/windows.rs | source | 2 | 1 | 3 |
| screen-capture-windowing | screenpipe-screen | src/ocr_cache.rs | source | 15 | 0 | 15 |
+| screen-windows-ocr | screenpipe-screen | src/ocr_worker.rs | source | 3 | 0 | 3 |
| screen-capture-windowing | screenpipe-screen | src/snapshot_writer.rs | source | 4 | 0 | 4 |
| screen-capture-ocr-contract | screenpipe-screen | src/tesseract.rs | source | 6 | 0 | 6 |
| screen-capture-ocr-contract | screenpipe-screen | src/text_regions.rs | source | 8 | 0 | 8 |
@@ -532,7 +533,7 @@ bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-su
| screen-capture-windowing | screenpipe-screen | tests/frame_window_mismatch_test.rs | integration | 3 | 0 | 3 |
| screen-capture-windowing | screenpipe-screen | tests/monitor_cache_test.rs | integration | 7 | 0 | 7 |
| screen-capture-windowing | screenpipe-screen | tests/url_timing_test.rs | integration | 7 | 0 | 7 |
-| screen-windows-ocr | screenpipe-screen | tests/windows_vision_test.rs | integration | 1 | 1 | 2 |
+| screen-windows-ocr | screenpipe-screen | tests/windows_vision_test.rs | integration | 3 | 1 | 4 |
| sqlite-coordinator-durable-quarantine | screenpipe-sqlite-coordinator | src/lib.rs | source | 14 | 0 | 14 |
| sqlite-coordinator-durable-quarantine | screenpipe-sqlite-coordinator | src/quarantine.rs | source | 12 | 0 | 12 |
| sqlite-coordinator-durable-quarantine | screenpipe-sqlite-coordinator | src/verification.rs | source | 1 | 0 | 1 |
diff --git a/docs/coverage/core-engine-map.json b/docs/coverage/core-engine-map.json
index 99416d8e2..0f914c6d7 100644
--- a/docs/coverage/core-engine-map.json
+++ b/docs/coverage/core-engine-map.json
@@ -1224,6 +1224,7 @@
"crate": "screenpipe-screen",
"files": [
"src/microsoft.rs",
+ "src/ocr_worker.rs",
"tests/windows_vision_test.rs"
],
"platforms": [
@@ -1239,7 +1240,7 @@
"criticality": "high",
"confidence": "partial",
"kind": "integration",
- "notes": "Windows OCR fixture coverage plus an ignored continuous-capture probe that requires a live desktop."
+ "notes": "Windows OCR fixture and STA-pool regression tests, portable bounded-worker tests, plus an ignored continuous-capture probe that requires a live desktop. Native OCR tests require an installed English recognizer."
},
{
"id": "screen-custom-ocr",